1ntextBindings(n) Alternative Bindings for the Text Widget ntextBindings(n)
2
3
4
5______________________________________________________________________________
6
8 ntextBindings - Alternative Bindings for the Text Widget
9
11 package require Tcl 8.5
12
13 package require Tk 8.5
14
15 package require ntext ?0.81?
16
17______________________________________________________________________________
18
20 The ntext package provides a binding tag named Ntext for use by text
21 widgets in place of the default Text binding tag.
22
23 The Text binding tag provides around one hundred bindings to the text
24 widget (the exact number is platform-dependent). A few of these behave
25 in a way that is different from most contemporary text-editing applica‐
26 tions. Ntext aims to provide more familiar behaviour.
27
28 Features of the Ntext bindings that differ from the default Text bind‐
29 ings:
30
31 • Clicking near the end of a (logical) line moves the cursor to
32 the end of that line (not the start of the next line). If the
33 widget is in -wrap word mode, the same rule applies to display
34 lines.
35
36 • Double-clicking or dragging near the end of a (logical) line
37 will highlight/select characters from the end of that line (not
38 the next line, or the region at the end of the line where there
39 are no characters). If the widget is in -wrap word mode, the
40 same rule applies to display lines.
41
42 • The End key implements "Smart End" (successive keypresses move
43 the cursor to the end of the display line, then to the end of
44 the logical line); the Home key implements "Smart Home" (which
45 is similar to "Smart End", but also toggles between the begin‐
46 ning and end of leading whitespace).
47
48 • When a selection exists, a <<Paste>> operation (e.g. <Control-
49 v>) overwrites the selection (as most editors do), and does so
50 on all platforms.
51
52 • The <Insert> key toggles between "Insert" and "Overwrite" modes
53 for keyboard input. (In contrast, the Text binding tag uses
54 <Insert> as a method to paste the "primary selection", a task
55 that can be accomplished instead by mouse middle-click.)
56
57 • The <Escape> key clears the selection.
58
59 • Selecting with <Shift-Button1> selects from the previous posi‐
60 tion of the insertion cursor. (In the Text binding tag, the se‐
61 lection anchor may be the position of the previous mouse click.)
62
63 • <Shift-Button1> operations do not alter the selection anchor.
64 (In the Text binding tag, they do.)
65
66 • By default, the Ntext binding tag does not provide several of
67 the Control-key bindings supplied by the Text binding tag. Mod‐
68 ern keyboards offer alternatives, such as cursor keys for navi‐
69 gation; modern applications often use the Control-key bindings
70 for other purposes (e.g. <Control-p> for "print").
71
72 The last three cases, the behavior of Text is often useful, so Ntext
73 gives you the option of retaining it, by setting variables defined in
74 the ::ntext namespace to 1 (instead of their default 0). Explaining
75 these features in more detail:
76
77 • If the mouse is clicked at position A, then the keyboard is used
78 to move the cursor to B, then shift is held down, and the mouse
79 is clicked at C: the Text binding tag gives a selection from A
80 to C; the Ntext gives a selection from B to C. If you want
81 Ntext to behave like Text in this respect, set ::ntext::classic‐
82 MouseSelect to 1.
83
84 • The Text binding tag allows successive <Shift-Button-1> events
85 to change both ends of the selection, by moving the selection
86 anchor to the end of the selection furthest from the mouse
87 click. Instead, the Ntext binding tag fixes the anchor, and
88 multiple Shift-Button-1 events can only move the non-anchored
89 end of the selection. If you want Ntext to behave like Text in
90 this respect, set ::ntext::classicAnchor to 1. In both Text and
91 Ntext, keyboard navigation with the Shift key held down alters
92 the selection and keeps the selection anchor fixed.
93
94 • The following "extra" Text bindings are switched off by default,
95 but can be activated in Ntext by setting ::ntext::classicExtras
96 to 1: <Control-a>, <Control-b>, <Control-d>, <Control-e>, <Con‐
97 trol-f>, <Control-h>, <Control-i>, <Control-k>, <Control-n>,
98 <Control-o>, <Control-p>, <Control-t>, <Control-space>, <Con‐
99 trol-Shift-space>.
100
102 Ntext provides alternatives to a number of behaviours of the classic
103 Text binding tag. Where there is an option, the Ntext behaviour is
104 switched on by default, except for display-line indentation which is
105 discussed on a separate page at ntextIndent.
106
107 The behaviour of Ntext may be configured application-wide by setting
108 the values of a number of namespace variables:
109
110 ::ntext::classicAnchor
111
112 • 0 - (default value) selects Ntext behaviour, i.e. the anchor
113 point is fixed
114
115 • 1 - selects classic Text behaviour, i.e. the anchor point is
116 variable
117
118 ::ntext::classicExtras
119
120 • 0 - (default value) selects Ntext behaviour, i.e. several "ex‐
121 tra" Text bindings are de-activated
122
123 • 1 - selects classic Text behaviour, i.e. the "extra" Text bind‐
124 ings are activated
125
126 ::ntext::classicMouseSelect
127
128 • 0 - (default value) selects Ntext behaviour, i.e. the anchor
129 point for mouse selection operations is moved by keyboard navi‐
130 gation
131
132 • 1 - selects classic Text behaviour
133
134 ::ntext::overwrite
135
136 • 0 - (initial value) text typed at the keyboard is inserted into
137 the widget
138
139 • 1 - text typed at the keyboard overwrites text already in the
140 widget
141
142 • The value is toggled by the Insert key.
143
145 To use Ntext but keep classic Text 's variable-anchor feature:
146
147
148 package require ntext
149 text .t
150 set ::ntext::classicAnchor 1
151 bindtags .t {.t Ntext . all}
152
153
155 bindtags, ntext, ntextIndent, text
156
158 bindtags, text
159
160
161
162ntext 0.81 ntextBindings(n)