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 / richtext-mode.tcl < prev    next >
Encoding:
Text File  |  1995-02-10  |  1.7 KB  |  64 lines

  1. # ~/.tk/edittkmodes/richtext-mode.tcl - mode for styled text
  2. ######################################################################
  3.  
  4. proc mode:richtext:init { t } {
  5.   global JEDIT_MODEPREFS
  6.   
  7.   j:read_prefs -array JEDIT_MODEPREFS -prefix richtext \
  8.     -directory ~/.tk/jeditmodes -file richtext-defaults {
  9.     {textfont default}
  10.     {textwidth 80}
  11.     {textheight 24}
  12.     {textwrap word}
  13.     {sabbrev 0}
  14.     {dabbrev 0}
  15.     {autobreak 0}
  16.     {autoindent 0}
  17.     {savestate 0}
  18.     {buttonbar 1}
  19.     {menu,editor 1}
  20.     {menu,file 1}
  21.     {menu,edit 1}
  22.     {menu,prefs 0}
  23.     {menu,abbrev 1}
  24.     {menu,filter 1}
  25.     {menu,format 1}
  26.     {menu,display 1}
  27.     {menu,mode1 0}
  28.     {menu,mode2 0}
  29.     {menu,user 1}
  30.   }
  31. }
  32.  
  33. ######################################################################
  34. # save entire contents of text widget, including tags and marks
  35. #   (overrides normal write procedure)
  36. ######################################################################
  37.  
  38. proc mode:richtext:write { filename t } {
  39.   j:tag:archive_text_widget $t $filename
  40. }
  41.  
  42. ######################################################################
  43. # read in archive of text widget, including tags and marks
  44. #   (overrides normal read procedure)
  45. ######################################################################
  46.  
  47. proc mode:richtext:read { filename t } {
  48.   jedit:font:roman $t                ;# start tagging as roman
  49.   if { ! [file exists $filename] } then {
  50.     $t delete 1.0 end
  51.     $t mark set insert 1.0
  52.     jedit:set_label $t "$filename (new file)"
  53.   } else {                    ;# file exists
  54.     j:tag:restore_text_widget $t $filename
  55.     global JEDIT_MODEPREFS
  56.     if { ! $JEDIT_MODEPREFS(richtext,savestate) } {
  57.       $t tag remove sel 1.0 end
  58.       $t mark set insert 1.0
  59.       $t yview 1.0
  60.     }
  61.   }
  62. }
  63.  
  64.