Saturday, October 2, 2010

Tk Text widget FAQ

Tk Text widget FAQ

"A work in progress" 
 
        
This FAQ concentrates on those issues involved in uses of the "text" widget.  References to other widgets are minimized and no attept to teach Tcl was attempted. 
 
The documentation of the text widget that comes with the Tk is really very good, so read it along with the examples given.

 
  1. Tk Text widget FAQ
    1. 1) Top Level Issues
    2. 2) Font Issues
      1. 2.1) How to change a font to italic without having to specify it in full.
      2. 2.2) How do I specify a default menu (for example) font?
      3. 2.3) How to change all the widgets font at same time?
      4. 2.4) How to measure size of text with a certain font?
      5. 2.5) How to set all font sizes?
      6. 2.6) How list all available fonts?
      7. 2.7) How to use named fonts?
      8. 2.8) Need a font selection widget?
      9. 2.9) How can I tell if the font is a fixed-width font?
      10. 2.10) How to get list of font families?
    3. 3) Color Issues
      1. 3.1) How bright is a color?
      2. 3.2) How to call native color picker on platform?
      3. 3.3) How to i choose a good color combination for text?
    4. 4) Wrapping
      1. 4.1) How to increase the height of a text widget to get a full view of its word wrapped contents?
    5. 5) Indexes
      1. 5.1) What is the index of the start of the text?
      2. 5.2) What is the index of the end of the text?
      3. 5.3) What is the index of the end of the first line?
      4. 5.4) If the middle a word is at 2.2 where is it's beginning and end?
    6. 6) Getting information
      1. 6.1) how does one calculate the number of displayed lines in a text widget, as distinguished from the number of logical (\n-separated) line
    7. 7) Tags
      1. 7.1) How to change all text with the tag "aTag" to underline?
      2. 7.2) How make a mouse click on all text with the tag "aTag" produce a bell sound?
      3. 7.2) How to print out a message when the mouse flys over all text marked with the tag "aTag"?
      4. 7.3) How to list all tags being used in text?
      5. 7.4) How to test if a tag applies to a particular place?
    8. 7.1) Tag event bindings
    9. 7.2) Syntax highlighting
    10. 8) Marks
      1. 8.1) How to set mark at the second line seveth letter?
      2. 8.2) How to remove a mark?
    11. 9) Searching
    12. 10) Images
    13. 11) Buttons
      1. 11.1) How to add a button to a text?
    14. 12) Goto
    15. 13) Insert
    16. 14) Delete
      1. 14.1) How to delete all text?
    17. 15) Replace
    18. 16) Event Bindings
    19. 17) Use as console
      1. 17.1) How to make a text widget a console?
    20. 18) Unicode
      1. 18.1) How to display file in all possible encodings?
      2. 18.2) How check that an UTF-8 octet sequence is a complete character?
    21. 19) Persistance
    22. 20) autocomplete
    23. 21) balloon help
    24. 22) brace checking
    25. 23) text diff
    26. 24) VFS
    27. 25) linenumbers
    28. 26) Undo/Redo
    29. 27) Block selection
    30. 28) Text sorting
    31. 29) tailing
    32. 30) binary text
    33. 31) Drag and Drop
    34. 32) TextZoom
    35. 33) Printing
      1. 33.1) Can you use OpenOffice to print?
      2. 33.2) Printing Windows
      3. 33.3) Printing Unix
      4. 33.4 Printing Mac
    36. 34) Message Cataglog
    37. 35) Tile/Theme/Ttk
    38. 36) Folding text
    39. 37) Help
      1. 37.1) HTML as help files.
    40. 38) Invoking Browsers
    41. 39) What missing?
      1. 39.1) Typesetting
      2. 39.2) Asyncronous loading
    42. 40) Dealing with edit cursor
    43. 41) Dealing with mouse cursor
    44. 42) Defining and using tab stops
    45. 43) Only displaying part of a buffer
    46. 44) Indenting start of paragraph
    47. 45) Cut/Copy/Paste
    48. 46) MRU
    49. 47) Configuration files
    50. 48) Selection ?? Clipboard collision
      1. 48.1) How to clear the current selection (i.e unselect)
      2. 48.2) How to get the text of the current selected item?
      3. 48.3) How to test that the selection is owned by your?
    51. 49) Insert point
    52. 50) Mouse
      1. 50.1) How to handle a virtual mouse?
    53. 51) Read-only
    54. 52) Auto Indent
    55. 53) Horizontal scrollbar
    56. 54) Vertical scrollbar
    57. 55) Auto disappearing scrollbar
    58. 56) Inputting International characters
      1. 56.1) How to do right-left languages?
      2. 56.2) How to handle tcl files in different encodings?
      3. 56.3) How deal with different encodings?
    59. 57) Several windows into same text (peering)
    60. 58) File type recognition
    61. 59) Capitalization
    62. 60) Spell checking
      1. 60.1) Using OpenOffice as a spell-checker.
    63. 61) Tablification/De-tablification
    64. 62) Encryption
    65. 63) Generate nroff/html/latex output
    66. 64) Highlight word under mouse
    67. 65) ctags
    68. 66) Keystroke macros
    69. 67) Busy indication
    70. 68) Bookmarks
    71. 69) Piping input in/out of external utils
    72. 70) Change Tk definition of a word
    73. 71) Disabling auto-repeat on windows
    74. 72) Looping over text widget
    75. 73) Keyboard
    76. 74) Making it portable
    77. 75) Making it into a single file
    78. 76) Books
    79. 77) Web sites
    80. 78) Are there any Tcl Editors I can look at?
      1. Key Features
      2. Operates with other applications and systems
    81. 79) Error management
    82. 80) Handling application exit
    83. 81) Usefull Libraries
    84. 82) Key bindings
      1. 82.1) How change key u to U and back?
      2. 82.2) How report keybindings for each keystroke?
    85. 83) Icons
      1. 83.1) Where can I find some icons to use?
    86. 84) Highlighting
    87. 85) Generate PDF files
    88. 86) How can I atomatic translation of files via Bablefish?
    89. 86) Is character x in font y?
    90. 87) Multi File searching
    91. 88) Adding text tags via regular expressions.
    92. 89) Auto-Replace
    93. 90) Hidden text
    94. 91) Standard dialogs
      1. 91.1) choose directories
      2. 92.2) choose files
      3. 92.3) choose colors
      4. 92.4) choose fonts
      5. 92.5) Find
      6. 92.6) Find and Replace
      7. 92.7) Print
      8. 92.8) Print Preview
      9. 92.9) Page setup
      10. 92.10) Any simple modal dialog
    95. 92) Generic articles on tk text widget
    96. 93) Clipboard
      1. 93.1) Putting text onto clipboard?
      2. 93.2) Clearing the cliipboard?
    97. 94) Internationalization
    98. 95) How generate tables?
    99. 96) Scrolling multiple widgets at same time.
    100. 97) Scrolling
    101. 98) Spacing out lines
      1. 98.1) How to change spacing above each line?
      2. 98.2) How to change spacing below each line?
      3. 98.3) How to change space between all logical lines? (not wrapped lines)
    102. 99) Frame widgets
      1. 99.1) How to embedded a entry widget into a text widget?
    103. Left overs
    104. Out of scope

 

1) Top Level Issues

 

2) Font Issues

     Source: http://wiki.tcl.tk/1050    "font"
     Source: http://wiki.tcl.tk/451      "Practical Guide to Choosing Fonts"
     Source: http://wiki.tcl.tk/1129    "Changing all fonts in an application"
     Source: http://wiki.tcl.tk/8519    "font measure"
     Source: http://wiki.tcl.tk/3896    "A little font chooser"
     Source: http://wiki.tcl.tk/13139  "named fonts"

     2.1) How to change a font to italic without having to specify it in full.

        $w configure -font "[font actual [$w cget -font]] -slant italic"

     2.2) How do I specify a default menu (for example) font?

        option add *Menu.font $my_preferred_font

     2.3) How to change all the widgets font at same time?

     foreach class {
         Button Checkbutton Entry Label Listbox
         Menu Menubutton Message Radiobutton Scale
     } {
         font create $class -family Helvetica -size 12
         option add *$class.font $class widgetDefault
     }
     font create Text -family courier -size 12
     option add *Text.font Text widgetDefault

    2.4) How to measure size of text with a certain font?

        font measure $font

        The 'font measure' command does not expand newlines or tabs (it appears to treat each as a double-space), so it doesn't give a true indication of how wide a label (for example)             would be using the specified font and text.

    proc font:width {font text {w .}}

     {
 
     puts " measure = \[[font measure $font -displayof $w $text]\]"
 
     set max 0
     foreach line [split $text \n] {
          set width [font measure $font -displayof $w $line]
          if { $width > $max } { set max $width }
     }

     puts " max width = \[$max\]"
     return $max
     }

    The font man page says: "The return value is the total width in pixels of text, not including the extra pixels used by highly exagerrated characters such as cursive 'f'." So the only real     way to find the required width (and height) of a string is to put it into a label and get the size of the label:

    proc font:reqwidth {font text {w ""}} {

    for {set i 1} {[winfo exists $w.label-$i]} {incr i} {}
    set l $w.label-$i
    label $l -bd 0 -padx 0 -pady 0 -highlightthickness 0 \
        -font $font \
        -text $text
    set width [winfo reqwidth $l]
    set height [winfo reqheight $l]
    puts " reqwidth = \[$width\]"
    puts " reqheight = \[$height\]"
    destroy $l
    return $width
    }

     # demo code
    set font [font create -family courier -size 10]
    set text "new\t\nline"
    font:width $font $text
    font:reqwidth $font $text


    2.5) How to set all font sizes?


    2.6) How list all available fonts?

      font names

    2.7) How to use named fonts?

        Named fonts are a great way to create and modify fonts on an application-wide basis. Just create a named font with \font create, then use that font name to create widgets or            text elements. Then later you can use font configure to modify the named font, and all the text elements will be automagically updated. Here is a little code example, showing                named fonts used both in a widget and on a canvas.

    2.8) Need a font selection widget?

        See: http://people.man.ac.uk/~zzcgudf/tcl/mwidx.html#fontdlg for  dkf_chooseFontwidget.
        See: Tk command tk_fontChoose

    2.9) How can I tell if the font is a fixed-width font?

    
        if {[font metrics $fontName -fixed]} { puts "fixedFont" }

 

    2.10) How to get list of font families?

 
        font families

 

3) Color Issues


    See: http://wiki.tcl.tk/534    "Bag of Tk algorithms"

    3.1) How bright is a color?


    proc brightness color {
        foreach {r g b} [winfo rgb . $color] break
        set max [lindex [winfo rgb . white] 0]
        expr {($r*0.3 + $g*0.59 + $b*0.11)/$max}
    } ;#RS, after [Kevin Kenny]

 

    3.2) How to call native color picker on platform?

    tk_chooseColor command

    See: http://wiki.tcl.tk/1056    "tk_chooseColor"

    3.3) How to i choose a good color combination for text?

    See: http://wiki.tcl.tk/22218     "rgb combinations"
    See: http://www.serice.net/rgb/

4) Wrapping


    See: http://wiki.tcl.tk/20245    "full view wrapped text"

    4.1) How to increase the height of a text widget to get a full view of its word wrapped contents?


    package require Tk
    bind . <F1> {console show}
    wm geometry . 260x600
    proc geom {x} {
        wm geometry . [format %dx600 $x]
    }
    button .br -text "reset text" -command reset
    pack .br -pady 5
    if {[expr {$tcl_version >= 8.5}]} { ;# as per MG's tip
        button .bv -text "full view" -command {.t configure -height [.t count -displaylines 1.0 end]}
    } else {
        button .bv -text "full view" -command adapt
    }
    pack .bv -side top
    set svar 255
    scale .sc -orient vertical -label "window width" -command geom -from 80 -to 800 -variable svar
    pack .sc -side left
    proc reset {} {
        catch {destroy .t}
        text .t -width 10 -wrap word -height 1
        pack .t -side left -fill x -expand 1 -pady 5 -padx 5
        for {set x 1} {$x<5} {incr x} {
            if {$x>1} {.t insert end \n}
            set first *
            for {set y 0} {$y < 21} {incr y} {
                .t insert end [format "%s%d.%02d" $first $x $y]
                set first " "
            }
            .t insert end \n
        }
    }

    proc adapt {{maxloop 100}} {
        .t see 1.0
        update idletasks
        set pos [.t index end]
        foreach {line col} [split $pos .] break
        incr line -1
        while {![llength [.t bbox $line.end]]} {
            incr maxloop -1
            if {!$maxloop} {
                  title . $h:aborted
                break
            }
            set h [.t cget -height]
            incr h
            .t configure -height $h
            wm title . [list $h height of .t]
            update idletasks
        }
    }

reset



5) Indexes

     5.1) What is the index of the start of the text?

 
    1.0
 

    5.2) What is the index of the end of the text?

 
    end
 

    5.3) What is the index of the end of the first line?

 
    1.end
 

    5.4) If the middle a word is at 2.2 where is it's beginning and end?

 
    {2.2 wordstart}
    {2.2 wordend}
 
    

6) Getting information

  
    See: http://wiki.tcl.tk/1754    "Text Widget Newline Wrapping"
 

    6.1) how does one calculate the number of displayed lines in a text widget, as distinguished from the number of logical (\n-separated) line


    GPS answered a different question in c.l.t: how does one calculate the number of displayed lines in a text widget, as distinguished from the number of logical (\n-separated) lines:

    set start [.t index @0,0]
    set end [.t index @0,[winfo height .t]]
    expr $end - $start + 1

    # ...
This returns the number of logical (\n-separated) lines currently displayed, which is not the same as the number of display lines on screen (which is very hard to calculate if          # font sizes differ). But, with tip 155:
    
    expr [.t count -displaylines @0,0 @0,[winfo height .t]] + 1


       # does the job.

7) Tags

     7.1) How to change all text with the tag "aTag" to underline?

 
    $w tag configure -underline 1
 

     7.2) How make a mouse click on all text with the tag "aTag" produce a bell sound?

 
    $w tag bind aTag <Button-1> { bell }
 

    7.2) How to print out a message when the mouse flys over all text marked with the tag "aTag"?

 
    $w tag bind aTag <Entry> { puts "over text with aTag" }
    $w tag bind aTag <Leave> { puts "no more over text with aTag" }
 

     7.3) How to list all tags being used in text?

 
    $w tag names
 

    7.4) How to test if a tag applies to a particular place?

    
    $w tag names $index
 
 

7.1) Tag event bindings

     See: http://wiki.tcl.tk/6101        "Behavior of break for text tag bindings"

7.2) Syntax highlighting

 
  
     See: http://wiki.tcl.tk/4134          "Ctext" 
     See: http://wiki.tcl.tk/13989        "a debugger with syntax highlighting using ctext"
     See: http://wiki.tcl.tk/22169        "Adding text widget tags using regular expressions"

8) Marks

     8.1) How to set mark at the second line seveth letter?

 
    $w mark set $tagName 2.7
 

    8.2) How to remove a mark?

 
    $w mark unset $tagName
 
 

9) Searching

     See: http://wiki.tcl.tk/17286        "Searching in a text widget"

10) Images

     10.1) How to add a image to a text?
 
    image create photo myImage -file myImage.gif
    $w image create {2.0 linestart} -image myImage -name embeddedImage
    # Don't pack embedded images

11) Buttons

     11.1) How to add a button to a text?

 
    button .$w.button1 -text "Embedded button"
    $w window create {1.0 lineend} -window $w.button1
    # Don't pack embedded widgets
 
 

12) Goto

 

13) Insert

     13.1) How to get current insert position?
 
     13.2) How to move current insert position?
 
        $w icursor $pos
 
        # Put at start of text
        $w icursor 0
 
        # Put at end of text
        $w icursor end
 
        # Put start of selection
        $w icursor sel.first
 
        # Put at end of selection
        $w icursor sel.last
 
        

14) Delete

     14.1) How to delete all text?

 
    $w delete 0 end
 
    14.2)

15) Replace

 

16) Event Bindings

 

17) Use as console


     See: http://wiki.tcl.tk/1026    "A minimal console"
     See: http://wiki.tcl.tk/786     "console for Unix"
     See: http://code.activestate.com/recipes/65430-a-minimal-console/?in=lang-tcl    "Recipe 65430: A minimal console (Tcl) "

    17.1) How to make a text widget a console?


    package require Tk

    destroy .console
    toplevel .console
    pack [text .console.cmd -wrap word] -expand yes -fill both
    bind .console.cmd <Return> evalConsoleCmd
    bind .console.cmd <Return> +break
    .console.cmd tag configure success -foreground \#008800
    .console.cmd tag configure failure -foreground red

    proc evalConsoleCmd {} {
        set c .console.cmd
        if {[$c compare {insert + 1 lines} < end]} then {
            set l [$c get {insert linestart} {insert lineend}]
            $c insert {end - 1 chars} \n[string trimright $l]
            $c mark set insert end
            $c see insert
        } else {
            if {[catch {
                set result [uplevel 1 [$c get end-1lines end-1chars]]
            } err]} then {
                $c insert end \n {} $err failure \n
            } else {
                 $c insert end \n {} $result success \n
             }
         }
 7    }



18) Unicode


    See: international section of this FAQ
    See: http://wiki.tcl.tk/1364    "Unicode"
    See: http://wiki.tcl.tk/515    "Unicode and UTF-8"
    See: http://wiki.tcl.tk/907    "A little Unicode editor"
    See: http://wiki.tcl.tk/699    "A simple Arabic renderer"
    See: http://wiki.tcl.tk/25658    "Reformatting Lines of Chinese Text"
    See: http://wiki.tcl.tk/515     "Unicode and UTF-8"
    See: http://wiki.tcl.tk/517      "Unicode file reader"

    18.1) How to display file in all possible encodings?

     proc display-all-encodings {} {
        set file [tk_getOpenFile]
        text .t -bg white -font "Times"
        pack .t -fill both -expand t
        foreach encoding [lsort -ascii [encoding names]] {
            set str [open $file r]
            fconfigure $str -encoding $encoding
            .t insert end "\nEncoding: $encoding\n[read $str]"
            close $str
        }
     }   


    18.2) How check that an UTF-8 octet sequence is a complete character?

        Lars H: A more compact way of checking that an UTF-8 octet sequence is a complete character is to use a regexp. This procedure checks whether a char is UTF-8:

     proc utf8 {char} {
         regexp {(?x) # Expanded regexp syntax, so I can put in comments :-)
             [\x00-\x7F] | # Single-byte chars (ASCII range)
             [\xC0-\xDF] [\x80-\xBF] | # Two-byte chars (\u0080-\u07FF)
             [\xE0-\xEF] [\x80-\xBF]{2} | # Three-byte chars (\u0800-\uFFFF)
             [\xF0-\xF4] [\x80-\xBF]{3} # Four-byte chars (U+10000-U+10FFFF, not suppoted by Tcl 8.5)
     } $char
     }
        (This regexp can be tightened a bit if one wishes to exclude ill-formed UTF-8; see Section 3.9 ("Unicode Encoding Forms") of the Unicode standard.) See UTF-8 bit by bit for an                 explanation of how UTF-8 is constructed.

19) Persistance

     See: http://www1.clearlight.com/~oakley/tcl/ttd/index.html        ""ttd"

20) autocomplete


    See: http://taipudex.com/code/readme.htm     dcp package
    See: http://wiki.tcl.tk/20491                         "autocomplete"
    See: http://wiki.tcl.tk/20215                         "Pure-tcl readline2" 

     8.6   
  • prefix match ?-exact? ?-message string? ?-error options? list string

  • prefix longest list string

  • prefix all list string

        See: http://www.tcl.tk/cgi-bin/tct/tip/195.html    "A Unique Prefix Handling Command"

21) balloon help

     See: tklib package balloon
     See: http://wiki.tcl.tk/10551        "tooltip"
     See: http://wiki.tcl.tk/1954          "tooltips"
     See: http://wiki.tcl.tk/3060          "balloon help"

22) brace checking

     See: http://wiki.tcl.tk/20325   "Balancing Open and Close Quotes in a TK text widget."

23) text diff

    See: http://wiki.tcl.tk/3108     "diff in Tcl"
    See: http://wiki.tcl.tk/26364    "DiffUtilTcl"
    See: http://github.com/pspjuth/DiffUtilTcl
 

24) VFS

     See: http://wiki.tcl.tk/2138       "VFS"
     See: http://wiki.tcl.tk/2466       "tclvfs"
     See: http://wiki.tcl.tk/25769     "Vfs for Sqlite"
     See: http://wiki.tcl.tk/12838     "vfs::http"
     See: http://wiki.tcl.tk/12063     "mk4vfs"
     See: http://wiki.tcl.tk/11846     "vfs::zip"
     See: http://wiki.tcl.tk/12328     "tclvfs gotchas"
     See: http://wiki.tcl.tk/12840     "vfs::ns"
     See: http://wiki.tcl.tk/12837     "vfs::ftp"
     See: http://wiki.tcl.tk/12832     "tclVFS examples"
     See: http://wiki.tcl.tk/8412       "vfs filesystem configuration"
     See: http://wiki.tcl.tk/15635     "ramvfs"
     See: http://wiki.tcl.tk/14131     "vfs::inmem"
     See: http://wiki.tcl.tk/12836     "tclVFS Hints and Tricks"
     See: http://www.tcl.tk/about/tclvfs.html    "Tcl Virtual File System"

25) linenumbers

     See: http://wiki.tcl.tk/20916    "line numbers in text widget"

26) Undo/Redo

    Some of these articles predate the built-in support for undo/redo and show the old manual way of doing it.

    See: http://wiki.tcl.tk/23381    "Undo, a few pointers at how to code the Undo function for a text editor"
    See: http://wiki.tcl.tk/12362    "Text widget undo/redo limitations and enhancements"
    See:http://wiki.tcl.tk/16681     "Undo and Redo undoable widgets"
    See: http://wiki.tcl.tk/1333     "Text widget undo/redo"
    See: http://wiki.tcl.tk/23381    "Undo, a few pointers at how to code the Undo function for a text editor"

     text .t -undo 0
     for {set i 0} {$i < 20} {incr i} {
         .t insert end "hello there $i"
     }
     text .t -undo 1
     .t insert end "add one more line"
     # Only show the middle 10 lines
     .t configure -startline 5 -endline 15
     # This should undo the action that isn't visible?
     .t undo edit


    proc do.undo {} {
        if [$::current_ht edit modified ] {
            if [catch {$::current_ht edit undo}] {return
}
            }
      }

27) Block selection

     See: http://wiki.tcl.tk/15471        "Simple Block Selection for Text Widget"

28) Text sorting

     See: http://wiki.tcl.tk/15410        "Simple Text Widget Sort"

29) tailing

     See: http://wiki.tcl.tk/1154         "Tail"

30) binary text

 

31) Drag and Drop

    See: https://sourceforge.net/projects/tkdnd/
    See: http://wiki.tcl.tk/14883        "Text Drag -Drag and Drop for Text Widget Selections"

32) TextZoom

 

33) Printing

    See: http://wiki.tcl.tk/2496      "printing"

    33.1) Can you use OpenOffice to print?

    See: http://wiki.tcl.tk/14843     "TclOO -Rendering text pages in OpenOffice Writer from a Tcl application."
 

    33.2) Printing Windows

    See: http://wiki.tcl.tk/9846    "Printing text files under Windows"
    See: http://wiki.tcl.tk/11319  "Printing under Windows"

    33.3) Printing Unix

 

    33.4 Printing Mac

 

34) Message Cataglog

     See: http://wiki.tcl.tk/1488         "msgcat"
     See: http://wiki.tcl.tk/20290       "Tk and msgcat"
     See: http://wiki.tcl.tk/14377       "msgcat-Ready Script Utility"

35) Tile/Theme/Ttk

Title does not match the "only things to do with text widget" idea of this FAQ but somehow I thought it was important enough to add anyway.

    See: http://www.tkdocs.com/tutorial/styles.html        "TkDocs - Tk =Tutorial - Styles and Themes"
    See: http://wiki.tcl.tk/23461        "Problems using Tile/Ttk"
    See: http://www.tcl.tk/about/ttk.html        "Themed, Native GUI"
    See: http://wiki.tcl.tk/14796        "Ttk"    
    See: http://wiki.tcl.tk/20064        "ttk::style"
    See: http://wiki.tcl.tk/13636        "Applications using Tile"    
    See: http://wiki.tcl.tk/11075        "Tile"    

36) Folding text

    See: http://wiki.tcl.tk/12091        "Text widget elision"

37) Help

    37.1) HTML as help files.

    
    See: FAQ section on "Invoking browsers"

38) Invoking Browsers

     See: http://wiki.tcl.tk/557        "Invoking browsers"

39) What missing?

 

    39.1) Typesetting

 

    39.2) Asyncronous loading

 

40) Dealing with edit cursor

 

41) Dealing with mouse cursor

 

42) Defining and using tab stops

 

43) Only displaying part of a buffer

 

44) Indenting start of paragraph

 

45) Cut/Copy/Paste

     See: http://wiki.tcl.tk/14035        "Tk's copy and paste support"

46) MRU

     See: http://wiki.tcl.tk/14324        "Most Recently Used (MRU) Menus"

47) Configuration files

    See: http://wiki.tcl.tk/23917        "Config file using slave interp"
    See: http://wiki.tcl.tk/13565        "Where to store application configuration files"

48) Selection ?? Clipboard collision

    48.1) How to clear the current selection (i.e unselect) 

     $w selection clear
 

    48.2) How to get the text of the current selected item?

 
    selection get
 

    48.3) How to test that the selection is owned by your?

 
    selection own
     

49) Insert point

     See: http://wiki.tcl.tk/1634        "How do I insert text programmatically at the current insertion point"

50) Mouse


    50.1) How to handle a virtual mouse?

    See: http://wiki.tcl.tk/17999     "VirtualMouse Cross Platform Mouse Handling"
 

51) Read-only

    See: http://wiki.tcl.tk/1152        "Read-only text widget"

52) Auto Indent

     See: http://wiki.tcl.tk/15463      "auto-indent"
     See: http://wiki.tcl.tk/15619      "Maintaining indentation in a text widget when go to a new line"

53) Horizontal scrollbar

 

54) Vertical scrollbar


    pack [scrollbar .y -command ".t yview"] -side right -fill y
    pack [text .t -wrap word -yscrollc ".y set"] -side right -fill both -expand 1

 

55) Auto disappearing scrollbar


    See: http://wiki.tcl.tk/950    "Scroll bars that appear only when needed"

    Or use the package autoscroll in the tklib.
    package require autoscroll
    text .t -yscrollcommand ".scrolly set"
    scrollbar .scrolly -orient v -command ".t yview"
    pack .scrolly -side right -fill y
    pack .t -side left -fill both -expand 1
    ::autoscroll::autoscroll .scrolly

 

56) Inputting International characters


    See: http://wiki.tcl.tk/9026    "i18n - Tcl for the world"

    56.1) How to do right-left languages?

    See: http://wiki.tcl.tk/1126 "Right-to-left entry widget"

    56.2) How to handle tcl files in different encodings?

    8.5 has "source -encoding encodingName fileName"
 

    56.3) How deal with different encodings?

    Source: tcl man pages

    encoding convertfrom ?encoding? data Convert data to Unicode from the specified encoding. The characters in data are treated as binary data where the lower 8-bits of each            character is taken as a single byte. The resulting sequence of bytes is treated as a string in the specified encoding. If encoding is not specified, the current system encoding is used.

    encoding convertto
?encoding? string Convert string from Unicode to the specified encoding. The result is a sequence of bytes that represents the converted string. Each byte is           stored in the lower 8-bits of a Unicode character. If encoding is not specified, the current system encoding is used.

    encoding dirs
?directoryList? Tcl can load encoding data files from the file system that describe additional encodings for it to work with. This command sets the search path for *.enc    encoding data files to the list of directories directoryList. If directoryList is omitted then the command returns the current list of directories that make up the search path. It is an error    for directoryList to not be a valid list. If, when a search for an encoding data file is happening, an element in directoryList does not refer to a readable, searchable directory, that             element is ignored.

    encoding names
Returns a list containing the names of all of the encodings that are currently available.
    
    encoding system
?encoding? Set the system encoding to encoding. If encoding is omitted then the command returns the current system encoding. The system encoding is used           whenever Tcl passes strings to system calls.

57) Several windows into same text (peering)

 

58) File type recognition

 

59) Capitalization

 

60) Spell checking

 

    60.1) Using OpenOffice as a spell-checker.

    See: http://wiki.tcl.tk/14791    "tcluno"
    See: http://wiki.tcl.tk/15447    "Drive OpenOffice Calc with tcluno"
    See: http://wiki.tcl.tk/15681    "OpenOffice"

    60.2) Use GNU aspell

    See: Alphatk editor for example
    

61) Tablification/De-tablification

 

62) Encryption

     See: http://wiki.tcl.tk/2198            "encryption"
     See: http://wiki.tcl.tk/11888          "rc4"

63) Generate nroff/html/latex output

 

64) Highlight word under mouse

 

65) ctags

     See: http://wiki.tcl.tk/6635         "Exuberant Ctags"
     See: http://wiki.tcl.tk/2974         "Tags for Vi/ViM editing"

66) Keystroke macros

     See: http://wiki.tcl.tk/15726        "Record and replay system for Tcl/Tk"
     See: http://wiki.tcl.tk/209           "TKReplay"

67) Busy indication


    See: http://www.tcl.tk/cgi-bin/tct/tip/321.html    "Add a [tk busy] Command"
 

68) Bookmarks

 

69) Piping input in/out of external utils


    See: http://wiki.tcl.tk/24735        "How can I run data through an external filter?"
 
    button .top.quit -text Quit -command exit ;
    set but [button .top.run -text "Run it" -command Run] ;
    pack .top.quit .top.run -side right ;

    label .top.l -text Command: -padx 0 ;
    entry .top.cmd -width 20 -relief sunken -textvariable command ;
    proc Run {} {
        global command input log but
        if [catch {open "|$command |& cat"} input] {
            $log insert end $input\n
        } else {
            fileevent $input readable Log
            $log insert end $command\n
            $but config -text Stop -command Stop
        }
    }

70) Change Tk definition of a word

 

71) Disabling auto-repeat on windows

 

72) Looping over text widget

     See: http://wiki.tcl.tk/3246        "Looping over the contents of a text widget"

73) Keyboard

     See: http://www.iit.demokritos.gr/~petasis    "A virtual keyboard widget implementation"

74) Making it portable

 

75) Making it into a single file


76) Books


    "Effective Tcl/Tk Programming"    Mark Harrison, Michael McLennan
    See: http://wiki.tcl.tk/159        "BOOK Effective Tcl - Writing Better Programs in Tcl and Tk"

    Chapter 3 Handling Events
        3.1 The event loop
            3.1.1 Keyboard focus
            3.1.2 Forcing updates
            3.1.3 Handling long-running bindings
            3.1.4 Execution scope
        3.2 Simple examples using bind
            3.2.1 Selecting an item from a listbox
            3.2.2 Automatic button help
            3.2.3 Class bindings
        3.3 Syntax of the bind command                      << Usefull for text editing
            3.3.1 The event specification
            3.3.2 Percent subsitutions
        3.4 More complex events                                << Usefull for text editing
            3.4.1 Click, drag, drop
            3.4.2 Customizing the widget behavior
        3.5 Binding tags                                            << Usefull for text editing
            3.5.1 Default binding tags
            3.5.2 Using break to interrupt event processing
            3.5.3 Inverting bindings tags for groups of bindings
            3.5.4 Binding to a top-level window
        3.6 Debugging bindings
            3.6.1 Displaying bindings
            3.6.2 Monitoring events
        3.7 Animation
            3.7.1 Animation items on a canvas
            3.7.2 Debugging after events
            3.7.3 Library precedures for animation

    Chapter 5 "Using the Text Widget"                     << Usefull for text editing
        5.1 Understanding the text widget
            5.1.1 Indexing model
            5.1.2 Scrolling
            5.1.3 Using tags
            5.1.4 Text bindings
            5.1.5 Using marks
            5.1.6 Wrap modes
            5.1.7 Tab stops
        5.2 Simple text editor
        5.3 Read-only text display
        5.4 Appointment editor
            5.4.1 Using tags to apply styles
            5.4.2 Embedded windows
            5.4.3 Changing text bindings
            5.4.4 Retrieving appointments
        5.5 Hierarchical browser
            5.5.1 Hierarchical  data
            5.5.2 Creating the heiarchical browser
            5.5.3 Using tags and marks

        
    "Practical Programming in Tcl and Tk", Fourth Edition      Brent Welch, Jeff Hobbs, Ken Jones
    See: http://wiki.tcl.tk/8449        "Book Practical Programming in Tcl and Tk, Fourth Edition"
 

 
    "Graphical Applications with Tcl & Tk"        Eric Foster-Johnson
    
        Chapter 3 Interacting with the User
            ...
            Fonts
            Calling Code From Widets
            Text Options
            ...
        Chapter 5 Text Editing with Tcl and Tk
            Entering Text
            Creating Entry Widgets
            Multiline text Widgets
                When to Use a text Widet
                Controlling the Text Widget Display
                Deleting Text
                Defining Positions in the Text
                Inserting Text
                Retrieving TExt
            Connecting the text Widget to a Scrollbar
                Setting the Keyboard Focus
            Marks, Tags, and Embedded Windows
                Marks
                Using Tags to Control Fonts
                Embeding Windows
                Making Hypertext Links in the Text
            Cut, Copy, and Paste with the text Widget
                The Clipboard
                The Clipboard and the Selection
                Getting the Selection Text
                Putting Text in the Clipboard
                Clearing Text in the Clipboard
                Retrieving Data from the Clipboard
                Copy
                Cut
                Paste
                Binding Events for Cut, Copy, and Paste
                text Widget Efficiencey
                Dumping the Contents of a text Widget
                Searching Within the text Widget
            Tcl String-Handling Commands
            A Tcl-Based Text Editor
       

77) Web sites


    See: http://www.bacomatic.org/~dw/comp/tclurl/index.htm   "TCL-URL archive"
    See: http://wiki.tcl.tk                            "Tcl Wiki"
    See: http://www.tkdocs.com/tutorial        "Tk tutorial"
    See: http://code.activestate.com/recipes/langs/tcl/   "ActiveState Tcl Recipes"
    See: http://www.tkdocs.com/tutorial/text.html        "TkDocs - Tk =Tutorial - Text"

78) Are there any Tcl Editors I can look at?


    See: http://wiki.tcl.tk/9602        "A minimal editor"

    See: http://wiki.tcl.tk/1184        "Tcl Editors"
    See: http://wiki.tcl.tk/9623        "A minimal editor explained"
    See: http://wiki.tcl.tk/20542      "A small editor in 8.5.0"
    See: http://wiki.tcl.tk/24507      "Editing with different fonts"
    See: http://wiki.tcl.tk/21292      "HexEdit - an hexadecimal editor"
    See: http://code.activestate.com/recipes/68395-vwtcl-tk-text-file-viewer/?in=lang-tcl    "TK Text File Viewer"

    e:
    See: http://wiki.tcl.tk/15280        "e: a tiny editor plugin for eTcl"
    License: Open

With the eTcl distribution for PocketPC
  • a really compact editor that can be called from the eTcl console with a file or proc name,
  • called without argument, e just brings up the edit window, so one can switch
  • displays the content in a window that leaves room for the virtual keyboard
  • can save the content to file again, or evaluate it (e.g. for modified procs)
  • Most of edit functionality is from text anyway, just need menu items to invoke them

    ficedit
    See: http://newmagicprogs.x10hosting.com/?id=ficedit
    License: ??

    Alpha
    See: http://wiki.tcl.tk/6339        "Alpha"
    License: ???

Key Features

  • Cross-platform - use the same editor on Windows, Unix and MacOS X.
  • Very extensible and configurable - has a real (open source) language as a macro language
  • Multi-modal
  • Mode-specific syntax colouring, configurable with built in support for C/C++, HTML, Java, Tcl, Perl and 40 other modes.
  • Exceptionally powerful modes for HTML/CSS, LaTeX/BibTeX, Perl, Matlab, C++, Java, Tcl and Metafont
  • Some 40 others modes for TIP, Python, S+, R, Scheme, Igor, Postscript, Fortran, Gnuplot, Javascript, Ada, Caml, ChangeLog, Clan, Lisp, Modula2, email, make, Maple, Metafont, ObjectiveC, C#, Pascal, SAS, Scilab, Applescript, Setext, SPSS, Stata, SQL, Verilog, VB, XML... with syntax colouring for all of these modes.
  • File sets - organise your files and deal with sets independently, including operations like printing, ftp-mirroring, version control, archiving, etc.
  • Active user community writing additional modes, menus and other plugins, (e.g. here)
  • Largely open source, and easily customizable.
  • Configurable keyboard mapping
  • Contains helpers so you can easily add yet more modes!
  • Completely scriptable
  • Templates
  • Available either as a set of scripts or as a single standalone executable (or 'starkit')
  • Support for unlimited variety of plugins
  • Tearoff menus for easy access.
  • Automatic backup of files
  • Multi-byte (IME) Support

Programmer's Features

  • Support for more than 40 common programming languages
  • Automatic identification of mode according to file type, extension or first few lines
  • Sophisticated editing functions
  • Auto-indentation of individual lines or blocks of text (even as you cut and paste), and ability to shift-indent left or right.
  • Allows code 'folding'
  • Code competion
  • Code templates
  • Configurable colour schemes (e.g. green on black if you desire!)
  • Support to highlight words beginning with a specified sub-string
  • Automatic re-wrapping of text in comments
  • Spell-checking just inside comments
  • CTags support
  • Project specific Ctag file with option to create automatically when opened
  • User-definable code completion and new keywords
  • Built in FTP and HTTP clients to browse any number of remote servers
  • Sophisticated advanced regular expression search and replace (in single or multiple files or entire disk hierarchies)
  • Intelligent bracket/brace-matching (skips quoted literals, strings, etc) as you type
  • Project file-set support for grouping of different projects
  • File-set specific preferences (tabsize, indentation, column wrap, etc)
  • Quick insertion of strange ascii characters
  • Comment/Uncomment lines, paragraph or large blocks
  • Complete macro support, including saving, loading, editing and running of macros controlling all editing functions.
  • Configurable support for external tools (compilers, code checkers, etc)
  • Automatic lists of functions and marks in active file
  • On the fly or manual reformatting of code sections
  • Show line numbers for easier debugging

Documentation/Help Features

  • Extensive documentation
  • Online manuals and help
  • Very helpful mailing lists for users and developers
  • Large number of examples for many modes, menus, features.
  • Code template/Completions tutorials

Search functionality

  • Marking of function/section names in a file for quick navigation
  • Sophisticated search/replace (full grep/regexp or plain text, word-match, multi-file, ignore capital letters, preserve case, etc)
  • Full advanced regexp support for search and replace to match complex patterns, repetitions, etc
  • Regexp searching includes greedy and non-greedy quantifiers.
  • Search in entire document or selection only
  • Option to ignore matches in comments
  • Constrain matches to single or multiple lines
  • Incremental searches (forwards/backwards plain/regexp)
  • Find, find next, find previous, replace, replace all, etc.
  • Remembers recent search/replace strings for re-use
  • Can replace all in a hierarchy of files or any general file-set.
  • Search for numbers in any base or format.
  • Goto line
  • Bookmarks can be placed and returned to

Editing

  • Unlimited undo/redo
  • Cut, copy, paste including 'append' actions and re-indentation
  • Automatic re-wrapping of text (including text in comments)
  • Splitting of editing windows
  • Completely configurable key assignments
  • Large number of built in text transformations
  • 'Electric' code completion/templating features
  • Multiple clipboards
  • Can show line numbers in windows
  • Select by character, word, line, paragraph, and delete similarly
  • Insert other files, names, date, time, etc.
  • Auto-update 'last modified' date in file
  • Drag and Drop editing (Windows, Unix only)
  • Word wrap at specified column with hard return
  • True soft-wrap by word or character for long lines (usually disabled for programming modes, but valuable for text modes)
  • Line length up to 30k allowed
  • Many convenient key-bindings for quick editing, can also be totally configured.

Fileset/Project features

  • Open multiple files in a single fileset
  • Access all filesets from a menu
  • Hide filesets temporarily
  • Fileset-specific tools
  • Configurable tabsize, indentation, encoding etc for each fileset
  • Define filesets by file-list, directory, hierarchy, or multi-part LaTeX document
  • Configurable version control for each fileset
  • Automatic update of fileset according to last edited file
  • Define user identity based on fileset

Unicode features

  • Supports editing of multi-byte and Unicode text
  • Sophisticaed regexp searching of Unicode.
  • Directly handles any of 82 different text encodings.
  • Open and save Unicode files

Operates with other applications and systems

  • Can edit the contents of .zip, .tar and other supported 'virtual file systems' directly (also remote ftp sites, for example).
  • Seamless interaction with almost every TeX installation in existence (including related dvi, ps, pdf, bib tools).
  • Integrates with spellcheckers (aspell, ispell, Excalibur)
  • Integrates with common version control systems (e.g. cvs)
  • Built in 'diff' file/directory visual comparison, and ability to patch differences back and forth between files.
  • Built in FTP support (you can even edit remote files)
  • Disk browsers
  • Built in text-only web-browsing (like Lynx), including support for frames -- see here.
  • Spawn off tex, compile, tcl, javac, etc. processes and capture their output (both stdout and stderr), even interact with them
  • On MacOS can send/receive apple-events.


    See: http://wiki.tcl.tk/9623        "A minimal editor explained"
    License: Open   

    See: http://wiki.tcl.tk/10674      "A minimally extended minimal editor"
    License: Open   

    See: http://wiki.tcl.tk/9602        "A minimal editor"
    License: Open   

    See: http://wiki.tcl.tk/15240     "August html editor"
    License: Open   

**Main features:

* Edit multiple files.
* Search and replace.
* Support for many of the standard HTML tags.
* Create and use templates.
* Dialog boxes for setting font size & color, inserting tables & images.

    See: http://wiki.tcl.tk/9600       "A basic editor"
    License: Open

    See: http://wiki.tcl.tk/907        "A little Unicode editor"
    License: Open

    See: http://wiki.tcl.tk/8898       "Simple text editor"
    License: Open

    See: http://wiki.tcl.tk/21292     "HexEdit - an hexadecimal editor"
    License: Open

    See: http://wiki.tcl.tk/13593    "ML tk Text Editor"
    License: Open

Some features

  • Basic tcl syntax highlighting
  • Procedure window, select a procedure to go directly to it
  • Right click on a word to have the word "copied" to the "find" window
  • Multiple windows open simultaneously
  • The editor can be invoked with file names on the command line, including wildcards (don't do too many)

  • The replace function
  • Undo/redo (RA2 but strangely "no select all"
  • Brace matching - highlight matching braces when cursor is on a brace (also quotes & square brackets)
  • Goto line number (control-g or "view" menu)
  • Added "font larger/smaller" to the view menu; 20th June 02 (v1.09)
  • Changed window system so only opens 1 toplevel window, uses frames & packing for window/file selection
  • Added a splash screen on startup to show "loading file ..." (v1.10)
  • Added a "search - grep" function
  • Don't syntax highlight files at startup, do when they are first viewed
  • The most recent find/replace strings weren't being stored at the start of the find/replace history


    See: http://eddi.sourceforge.net/    "Eddi editor"
    License: Open

    See: http://code.google.com/p/ezdit/    "ezdit"
    See: http://wiki.tcl.tk/22431                "eZdit"    
    License: GNU General Public License v3

ezdit is a cross-platform editor written in Tcl/Tk. Currently ezdit runs on Mac 、Linux and Microsoft Windows.

Features include syntax highlighting, auto-completion, code browsing, auto-indentation, etc.

It also support plugins which extend the editor's functionality.


    See: http://www.ne.jp/asahi/kazuo/sasagawa/ "FVE editor"
    License: Open

    See: http://glimmer.sourceforge.net/     "Glimmer editor"
    License: Open

    See: http://fastbase.co.nz/edit/index.html    "ML Text Editor"
    License: Open

Features:

  • Syntax Highlighting (tcl/tk).
  • Text Undo
  • Multiple Windows.
  • Procedure list with click to goto proc.
  • Right click on word for quick find.
  • Editor loads all files open since last exit & remembers "find" history.
  • Standard search and replace features.
  • Goto Line number feature.


    See: http://sites.google.com/site/msedit/home    "MSEdit"
    License: Open

  • Syntax Highlighting, User Highlighting
  • Proc listing with positional feedback
  • Reindenting of TCL Code
  • Full TCL help (8.4.12) 
  • Windows and Linux versions
  • Bookmarking
  • Proc relative line numbering (For TCL error messages)
  • Quick searching in all open files and directories
  • PDF printing
  • Project files with full context save
  • Block commenting
  • Interactive TCL console
  • File Difference mechanism
  • Portable
  • Freeware


    See: http://aune.lpl.univ-aix.fr/projects/multext/MtScript/ "MtScript"
    License: Open

MtScript is a multi-lingual text editor that enables using several different writing systems (Latin, Arabic, Cyrillic, Greek, Hebrew, Chinese, Japanese, Korean, etc.) in the same document. MtScript provides typical editing functions such as insertion and deletion, even for text containing portions of writing in opposite directions. In addition, MtScript allows the user to explicitly associate portions of the text with a particular language, and to associate keyboarding rules with any language. Different types of character sets (single byte, multiple-byte) can also be handled.

    See: http://www.pspad.com/        "PSPad"
    License: Open

    See: http://sourcenav.sourceforge.net/    "Source-Navigator"
    License: ???

    See: http://imagic.weizmann.ac.il/~dov/dov-pd.html "taved"
    License: ???

    A Hebrew editor in Tcl/Tk for Unix.

    See: http://wiki.tcl.tk/3773    "tkdiff"
    License: ???

    See: http://yapakit.fortran.pagesperso-orange.fr/ "YapKit"
    License: ???

    See: http://home.earthlink.net/~joseph-ja/programs.html "TkNotepad"
    License: ???

    See: http://developer.berlios.de/projects/countessmod/ "ML"
    License: GNU

    See: http://www.iki.fi/petterik/              "ue - Unicode Editor 0.1"

 
    See: http://wiki.tcl.tk/13591            "ML - Heavily Modified & Improved"

Uses a Panned window for the Procs which is resizeable so you can maximize the horizontal area of the file being editted
You can Run the file (after saving)
You can Run the file ../../main.tcl above it,which is useful for testing unwrapped starkits)
Can have different splits for each file being editted
Made the Popup window on right click Tearoff
Added "Save" choice to the popup
Added "Save & Run" choice to the popup
Added "Save & Run main.tcl" choice to the popup
Modified logic so popup is placed correctly when not maximized
Does not Maximize the Window on start
Increased the size of the font for procs
Colors are now variables and are loaded/saved in ml_cfg/ml
ml_cfg.ml is now written in the folder from which ml was run, NOT in the edited file's folder.
Modified the Procedure Navigator text and the About window text to reflect that this is v1.20 (ZipGuy) version

79) Error management


    See: http://www.cs.man.ac.uk/~fellowsd/tcl/mwidx.html#error for advance error reporting dialog.

80) Handling application exit


    See: http://wiki.tcl.tk/20639        "AtExit for tcl 8.5"
    See: http://wiki.tcl.tk/3958         "AtExit handlers"
 

81) Usefull Libraries


    Tklib    - normally part of any distro    See: http://tcllib.sourceforge.net
    Tcllib   - normally part of any distro    See: http://tcllib.sourceforge.net

82) Key bindings


    See: http://wiki.tcl.tk/534        "Bag of Tk algorithms"

    82.1) How change key u to U and back?

     bind $w <u> {event generate . U; break}
        # To regain the original behavior:
     bind $w X {}


    82.2) How report keybindings for each keystroke?

         bind $w <KeyPress> {puts {%%K=%K %%A=%A}}

83) Icons


    83.1) Where can I find some icons to use?

        See: http://wiki.tcl.tk/5185        "ICONS"

84) Highlighting


    84.1) How to hightlight all the way across a widget not just the text?
    Include the newline

    $text tag add highlight $line.0 $line.0+1l

85) Generate PDF files


    See: http://wiki.tcl.tk/13449        "pdf4tcl"
    See: http://wiki.tcl.tk/24593        "High-level wrapper for pdf4tcl"
    See: http://wiki.tcl.tk/2375         "PDF"

86) How can I atomatic translation of files via Bablefish?


    package require http

     proc translate {text from to} {
        # ::http::config -proxyhost proxy -proxyport 80
        set url "http://babelfish.altavista.com/tr"
        set query [::http::formatQuery doit done intl 1 tt urltext trtext $text lp ${from}_${to}]
        set token [::http::geturl $url -query $query]
        regexp {<td bgcolor=white class=s><div style=padding:10px;>([^<]*)</div></td>} \
             [::http::data $token] dummy translation

        if {1} {
        set name out.html
        set fp [open $name w]
        puts $fp [::http::data $token]
        close $fp
        global tcl_platform
        if {$tcl_platform(platform) == "windows"} {
            exec cmd /c start $name &
        } else {
            exec mozilla file://[pwd]/$name &
        }
     }
     return $translation
}

puts [translate "foot" en zh]
exit



86) Is character x in font y?


    Sure, call font actual with the character and compare the results to font actual without the character. If they are different, the font doesn't contain that character.

87) Multi File searching


    See: http://wiki.tcl.tk/8405        "A grep-like utility"
    See: http://wiki.tcl.tk/3751        "A little file searcher"

88) Adding text tags via regular expressions.

    See section on syntax highlighting. (Since this is one technique for doing that.)

89) Auto-Replace


    See: http://wiki.tcl.tk/20636        "autoreplace"

90) Hidden text


    See: http://wiki.tcl.tk/12091        "Text widget elision"


91) Standard dialogs

   

    91.1) choose directories

   
        See: tk command tk_chooseDirectory

    92.2) choose files

   
        See: tk command tk_getOpenFile
        See: tk command tk_getSaveFile
        See: tk command tk_get

    92.3) choose colors


        See: tk command tk_chooseColor
        See: http://wiki.tcl.tk/1056        "tk_chooseColor"

    92.4) choose fonts


        See: tk command "tk chooseFont"

    92.5) Find

        There is no standard find dialog in Tk.

    92.6) Find and Replace

        There is no standard find and replace dialog in Tk.

    92.7) Print

        There is no standard print dialog in Tk.

    92.8) Print Preview

        There is no stadndard print preview dalog in Tk.

    92.9) Page setup

        There is no standard page setup dialog in Tk.

    92.10) Any simple modal dialog


        See: tk command tk_dialog
        See: tk command tk_messageBox
        See: http://wiki.tcl.tk/9183            "An option dialog"
        See: tklib package http://wiki.tcl.tk/13932    "swaplist"

92) Generic articles on tk text widget


    See: http://www.tkdocs.com/tutorial/text.html        "TkDocs - Tk =Tutorial - Text"
    See: "Effective Tcl/Tk Programming"  Chapter 5 "Using the Text Widget"
    See: "Practical Programming in Tcl and Tk"  4th Edition Chapter 36 "The Text Widget"

93) Clipboard


    See: http://wiki.tcl.tk/1423            "clipboard"
    See: http://wiki.tcl.tk/15647          "Copy image to and from the Windows clipboard"
    See: http://wiki.tcl.tk/24548          "ClipboardMonitor"
    See: http://wiki.tcl.tk/1023            "Text Clipboard"
    See: http://wiki.tcl.tk/14035          "Tk's copy and paste support"
    See: http://wiki.tcl.tk/3769            "tk_textCopy"
    See: http://wiki.tcl.tk/3770            "tk_textCut"
    See: http://wiki.tcl.tk/3771            "tk_textPaste"

 

    93.1) Putting text onto clipboard?

 

    clipboard append $text
 

    93.2) Clearing the cliipboard?

 
    clipboard clear
 
 


94) Internationalization


    See: http://www.tcl.tk/doc/howto/i18n.html        "How to Use Tcl 8.1 Internationalization Features"
    See: http://wiki.tcl.tk/1816            "An i15d date chooser"
    See: http://wiki.tcl.tk/1614            "i18n - Writing for the world"

95) How generate tables?


    ???
 

96) Scrolling multiple widgets at same time.

 
    See: http://wiki.tcl.tk/9254        "multi scrolling"
 

97) Scrolling

 

98) Spacing out lines

    

    98.1) How to change spacing above each line?

 
    $w configure -spacing1 $newValue
 

    98.2) How to change spacing below each line?

 
    $w configure -spacing3 $newValue
 

    98.3) How to change space between all logical lines? (not wrapped lines)

    
    $w configure -spacing2 $newValue
 

99) Frame widgets

 

    99.1) How to embedded a entry widget into a text widget?

 
    frame $w.frame1
    # add what ever widgets you want to $w.frame1
    $w window create {2.0 linestart} -window $w.frame1
    # Don't pack embedded widgets

Left overs


These articles I ran across while producing this FAQ.

1) How to source a file and pass arguments to the script. See: http://wiki.tcl.tk/10025 source with args 
2) How to embedded non-Tk windows in a Tk app or visa-versa?
    See: http://wiki.tcl.tk/2870 "Combining GUI applications developed with Tk and 'native' Windows toolkits"
    See: http://wiki.tcl.tk/13059 "How to embed a non-Tk GUI into a Tk frame"
3) How to call a lot of native windows functions?
    See: http://twapi.magicsplat.com Tcl Windows API (TWAPI)
4) IPC?
    See: http://wiki.tcl.tk/1228    "Inventory of IPC methods"
5) Coding
    See: http://wiki.tcl.tk/11290  "Tk coding styles and philosophies"
6) Command splitting
    See: http://wiki.tcl.tk/21701    "cmdSplit"
7) Generate PS output
    See: http://wiki.tcl.tk/25703    "pentcl"
8) Command Line processing
    See: tcllib package cmdline
9) MAC computer issues
    See: http://www.codebykevin.com/opensource/tutorial.html        "How to Build Tcl/Tk Application Bundles: the Mac Way"
    See: http://www.codebykevin.com/opensource/xplat_oss.html     "Cross-platform Tcl/Tk Widgets"
    See: http://www.codebykevin.com/opensource/oss.html             "Open-Source Packages"
10) auto-repeat
    See: http://wiki.tcl.tk/23677    "disable autorepeat under Windows"
11) Increase the height of a text widget to get a full view of its word wrapped contents
    See: http://wiki.tcl.tk/20245    "full view wrapped text"
    See: http://wiki.tcl.tk/10031    "Show me all!"
12)
    See: http://wiki.tcl.tk/17166    "Revert -Providing 'Revert' and Save Prompt Functionality to Text Editors"
13) Text zooming
    See: http://wiki.tcl.tk/15868    "TextZoom -Using mousewheel scrolling events to interactively re-size text widget content"
14) Windows
    See: http://www.tkdocs.com/tutorial/windows.html    "TkDocs - Tk =Tutorial - Windows and Dialogs"
    See: http://wiki.tcl.tk/1074        "Register file types under Windows"
    See: http://wiki.tcl.tk/3285        "Playing with Windows file associations"
    See: http://wiki.tcl.tk/1264        "registry"
    See: http://wiki.tcl.tk/13565      "Where to store application configuration files"
    See: http://wiki.tcl.tk/1795        "Tcl as an NT Service"
    See: http://wiki.tcl.tk/1797        "tclsvc - Tcl as an NT Service"
    See: http://wiki.tcl.tk/9886        "TWAPI"
    See: http://wiki.tcl.tk/1008        "Microsoft Windows and Tk"
    See: http://wiki.tcl.tk/3731        "Using Windows Controls in Tk Windows"
15)
    See: http://wiki.tcl.tk/1917        "Text variable for text widget"
16)
    See: http://wiki.tcl.tk/8674        "custom cursors"
    See: http://wiki.tcl.tk/1425        "cursors"
    See: http://wiki.tcl.tk/3051        "cursor"

Out of scope


1) How do I package an application?



No comments:

Post a Comment