summaryrefslogtreecommitdiff
path: root/support/tcltexed/lib/umlaut.tcl
blob: 9de2d29bf604f7745f249172f1abeaa730d47916 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# Copyright (C) 2000 - Martin Strauss - under terms of GPL
##############################################################
# umlaut routine
# 
proc umlaut LIST {
 global FocusEditorFlag
 global FocusEditor
 if $FocusEditorFlag then {
  focus $FocusEditor.te.edit1
  foreach {FIND REPLACE} $LIST {
    set FIND_L [string length "$FIND"]
    if {$FIND != ""} then { 
     set modifiedflag 0
     undo_switch $FocusEditor.te.edit1 Save
     set startindex [$FocusEditor.te.edit1 index insert]
     set nowindex 1.0
     while {$nowindex != ""} {
      $FocusEditor.te.edit1 mark set insert $nowindex
      set NOW [$FocusEditor.te.edit1 get insert "insert + $FIND_L chars"]
      if ![string compare $NOW $FIND] then {
       # Ersetzt
       $FocusEditor.te.edit1 delete insert "insert + $FIND_L chars"
       $FocusEditor.te.edit1 insert insert $REPLACE
       set modifiedflag 1
      }
      # Sucht
      set nowindex [$FocusEditor.te.edit1 search -- $FIND insert end]
     }
     $FocusEditor.te.edit1 mark set insert $startindex
     if $modifiedflag {
      event generate $FocusEditor.te.edit1 <<Modified>>
     }
     event generate $FocusEditor.te.edit1 <<Position_tail>> -when tail
    }
   }
 }
}