You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Expand all lines: examples/ntext/ntextDemoBindings.tcl
+48-28Lines changed: 48 additions & 28 deletions
Original file line number
Diff line number
Diff line change
@@ -1,13 +1,19 @@
1
-
#!/usr/bin/env wish
2
-
## -*- tcl -*-
3
-
# Copyright (c) 2005-2007 Keith Nash.
1
+
#!/bin/sh
2
+
# the next line restarts using tclsh \
3
+
exec tclsh "$0" "$@"
4
+
5
+
package require Tk
6
+
7
+
# Copyright (c) 2005-2017 Keith Nash.
4
8
#
5
9
# See the file "license.terms" for information on usage and redistribution
6
10
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
7
11
8
12
### This demo explores the ntext options
13
+
9
14
### For a short example, see ntextExample.tcl
10
15
### To explore ntext indentation, try ntextDemoIndent.tcl
16
+
### To explore vertical scrolling on the Mac, try ntextDemoMacScrolling.tcl
11
17
12
18
# This string defines the text that will be displayed in each widget:
13
19
set message {QOTW: "C/C++, which is used by 16% of users, is the most popular programming language, but Tcl, used by 0%, seems to be the language of choice for the highest scoring users."
@@ -26,15 +32,15 @@ Try word-by-word navigation (Control key with left cursor or right cursor key);
26
32
The classicMouseSelect and classicAnchor options are discussed in the man page for ntextBindings.}
27
33
# End of string for widget text.
28
34
29
-
package require ntext
35
+
package require ntext 1.0
30
36
31
37
# Whether Shift-Button-1 ignores changes made by the kbd to the insert mark:
32
38
set ::ntext::classicMouseSelect 0
33
39
34
40
# Whether Shift-Button-1 has a variable or fixed anchor:
35
41
set ::ntext::classicAnchor 0
36
42
37
-
# Whether the traditional "extra" bindings are activated:
43
+
# Whether the traditional "extra" bindings are activated (default is 0):
38
44
set ::ntext::classicExtras 1
39
45
40
46
# Whether to use new or classic word boundary detection:
@@ -43,43 +49,57 @@ set ::ntext::classicWordBreak 0
43
49
# Set to 0 to align wrapped display lines with the first display line of the logical line:
44
50
set ::ntext::classicWrap 1
45
51
46
-
pack [frame .rhf] -side right -anchor nw
47
-
pack [text .rhf.new ]
52
+
# Set to 0 to follow Mac Aqua conventions on placement of the insert mark
53
+
# when a selection is cancelled by keyboard navigation:
54
+
# Has effect on all platforms. Default value is 0 on Aqua, 1 on other platforms.
# See the file "license.terms" for information on usage and redistribution
6
10
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
7
11
8
12
### This demo explores ntext indentation
13
+
9
14
### For a short example, see ntextExample.tcl
10
15
### To explore the ntext options, try ntextDemoBindings.tcl
16
+
### To explore vertical scrolling on the Mac, try ntextDemoMacScrolling.tcl
11
17
12
-
### Points to note when using ntext's indent facilities are commented and numbered (1) to (6).
13
-
14
-
### If the text in your widget is manipulated only by the keyboard and mouse, then (1), (2) and (3) are all you need to do. If the text or its layout are manipulated by the script, then you also need to call the function ::ntext::wrapIndent - see comments (4) to (6), and the man page for ntextIndent.
18
+
### - Points to note when using ntext's indent facilities are commented and
19
+
### numbered (1) to (6).
20
+
### - If the text in your widget is manipulated only by the keyboard and mouse,
21
+
### then (1), (2) and (3) are all you need to do.
22
+
### - If the text or its layout are manipulated by the script, then you also
23
+
### need to call the function ::ntext::wrapIndent - see comments (4) to (6),
24
+
### and the man page for ntextIndent.
15
25
16
26
# This string defines the text that will be displayed in each widget:
17
27
set message { This demo shows ntext's indentation facilities. These are switched off by default, but in this demo they have been switched on.
18
28
19
29
To try the demo - place the cursor at the start of a paragraph and change the amount of initial space. The paragraph is a logical line of text; its first display line may have leading whitespace, and ntext indents any subsequent (wrapped) display lines to match the first.
20
30
This paragraph is indented by a tab. Again, the display lines are all indented to match the first.
21
-
Try any text-widget operation, and test whether ntext's handling of display line indentation is satisfactory. Please report any bugs - for instructions, see the ntext Wiki page, http://wiki.tcl.tk/14918
31
+
Try any text-widget operation, and test whether ntext's handling of display line indentation is satisfactory. Ntext is part of Tklib - please report any bugs to:
32
+
33
+
http://core.tcl.tk/tklib/reportlist
22
34
}
23
35
# End of string for widget text.
24
36
25
-
package require ntext
37
+
package require ntext 1.0
26
38
27
39
### (1) Indentation is disabled by default. Set this variable to 0 to enable it:
28
40
set ::ntext::classicWrap 0
29
41
30
42
# Activate the traditional "extra" bindings so these can be tested too:
31
43
set ::ntext::classicExtras 1
32
44
33
-
pack [frame .rhf] -side right -anchor nw
34
-
pack [text .rhf.new ]
45
+
set col #e0dfde
46
+
. configure -bg $col
47
+
48
+
pack [frame .rhf -bg $col] -side right -anchor nw
49
+
pack [text .rhf.new ] -padx 2
35
50
36
51
### (2) Set the widget's binding tags to use 'Ntext' instead of the default 'Text':
.rhf.new insert end " I use the Ntext bindings.\n\n$message"
43
58
.rhf.new edit separator
44
59
45
-
### (4) The script (not the keyboard or mouse) has inserted text. Because the widget has not yet been drawn, ::ntext::wrapIndent will be called by the <Configure> binding, so it is not really necessary to call it here. It is necessary in most other cases when the 'insert' command is called by the script.
60
+
### (4) The script (not the keyboard or mouse) has inserted text. Because the
61
+
### widget has not yet been drawn, ::ntext::wrapIndent will be called by the
62
+
### <Configure> binding, so it is not really necessary to call it here. It
63
+
### is necessary in most other cases when the 'insert' command is called by
### (6) Changing the tabs may change the indentation of the first display line of a logical line; if so, the indentation of the other display lines must be recalculated:
91
+
### (6) Changing the tabs may change the indentation of the first
92
+
### display line of a logical line; if so, the indentation of the
0 commit comments