-
Notifications
You must be signed in to change notification settings - Fork 0
/
ui.tcl
63 lines (54 loc) · 2.47 KB
/
ui.tcl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
proc ui.page_top win { ::tk::TextSetCursor $win 1.0 }
proc ui.page_end win { ::tk::TextSetCursor $win {end - 1 char} }
proc ui.paste_selection win { tk_textPaste $win }
proc ui.delete_selection win { tk_textCut $win }
proc ui.copy_selection win {
set selection ""
catch { set selection [selection get] }
if { "x$selection" != "x" } {
clipboard clear
clipboard append $selection
} {
tk_textCopy $win
}
}
proc ui.page_down win { ::tk::TextScrollPages $win 1 }
proc ui.page_up win { ::tk::TextScrollPages $win -1 }
proc ui.clear_screen win { window.clear_screen $win }
proc ui.delete_line win { $win delete {insert linestart} {insert lineend} }
proc ui.delete_line_entry win { $win delete 0 end }
proc ui.left_char win { ::tk::TextSetCursor $win insert-1c }
proc ui.right_char win { ::tk::TextSetCursor $win insert+1c }
proc ui.up_line win { ::tk::TextSetCursor $win [tkTextUpDownLine $win -1] }
proc ui.down_line win { ::tk::TextSetCursor $win [tkTextUpDownLine $win 1] }
proc ui.start_line win { ::tk::TextSetCursor $win {insert linestart} }
proc ui.end_line win { ::tk::TextSetCursor $win {insert lineend} }
proc ui.left_word_start win {
$win mark set insert {insert-1c wordstart}
while { [$win get insert {insert+1c}] == " " } { ui.left_char $win }
$win mark set insert {insert wordstart}
}
proc ui.left_word_start_entry win {
tkEntrySetCursor $win [string wordstart [$win get] [expr [$win index insert] - 1]]
}
proc ui.right_word_start win {
$win mark set insert {insert wordend}
while { [$win get insert {insert+1c}] == " " } { ui.right_char $win }
}
proc ui.right_word_start_entry win {
tkEntrySetCursor $win [string wordend [$win get] [$win index insert]]
}
proc ui.delete_to_end win {
if [$win compare insert == {insert lineend}] {
$win delete insert
} else {
$win delete insert {insert lineend}
}
}
proc ui.delete_to_end_entry win { $win delete insert end }
proc ui.delete_to_beginning win { $win delete {insert linestart} insert }
proc ui.delete_to_beginning_entry win { $win delete 0 insert }
proc ui.delete_word_right win { $win delete insert {insert wordend} }
proc ui.delete_word_left win { $win delete {insert -1c wordstart} insert }
proc ui.delete_char_right win { $win delete insert {insert +1c} }
proc ui.delete_char_left win { $win delete {insert -1c} insert }