import System;
import System.Windows.Forms;
import System.Drawing;

var f : MyForm = new MyForm();
f.ShowDialog();

class MyForm extends Form {
	var text1 : TextBox;
	var btn1 : MyButton;
	var btn2 : MyButton;
	var btn3 : MyButton;
	var btn4 : MyButton;
	function MyForm() {
		super();
		Size = new System.Drawing.Size(200, 120);
		Location = new Point(200, 50);
		StartPosition = FormStartPosition.Manual;
		text1 = new TextBox();
		text1.Size = new System.Drawing.Size(180, 60);
		text1.Left = 5;
		text1.Multiline = true;
		Controls.Add(text1);
		btn1 = new MyButton();
		btn1.Text = "<-|";
		btn1.Width = 40;
		btn1.Location = new Point(10, 65);
		Controls.Add(btn1);
		btn2 = new MyButton();
		btn2.Text = ">-|";
		btn2.Width = 40;
		btn2.Location = new Point(55, 65);
		Controls.Add(btn2);
		btn3 = new MyButton();
		btn3.Text = "|-<";
		btn3.Width = 40;
		btn3.Location = new Point(100, 65);
		Controls.Add(btn3);
		btn4 = new MyButton();
		btn4.Text = "|->";
		btn4.Width = 40;
		btn4.Location = new Point(145, 65);
		Controls.Add(btn4);
	}
}

class MyButton extends Button {
	protected override function OnClick(e : EventArgs) {
		var t : TextBox = MyForm(Parent).text1;
		if(Text == "<-|") {
			t.SelectionStart--;
			t.SelectionLength++;
		}
		else if(Text == ">-|") {
			t.SelectionStart++;
			t.SelectionLength--;
		}
		else if(Text == "|-<")
			t.SelectionLength--;
		else
			t.SelectionLength++;
		t.Focus();
	}
}
