{jtextcmds.tcl

Introduction
The jtextcmds.tcl library is distributed as part of the jstools package.  It provides user­level command procedures (in the sense of jcommand.tcl) for working with text widgets that are likely to be useful across applications.  It depends on the jtext.tcl library, and supports (but does not require) the jtexttags.tcl library.  Currently, it provides Cut, Copy, and Paste commands.  In the future I hope for it to provide Undo and Redo commands and text formatting commands as well.

This document describes jtextcmds.tcl version 4.1/4.4.

Usage
Accessing the Library
In order to use the jtextcmds.tcl library, it (and any other libraries it depends on) must be in your Tcl auto_path, described in tclvars(n).  Information about how to arrange that, and other conventions common to the jstools libraries, is in the Usage section of The jstools Libraries.

Credits and Copyright
Author
Jay Sekora 
js@aq.org
http://www.aq.org/~js/

Copyright
The library is copyright © 1992-1995 by Jay Sekora, but may be freely redistributed under the conditions at the top of the file.

Overview
Procedures
j:cmd:text_cut - delete selected text and save it in a cut buffer
j:cmd:text_copy - save selected text in a cut buffer without deleting it
j:cmd:text_paste - paste previously cut or copied text into text widget

See Also
	jtext.tcl
	jtexttags.tcl

j:cmd:text_cut
Usage
	j:cmd:text_cut w args
Arguments
	w is the text widget to cut text from
	Any additional args are ignored

Description
This procedure deletes any selected text from the text widget w and stores it in a global variable so it can later be pasted.  If w is a rich­text widget (i.e., it's using the jtexttags.tcl library for tag maintenance), then the tags associated with the selected text are also saved, so they can be restored when the text is later pasted.

The cut text (and tags, if applicable) will be saved to disk if possible (specifically, if the files ~/.tk/cut_text and ~/.tk/cut_richtext can be written to) so that cut text can be pasted into an application running as a separate process.  (This also means that cut text is preserved across invocations of jedit; i.e., you can cut some text, quit jedit, start it again, and paste the text cut in the previous session.)

j:cmd:text_copy
Usage
	j:cmd:text_copy w args
Arguments
	w is the text widget to cut text from
	Any additional args are ignored

Description
This procedure copies any selected text in text widget w into a global variable so it can later be pasted.  If w is a rich­text widget (i.e., it's using the jtexttags.tcl library for tag maintenance), then the tags associated with the selected text are also saved, so they can be restored when the text is later pasted.

The copied text (and tags, if applicable) will be saved to disk if possible (specifically, if the files ~/.tk/cut_text and ~/.tk/cut_richtext can be written to) so that copied text can be pasted into an application running as a separate process.

j:cmd:text_paste
Usage
	j:cmd:text_paste w args
Arguments
	w is the text widget to paste text into
	Any additional args are ignored

Description
This procedure inserts previously cut or copied text into text widget w.  If J_PREFS(typeover) is true, than the existing selection in w, if any, will first be deleted if the insert point is in or adjacent to the selection.  If w is a rich­text widget (i.e., it's using the jtexttags.tcl library for tag maintenance), then the tags associated with the selected text will also be restored.

The pasted text (and tags, if applicable) will be read to disk if possible (specifically, if the files ~/.tk/cut_text and ~/.tk/cut_richtext exist and are readable) so that text cut or copied in a separate application can be pasted.  Otherwise, application­specific global variables are used.

Bugs and Misfeatures
* Cutting or copying rich text can be hideously slow, since the text is examined for tags character­by­character.  Now that Tk4.1 provides the text dump command, this could be speeded up considerably.} {{{jdoc:anchor:anchorname {3.0 4.0 8.0 9.0 12.0 13.0 21.0 22.0 31.0 32.0 43.0 44.0 55.0 56.0}} {sel {6.46 6.53}} {jdoc:xref:link {4.56 4.63 4.133 4.145 4.246 4.255 4.305 4.318 10.214 10.235 10.243 10.260 10.264 10.285 23.0 23.14 24.0 24.15 25.0 25.16 28.1 28.10 29.1 29.14 39.176 39.189 51.157 51.170 63.274 63.287}} {jdoc:xref:manpage {10.130 10.137}} {richtext:font:roman {2.0 3.0 4.0 4.4 4.17 4.56 4.63 4.133 4.145 4.246 4.255 4.305 4.318 6.24 6.37 8.0 10.0 10.20 10.33 10.106 10.115 10.130 10.137 10.218 10.225 10.247 10.252 10.264 10.285 12.0 14.0 15.0 15.9 16.0 16.22 18.0 19.0 21.0 23.14 24.0 24.15 25.0 25.16 27.0 28.0 28.1 28.10 29.1 29.14 31.0 35.2 36.16 36.20 37.0 39.0 39.62 39.63 39.130 39.131 39.176 39.189 41.101 41.115 41.120 41.138 41.307 41.312 41.348 41.353 43.0 45.0 45.1 45.23 46.0 47.2 48.16 48.20 50.0 51.0 51.55 51.56 51.111 51.112 51.157 51.170 53.104 53.118 53.123 53.141 55.0 57.0 57.1 57.24 58.0 59.2 60.16 60.20 62.0 63.0 63.70 63.71 63.77 63.94 63.135 63.136 63.228 63.229 63.274 63.287 65.103 65.117 65.122 65.140 67.0 68.0 68.143 68.152 68.200}} {richtext:font:italic {33.16 33.17 33.18 33.22 35.0 35.2 36.16 36.20 37.0 38.0 39.62 39.63 39.130 39.131 45.17 45.18 45.19 45.23 47.0 47.2 48.16 48.20 51.55 51.56 51.111 51.112 57.18 57.19 57.20 57.24 59.0 59.2 60.16 60.20 63.70 63.71 63.135 63.136 63.228 63.229 68.143 68.147}} {richtext:font:bold {4.4 4.17 4.56 4.63 4.133 4.145 4.246 4.255 4.305 4.318 6.24 6.37 10.20 10.33 10.218 10.225 28.1 28.10 29.1 29.14 38.11 39.0 39.176 39.189 41.101 41.115 41.120 41.138 41.307 41.312 41.348 41.353 51.157 51.170 53.104 53.118 53.123 53.141 63.274 63.287 65.103 65.117 65.122 65.140}} {richtext:font:bolditalic {10.247 10.252 10.264 10.285}} {richtext:font:typewriter {10.106 10.115 10.130 10.137 15.0 15.9 16.0 16.22 23.0 23.14 24.0 24.15 25.0 25.16 33.1 33.16 33.17 33.18 45.1 45.17 45.18 45.19 57.1 57.18 57.19 57.20 63.77 63.94 68.147 68.152}} {richtext:font:heading0 {1.0 2.0}} {richtext:font:heading1 {3.0 4.0 8.0 9.0 12.0 13.0 21.0 22.0 31.0 32.0 43.0 44.0 55.0 56.0 67.0 68.0}} {richtext:font:heading2 {9.0 10.0 13.0 14.0 18.0 19.0 22.0 23.0 27.0 28.0 32.0 33.1 33.22 35.0 38.0 38.11 44.0 45.0 46.0 47.0 50.0 51.0 56.0 57.0 58.0 59.0 62.0 63.0}} {{} {12.0 17.0 18.0 19.0}} {jdoc:link:jstools.jdoc {4.56 4.63}} {jdoc:manpage:tclvars {10.130 10.137}} {jdoc:link:jslibraries.jdoc#Usage {10.243 10.260}} {jdoc:link:jslibraries.jdoc {10.264 10.285}} {jdoc:anchorname:Credits_and_Copyright {12.0 13.0}} {jdoc:anchorname:Introduction {3.0 4.0}} {jdoc:anchorname:Overview {21.0 22.0}} {jdoc:anchorname:Usage {8.0 9.0}} {jdoc:link:jslibraries.tcl {10.214 10.235}} {jdoc:link:jtexttags.tcl.jdoc {4.305 4.318 29.1 29.14 39.176 39.189 51.157 51.170 63.274 63.287}} {jdoc:link:jcommand.tcl.jdoc {4.133 4.145}} {jdoc:link:jtext.tcl.jdoc {4.246 4.255 28.1 28.10}} {jdoc:link:#j:cmd:text_cut {23.0 23.14}} {jdoc:anchorname:j:cmd:text_cut {31.0 32.0}} {jdoc:anchorname:j:cmd:text_copy {43.0 44.0}} {jdoc:anchorname:j:cmd:text_paste {55.0 56.0}} {jdoc:link:#j:cmd:text_copy {24.0 24.15}} {jdoc:link:#j:cmd:text_paste {25.0 25.16}}} {{abbrevstart 41.419} {matchend 66.0} {del_from 68.200} {richptr 65.291} {abbrevend 41.419} {insert 6.53} {emacs_mark 68.200} {anchor 41.419} {matchstart 66.0} {del_to 68.200} {current 10.46}}} {}