1ntext(n) Alternative Bindings for the Text Widget ntext(n)
2
3
4
5______________________________________________________________________________
6
8 ntext - 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 purpose of the ntext package is to make the text widget behave more
21 like other text-editing applications. It makes the text widget more
22 useful for implementing a text editor, and makes it behave in a way
23 that will be more familiar to most users.
24
25 The package provides a binding tag named Ntext for use by text widgets
26 in place of the default Text binding tag.
27
28 Package ntext 's functions and variables are contained entirely in the
29 ::ntext namespace; its other code is contained in the binding tag
30 Ntext. ntext has no exports to the global or other namespaces, and no
31 new widget commands. It uses modified copies of the Tk code, leaving
32 the original code, and the Text binding tag, unchanged.
33
34 The differences between the Ntext binding tag and the default Text
35 binding tag are in three categories:
36
37 · Some Text bindings behave differently from most text-editing
38 applications. Ntext gives these bindings more familiar behav‐
39 iour. For details see ntextBindings.
40
41 · When a logical line with leading whitespace is word-wrapped onto
42 more than one display line, the wrapped display lines begin fur‐
43 ther to the left than the first display line, which can make the
44 text layout untidy and difficult to read. Ntext can indent the
45 wrapped lines to match the leading whitespace of the first dis‐
46 play line (this facility is switched off by default). For
47 details see ntextIndent.
48
49 · When the user navigates or selects text, Tcl/Tk sometimes needs
50 to detect word boundaries. Ntext provides improved rules for
51 word boundary detection. For details see ntextWordBreak.
52
53 The remainder of this page describes the basic use and configuration of
54 all three aspects of Ntext. For more detailed information on the dif‐
55 ferent facilities of Ntext, see the pages ntextBindings, ntextIndent,
56 and ntextWordBreak.
57
58 See Section EXAMPLE for how to apply the Ntext binding tag in place of
59 the Text binding tag.
60
62 Ntext provides alternatives to a number of behaviours of the classic
63 Text binding tag. Where there is an option, the Ntext behaviour
64 (except for display-line indentation) is switched on by default.
65
66 The behaviour of Ntext may be configured application-wide by setting
67 the values of a number of namespace variables:
68
69 ::ntext::classicAnchor
70
71 · 0 - (default value) selects Ntext behaviour, i.e. the anchor
72 point is fixed
73
74 · 1 - selects classic Text behaviour, i.e. the anchor point is
75 variable
76
77 ::ntext::classicExtras
78
79 · 0 - (default value) selects Ntext behaviour, i.e. several tradi‐
80 tional Text bindings are de-activated
81
82 · 1 - selects classic Text behaviour, i.e. all Text bindings are
83 activated
84
85 ::ntext::classicMouseSelect
86
87 · 0 - (default value) selects Ntext behaviour, i.e. the anchor
88 point for mouse selection operations is moved by keyboard navi‐
89 gation
90
91 · 1 - selects classic Text behaviour
92
93 ::ntext::classicWordBreak
94
95 · 0 - (default value) selects Ntext behaviour, i.e. platform-inde‐
96 pendent, two classes of word characters and one class of non-
97 word characters.
98
99 · 1 - selects classic Text behaviour, i.e. platform-dependent, one
100 class of word characters and one class of non-word characters
101
102 · After changing this value, the matching patterns should be
103 recalculated. See ntextWordBreak for details and advanced con‐
104 figuration options.
105
106 ::ntext::classicWrap
107
108 · 0 - selects Ntext behaviour, i.e. display lines of text widgets
109 in -wrap word mode are indented to match the initial whitespace
110 of the first display line of a logical line. If the widget
111 already holds text when this value is set, a function call may
112 be necessary. See ntextIndent for detailed instructions on the
113 use of Ntext 's indentation.
114
115 · 1 - (default value) selects classic Text behaviour, i.e. no
116 indentation
117
118 ::ntext::overwrite
119
120 · 0 - (initial value) text typed at the keyboard is inserted into
121 the widget
122
123 · 1 - text typed at the keyboard overwrites text already in the
124 widget
125
126 · The value is toggled by the Insert key.
127
129 To create a text widget .t and use the Ntext bindings:
130
131 package require ntext
132 text .t
133 bindtags .t {.t Ntext . all}
134
135 See bindtags for more information.
136
138 bindtags, ntextBindings, ntextIndent, ntextWordBreak, re_syntax, reg‐
139 exp, text
140
142 bindtags, re_syntax, regexp, text
143
144
145
146ntext 0.81 ntext(n)