home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 3 / CD ACTUAL 3.iso / linux / incoming / jstools-.6v3 / jstools- / jstools-tk3.6v3.0 / lib / jeditmodes / hook-mode.tcl < prev    next >
Encoding:
Text File  |  1995-02-09  |  2.6 KB  |  114 lines

  1. proc mode:hook:init { t } {
  2.   global JEDIT_MODEPREFS
  3.   
  4.   j:read_prefs -array JEDIT_MODEPREFS -prefix hook \
  5.     -directory ~/.tk/jeditmodes -file hook-defaults {
  6.     {textfont default}
  7.     {textwidth 80}
  8.     {textheight 30}
  9.     {textwrap char}
  10.     {sabbrev 0}
  11.     {dabbrev 0}
  12.     {autobreak 1}
  13.     {autoindent 0}
  14.     {savestate 0}
  15.     {buttonbar 1}
  16.     {menu,editor 1}
  17.     {menu,file 1}
  18.     {menu,edit 1}
  19.     {menu,prefs 1}
  20.     {menu,abbrev 1}
  21.     {menu,filter 1}
  22.     {menu,format 0}
  23.     {menu,display 1}
  24.     {menu,mode1 1}
  25.     {menu,mode2 1}
  26.     {menu,user 1}
  27.   }
  28.   
  29.   set toplevel [jedit:text_to_top $t]
  30.   label $toplevel.blue -bg blue -fg white -bd 2 -relief raised \
  31.     -text {hook mode test}
  32.   pack $toplevel.blue -fill both
  33. }
  34.  
  35. proc mode:hook:cleanup { t } {
  36.   set toplevel [jedit:text_to_top $t]
  37.   destroy $toplevel.blue
  38. }
  39.  
  40. ### proc mode:hook:pre_returnkey_hook t {
  41. ###   $t insert insert { [CR]}
  42. ### }
  43. ### 
  44. ### proc mode:hook:post_returnkey_hook t {
  45. ###   $t tag add sel {insert -1 line linestart} {insert -1 line lineend}
  46. ### }
  47. ### 
  48. ### proc mode:hook:pre_tabkey_hook t {
  49. ###   $t tag add sel {insert -1 char wordstart}
  50. ### }
  51. ### 
  52. ### proc mode:hook:post_tabkey_hook t {
  53. ###   $t tag remove sel {insert -1 char}
  54. ### }
  55. ### 
  56. ### proc mode:hook:pre_spacebar_hook t {
  57. ###   $t tag add sel {insert -1 char wordstart} {insert}
  58. ### }
  59. ### 
  60. ### proc mode:hook:post_spacebar_hook t {
  61. ###   $t tag remove sel {insert -1 char}
  62. ### }
  63.  
  64. ### proc mode:hook:spacebar t {
  65. ###   jedit:sabbrev_hook $t
  66. ###   j:tb:insert_nondigit "\\ " $t
  67. ###   jedit:autobreak_hook $t
  68. ### }
  69. ### 
  70. ### proc mode:hook:returnkey t {
  71. ###   j:tb:insert_nondigit "\\\n" $t
  72. ### }
  73. ### 
  74. ### proc mode:hook:tabkey t {
  75. ###   j:tb:insert_nondigit {^I} $t
  76. ### }
  77.  
  78. proc mode:hook:post_returnkey_hook t {
  79.   $t tag configure proc-start -foreground red \
  80.     -font "-*-lucidatypewriter-bold-r-normal-sans-18-*-*-*-*-*-*-*"
  81.   set line [$t get {insert -1 line linestart} {insert -1 line lineend}]
  82.   if [string match {proc *\{} $line] {
  83.     $t tag add proc-start {insert -1 line linestart} {insert -1 line lineend}
  84.   }
  85. }
  86.  
  87. proc mode:hook:pre_quit_hook t {
  88.   j:alert -text {Oh, sure, just quit and leave me all by myself!}
  89. }
  90.  
  91. proc mode:hook:quit t {
  92.   if [j:confirm -priority 100 \
  93.     -text "╩tes vous s√r(e)?" \
  94.     -yesbutton Oui -nobutton Non] {
  95.     if [j:confirm -priority 100 \
  96.       -text "╩tes vous vraiment s√r(e)?" \
  97.       -yesbutton Oui -nobutton Non] {
  98.       exit 0
  99.     }
  100.   }
  101. }
  102.  
  103. proc mode:hook:done t {
  104.   if [j:confirm -priority 100 \
  105.     -text "Are you COMPLETELY sure you're done?"\
  106.     -yesbutton Yuppers -nobutton Nope] {
  107.     jedit:cmd:save $t
  108.     jedit:cmd:quit $t
  109.   } else {
  110.     j:alert -text "Saving..."
  111.     jedit:cmd:save $t
  112.   }
  113. }
  114.