source: tol/tolbase/lib/toltk/editor.tcl @ 6d7779d

1941-docker-image-to-testdevel
Last change on this file since 6d7779d was 6d7779d, checked in by Jorge Pérez <josp.jorge@…>, 18 years ago

initial import

git-svn-id: ​https://www.tol-project.org/svn/tolp/trunk@1 be4846ae-f051-483a-831f-b64e7d08527f

  • Property mode set to 100644
File size: 64.0 KB
Line 
1#/////////////////////////////////////////////////////////////////////////////
2# FILE    : editor.tol
3# PURPOSE :  This file contains a namespace called Editor with its functions.
4#           It's for creating a editor widget with TOL highlight syntax and
5#           managing its events.
6#/////////////////////////////////////////////////////////////////////////////
7
8#/////////////////////////////////////////////////////////////////////////////
9# TESTING
10#/////////////////////////////////////////////////////////////////////////////
11# Put if {1} for testing this file.
12if { 0 } {
13  package require Tk
14  package require BWidget
15  package require BLT
16  Bitmap::use
17
18  set toltk_script_path [file dirname [info script]]
19  set toltk_images_path [file join ${toltk_script_path} images]
20
21  #source [file join $toltk_script_path "ctext.tcl"]
22  source [file join $toltk_script_path "supertext.tcl"]
23  Supertext::overrideTextCommand
24  source [file join $toltk_script_path "bystext.tcl"]
25  lappend ::Bitmap::path $toltk_images_path
26
27  package require msgcat
28  namespace import ::msgcat::*
29  ::msgcat::mclocale es
30  ::msgcat::mcload [file join $toltk_script_path msgs]
31
32  set home_path $env(HOME)
33  ::iniFile::Create [file join $home_path "tolcon.ini"]
34  proc startupResources { } {
35    global tcl_platform
36    global toltk_options
37    DynamicHelp::configure -background \#FFFFC0
38    if [string equal $tcl_platform(platform) "windows"] {
39      set toltk_options(colors,SystemButtonFace) SystemButtonFace
40      set toltk_options(fonts,MenuNor) {Tahoma 8}
41      set toltk_options(fonts,Fixed)   {{Courier New} 9}
42      set toltk_options(fonts,Title1)  {Arial 9 bold}
43      set toltk_options(fonts,Label)   {Arial 9}
44      font create Letra1 -family "Arial" -slant roman -size 8
45      set toltk_options(relief,ridge) ridge
46    } else  {
47      set toltk_options(colors,SystemButtonFace) #d4d4d4
48      set toltk_options(fonts,MenuNor) {-*-helvetica-medium-r}
49      set toltk_options(fonts,Fixed)   {Courier 10}
50      set toltk_options(fonts,Title1)  {-*-helvetica-bold-r}
51      set toltk_options(fonts,Label)   {-*-helvetica-medium-r}
52      set toltk_options(relief,ridge) raised
53    }
54  }
55  startupResources
56}
57
58
59#/////////////////////////////////////////////////////////////////////////////
60  namespace eval ::Editor {
61#
62# PURPOSE: The purpose of this namespace is organize code and functions and
63#          manage common options for all editors such as last edited files,
64#          last directory opened, etc.
65#          A special namespace is created for each instance of editor.
66#
67# VARIABLES:
68#   options -> common options for all editor windows:
69#     geometry  -> initial window editor geometry
70#     wm,state  -> initial window editor state
71#     font      -> editor's text widget font
72#     lastDir   -> last directory used
73#     chEdited  -> boolen for saving last edited files path
74#     numEdited -> number of last edited files path to save
75#     edited    -> path of last edited files
76#   tmpOpt     -> temporary array used to store the widgets and variables of
77#              the options dialog.
78#   num_editor -> incrementally number to identify each editor window
79#   typelist   -> list of type files supported by editor
80#   defExt     -> default extension for files managed by editor
81#
82#/////////////////////////////////////////////////////////////////////////////
83  variable options
84  variable num_editor 0
85  variable typelist {{"Tol Files" {".tol"}} {"All Files" {"*"}}}
86  variable defExt   .tol
87}
88
89
90#/////////////////////////////////////////////////////////////////////////////
91  proc ::Editor::New {{path ""}} {
92#
93# PURPOSE: Creates a new editor window and an instance of it. This also
94#          initializes the instance and register the window in the project.
95#
96# PARAMETERS:
97#   path  -> path of file to edit. If it isn't specified a new white document
98#            is created.
99#
100# RETURN: A instance of editor.
101#
102#/////////////////////////////////////////////////////////////////////////////
103  variable num_editor
104  incr num_editor
105
106  set this [Create .editor$num_editor]
107  SetTraces $this
108  InitState $this new
109  update
110  if {$path == ""} {
111    CmdNew $this
112  }
113  return $this
114}
115
116
117#/////////////////////////////////////////////////////////////////////////////
118  proc ::Editor::Open {{path ""} {run 0}} {
119#
120# PURPOSE: Opens a file in a editor window. If file is already opened it
121#          raises its window, else it creates a new editor window and an
122#          instance of it.
123#
124# PARAMETERS:
125#   path  -> path of file to open. If it isn't specified it ask for it.
126#   run   -> automatically once opened, compiles the file
127#
128# RETURN: A instance of editor.
129#
130#/////////////////////////////////////////////////////////////////////////////
131  if {$path != ""} {
132    #Comprobar si el archivo ya está abierto y si es así hacer un raise
133    foreach ins [namespace children ::Editor] {
134      upvar \#0 ${ins}::data data
135      if {[string equal $data(nameFile) $path]} {
136        #wm deiconify $data(f)
137        $data(f) raise
138        #focus $data(f)
139        return $ins
140      }
141    }
142    update
143  }
144
145  if {$path == ""} {
146    CmdOpen ""
147  } else  {
148    set this [New $path]
149    GetFromFile $this $path $run
150  } 
151
152  if {[info exists this]} {
153    return $this
154  } else  {
155    return ""
156  }
157}
158
159
160#/////////////////////////////////////////////////////////////////////////////
161  proc ::Editor::postEdited {m {ord 0}} {
162#
163# PURPOSE: Fills a menu with the last edited files, according to the
164#          information of 'options' variable.
165#
166# PARAMETERS:
167#   m   -> menu's path that will have the list of last edited files
168#   ord -> flag that indicates if files must be shown sorted
169#
170#/////////////////////////////////////////////////////////////////////////////
171  variable options
172  $m delete 0 end
173  if $options(chEdited) {
174    set options(edited) [lrange $options(edited) 0 [expr $options(numEdited)-1]]
175    if $ord {
176      set lst [lsort -ascii $options(edited)]
177    } else {
178      set lst $options(edited)
179    }
180    foreach w $lst {
181      $m add command -label $w -command [list ::Editor::Open $w]
182    }
183    if [llength $lst] {
184      $m add separator
185      $m add command -label [mc "Clear"]\
186            -command [list ::Editor::clearEdited]
187    }
188  }
189}
190
191#/////////////////////////////////////////////////////////////////////////////
192  proc ::Editor::clearEdited {} {
193#
194# PURPOSE: Clears the list of last edited files
195#
196#/////////////////////////////////////////////////////////////////////////////
197  variable options
198  set options(edited) ""
199  ::iniFile::Write Editor recent       $options(edited)
200  ::iniFile::Flush
201}
202
203#/////////////////////////////////////////////////////////////////////////////
204  proc ::Editor::OnDelete {this} {
205#
206# PURPOSE: Procedure to check things before destroying editor window
207#
208# PARAMETERS:
209#   this  -> Instance of editor
210#
211#/////////////////////////////////////////////////////////////////////////////
212  upvar \#0 ${this}::data data
213  if {[string equal [CheckOpen $this] "cancel"]} {
214    return 0
215  }
216  destroy $data(f)
217  return 1
218}
219
220#/////////////////////////////////////////////////////////////////////////////
221proc ::Editor::Configure {this} {
222#
223# PURPOSE: Configures editor
224#
225#/////////////////////////////////////////////////////////////////////////////
226  variable options
227
228  set fnt $options(font)
229 
230  #puts "Configure con $fnt"
231
232  if {[llength $fnt]>1} {
233    font configure ctfnBold   -family [lindex $fnt 0] -size [lindex $fnt 1]
234    font configure ctfnNormal -family [lindex $fnt 0] -size [lindex $fnt 1]
235  } else {
236    font configure ctfnBold   -family $fnt -size 9
237    font configure ctfnNormal -family $fnt -size 9
238  }
239  CmdRightMargin $this
240}
241
242#/////////////////////////////////////////////////////////////////////////////
243  proc ::Editor::Destroy {this w} {
244#
245# PURPOSE: Deletes the instance of editor. Before this,writes the ini file.
246#
247# PARAMETERS:
248#   this  -> Instance of editor
249#
250#/////////////////////////////////////////////////////////////////////////////
251  upvar \#0 ${this}::data data
252  #CheckOpen $this
253  if { [string equal $data(f) $w] } {
254    # guardamos variables en el .ini
255#puts "estamos destruyendo y guardando en el ini"
256    WriteIni $this
257    namespace delete $this
258  }
259}
260
261
262#/////////////////////////////////////////////////////////////////////////////
263  proc ::Editor::InitState {this from} {
264#
265# PURPOSE: Initializes some variables according to the state of editor.
266#
267# PARAMETERS:
268#   this  -> Instance of editor
269#   from  -> State that defines values for the variables
270#
271#/////////////////////////////////////////////////////////////////////////////
272  upvar \#0 ${this}::data data
273
274  switch $from {
275    new {
276      set data(isSaved) 1
277      set data(isCompiled) 0
278      #If clipboard has something (to enable paste)
279      set data(clipboard) 0
280      #If there is something selected (to enable cut, copy)
281      set data(selected)  0
282      set data(nameFile) ""
283      # Time of last modification of file
284      set data(mTime)    0
285      #pedro - balloon controller
286      set data(balloon) 0
287    }
288    open {
289      if {[lsearch [::tol::info included] $data(nameFile)] != -1} {
290        set data(isCompiled) 1
291      } else {
292        set data(isCompiled) 0
293      }
294      set data(isSaved) 1
295#      set data(nameFile) ""
296    }
297    save {
298      set data(isSaved) 1
299      #set data(isCompiled) 0
300    }
301  }
302  #pedro-controls balloon hlp
303  IniSupertext $this
304}
305
306
307#/////////////////////////////////////////////////////////////////////////////
308  proc ::Editor::InsertFileHeader {this} {
309#
310# PURPOSE:
311#
312# PARAMETERS:
313#
314#/////////////////////////////////////////////////////////////////////////////
315  variable options
316  upvar \#0 ${this}::data data
317  if $options(chFileH) {
318    if [file exists $options(fileH)] {
319      ::BayesText::Open $data(txt) $options(fileH)
320      #Lo marcamos como guardado a pesar de no ser realmente cierto
321      set data(isSaved) 1
322      tk::TextSetCursor $data(txt) end
323    } else {
324      #Sacar mensaje de que no existe el archivo especificado
325      tk_messageBox -type ok -icon warning \
326         -parent $data(txt) -title [mc Warning] \
327         -message "[mc "Header file %1\$s doesn't exist" $options(fileH)].\n\
328            [mc "Check editor's options"]"
329      $data(txt) mark set insert 1.0
330    }
331  }
332}
333
334#/////////////////////////////////////////////////////////////////////////////
335  proc ::Editor::InsertFileFunction {this} {
336#
337# PURPOSE:
338#
339# PARAMETERS:
340#
341#/////////////////////////////////////////////////////////////////////////////
342  variable options
343  upvar \#0 ${this}::data data
344
345  if [file exists $options(funcH)] {
346    ::BayesText::Open $data(txt) $options(funcH) $data(position)
347    #tk::TextSetCursor $data(txt) end
348  } else {
349    #Sacar mensaje de que no existe el archivo especificado
350    tk_messageBox -type ok -icon warning \
351       -parent $data(txt) -title [mc Warning] \
352       -message "[mc "Functions file header %1\$s doesn't exist" $options(funcH)].\n\
353          [mc "Check editor's options"]"
354  }
355  $data(txt) mark set insert $data(position)
356}
357
358proc ::Editor::IniSupertext {this} {
359  upvar \#0 ${this}::data data
360  set Supertext::undo($data(txt,supertext))      {}
361  set Supertext::undoIndex($data(txt,supertext)) -1
362}
363
364
365#/////////////////////////////////////////////////////////////////////////////
366  proc ::Editor::SetTraces {this} {
367#
368# PURPOSE: Sets some traces of variables to control changes in editor widget
369#
370# PARAMETERS:
371#   this  -> Instance of editor
372#
373#/////////////////////////////////////////////////////////////////////////////
374  upvar \#0 ${this}::data data
375
376  trace variable ${this}::data(nameFile)   w \
377        [list ::Editor::TraceNameFile $this]
378  trace variable ${this}::data(selected)   w \
379        [list ::Editor::TraceSelected $this]
380  trace variable ${this}::data(isSaved)    w \
381        [list ::Editor::TraceSaved $this]
382  trace variable ${this}::data(isCompiled) w \
383        [list ::Editor::TraceCompiled $this]
384  trace variable ${this}::data(position)   w \
385        [list ::Editor::TracePosition $this]
386  trace variable Supertext::undo($data(txt,supertext)) w \
387        [list ::Editor::TraceUndo $this]
388}
389
390proc ::Editor::UpdateMarkPos { this h} {
391  #puts "UpdateMarkPos $this $h"
392
393  variable options
394  upvar \#0 ${this}::data data 
395  if $options(chLine) {
396    $data(txt,mark) configure -height $h
397    set xpos [expr $options(posLine) * [font measure ctfnNormal "/"]]
398    place $data(txt,mark) -in $data(txt) -x $xpos -y 0
399  } else {
400    place forget $data(txt,mark)
401  }
402}
403
404proc ::Editor::OnConfigure { this w h } {
405  UpdateMarkPos $this $h
406}
407
408
409#/////////////////////////////////////////////////////////////////////////////
410  proc ::Editor::Create {path} {
411#
412# PURPOSE: Creates a editor instance
413#
414# PARAMETERS:
415#   path  -> editor's path (toplevel)
416#
417# RETURN: Editor's instance
418#
419#/////////////////////////////////////////////////////////////////////////////
420  variable options
421
422  set this ::Editor::$path
423  if { [lsearch [namespace children ::Editor] $this] != -1 } {
424    error "$this already exists as a children of ::Editor"
425  }
426  namespace eval $this {
427    variable data
428  }
429  upvar \#0 ${this}::data data
430
431  # create
432  set data(f) [set f [::project::CreateForm -width 575 -height 700 \
433                        -type Files \
434                        -iniconfig Editor \
435                        -closecmd [list ::Editor::OnDelete $this] \
436                        -helpkey "Tb4Eda"] ]
437  set f [$f getframe]
438 
439  # bind Destroy más abajo
440  set n_b [list \
441     "bnew"         "CmdNew"      "[mc [list New white document]] (CTRL+N)" \
442     "bopen"        "CmdOpen"     "[mc Open] (CTRL+A)" \
443     "bsave"        "CmdSave"     "[mc Save] (CTRL+S)" \
444     "bsaveas"      "CmdSaveAs"   "[mc "Save As"] (CTRL+G)" \
445     "sep1"        "--"          ""\
446     "bcut"         "CmdCut"      "[mc Cut] (CTRL+X)" \
447     "bcopy"        "CmdCopy"     "[mc Copy] (CTRL+C)" \
448     "bpaste"       "CmdPaste"    "[mc Paste] (CTRL+V)" \
449     "sep2"        "--"          ""\
450     "bundo"        "CmdUndo"     "[mc Undo] (CTRL+Z)" \
451     "bredo"        "CmdRedo"     "[mc Redo] (CTRL+Y)" \
452     "sep3"        "--"          ""\
453     "bfind"        "CmdFind"     "[mc Find] (CTRL+F)" \
454     "findnext"    "CmdFindNext" "[mc [list Find next]] (F3)" \
455     "funsearch"   "CmdSearch"   "[mc {Search function}] (CTRL+G)" \
456     "sep4"        "--"          ""\
457     "unident"     "CmdUnIdent"  "[mc Unident] (CTRL+U)" \
458     "ident"       "CmdIdent"    "[mc Ident] (CTRL+I)" \
459     "sep5"        "--"          ""\
460     "bprint"      "CmdPrint"    "[mc Print]" \
461     "font"        "CmdFont"     "[mc Font] (CTRL+T)" \
462     "sep6"        "--"          ""\
463     "eval"        "CmdCompile"  "[mc Compile] (F11)" \
464     "savecom"     "CmdSaveCompile" "[mc [list Save and Compile]] (F9)" \
465     "decom"       "CmdDecompile"  "[mc Decompile] (F8)" \
466     "syntaxcheck" "CmdSyntaxCheck" "[mc [list Syntax Check]] (F7)" \
467     "refresh"     "CmdRefresh" "[mc Refresh] (F5)"\
468     "balloon"     "CmdBalloon"    "[mc BalloonHelp]" \
469     "sep7"        "--"          ""\
470     "tools"       "CmdOptions" "[mc Options]"]
471  # botonera superior
472  set data(tb,frame) [frame $f.ftop -relief raised -bd 1]
473  foreach {n_img n_proc n_hint} $n_b {
474    if {[string equal $n_proc "--"]} {
475      Separator $f.ftop.$n_img -orient vertical
476      #pack $f.ftop.$n_img -side left -fill y
477    } else {
478      set data(tb,$n_img) [Button $f.ftop.$n_img\
479                -image [::Bitmap::get ${n_img}] -relief link\
480                -helptext $n_hint -bd 2\
481                -command [list ::Editor::$n_proc $this]]
482    }
483    pack $f.ftop.$n_img -anchor nw -side left -pady 2 -fill y -padx 1
484  }
485  #desactivamos botones de print y redo
486  #$data(tb,redo)  configure -state disabled
487  $data(tb,bprint) configure -state disabled
488     
489   
490  # frame y label para barra de estado
491  set data(sb,frame) [frame $f.fop -relief groove -bd 1 -height 7]
492  set data(sb,posi)  [label $f.fop.posi -relief groove -bd 1 -width 16]
493  set data(sb,comp)  [label $f.fop.comp -text [mc "Not Compiled"] \
494                                        -relief raised -bd 1 -width 16]
495  set data(sb,modi)  [label $f.fop.modi -bd 1 -width 14]
496  set data(sb,nlin)  [label $f.fop.nlin -relief groove -bd 1 -width 16]
497  set data(sb,rell)  [label $f.fop.rell -relief groove -bd 1]
498  # texto y scroll
499  scrollbar $f.sy -command "$f.t yview"
500  scrollbar $f.sx -orient horizontal -command "$f.t xview"
501
502  set data(txt) [::BayesText::CreateHLText $f.t tol \
503         -background white -borderwidth 0 -wrap none\
504         -foreground black -relief sunken \
505         -yscrollcommand "$f.sy set" \
506         -xscrollcommand "$f.sx set" \
507         -preproc "::Editor::PreProc $this" \
508         -linemap 0 -font $options(font)]
509
510  bind $data(txt) <Configure> "::Editor::OnConfigure $this %w %h"
511  set data(txt,ctext)      $data(txt).t
512  set data(txt,mark) [frame $f.mark -bg gray50 -width 1 \
513                          -cursor [$data(txt,ctext) cget -cursor]]
514
515  set data(txt,supertext)  __$data(txt,ctext)
516
517  focus $data(txt,ctext)
518  # empaquetamos los label de estado
519  pack $f.fop.posi $f.fop.comp $f.fop.modi $f.fop.nlin -side left
520  pack $f.fop.rell -expand true -fill x
521   
522  grid $f.ftop  -     -sticky new
523  grid $f.t     $f.sy -sticky news
524  grid $f.sx          -sticky ew
525  grid $f.fop   -     -sticky ews
526
527  grid rowconfigure    $f 1 -weight 1
528  grid columnconfigure $f 0 -weight 1
529
530  #Creación de un menú contextual
531  # leer del archivo de cinfiguracion para coger la fuente del texto
532  set m [menu $f.m -tearoff 0]
533  $m add command -label [mc "Save and Compile"] -accelerator F9 \
534                 -command [list ::Editor::CmdSaveCompile $this]
535  $m add command -label [mc "Decompile"] -accelerator F8 \
536                 -command [list ::Editor::CmdDecompile $this]
537  $m add command -label [mc "Syntax Check"] -accelerator F7 \
538                 -command [list ::Editor::CmdSyntaxCheck $this]
539  $m add command -label [mc "Compile"] -accelerator F11 \
540                 -command [list ::Editor::CmdCompile $this]
541  $m add command -label [mc "Refresh"] -accelerator F5 \
542                 -command [list ::Editor::CmdRefresh $this]
543
544  $m add separator
545  $m add command -label "[mc Open]..." -accelerator CTRL+A \
546                 -command [list ::Editor::CmdOpen $this]
547  $m add command -label [mc "Save"] -accelerator CTRL+S \
548                 -command [list ::Editor::CmdSave $this]
549  $m add command -label "[mc [list Save as]] ..." \
550                 -command [list ::Editor::CmdSaveAs $this]
551  $m add separator
552  $m add command -label "[mc Find]..." -accelerator CTRL+F \
553                 -command [list ::Editor::CmdFind $this]
554  $m add command -label [mc "Find next"] -accelerator F3 \
555                 -command [list ::Editor::CmdFindNext $this]
556  $m add command -label "[mc Replace]..." -accelerator CTRL+R \
557                 -command [list ::Editor::CmdReplace $this]
558  $m add command -label "[mc {Search function}]..." -accelerator CTRL+G \
559                 -command [list ::Editor::CmdSearch $this]
560  $m add separator
561  $m add command -label [mc "Insert function schema"] \
562                 -command [list ::Editor::InsertFileFunction $this]
563  $m add command -label "[mc Font]..." -accelerator CTRL+T \
564                 -command [list ::Editor::CmdFont $this]
565  $m add check   -label [mc "Show right margin line"] -variable ::Editor::options(chLine) \
566                 -command [list ::Editor::CmdRightMargin $this]
567  set me [menu $f.m.edit -tearoff 0]
568  $m add cascade -label [mc "Edit"] -menu $me
569  $me add command -label [mc "Undo"] -accelerator CTRL+Z \
570                  -command [list ::Editor::CmdUndo $this]
571  $me add command -label [mc "Cut"] -accelerator CTRL+X \
572                  -command [list ::Editor::CmdCut $this]
573  $me add command -label [mc "Copy"] -accelerator CTRL+C \
574                  -command [list ::Editor::CmdCopy $this]
575  $me add command -label [mc "Paste"] -accelerator CTRL+V \
576                  -command [list ::Editor::CmdPaste $this]
577  $me add command -label [mc "Select all"] -accelerator CTRL+E \
578                  -command [list ::Editor::CmdSelectAll $this]
579 
580  #CVS Utilities
581  #$m add separator
582  #set mc [menu $f.m.cvs -tearoff 0]
583  #$m add cascade -label [mc "CVS Utilities"] -menu $mc
584  #$mc add command -label [mc "TkCVS"] \
585  #                -command [list ::Editor::CmdTkcvs $this 0]
586  #$mc add command -label [mc "TkDiff"] \
587  #                -command [list ::Editor::CmdTkcvs $this  1]
588 
589
590  bind $data(txt,ctext) <Button-3>  "tk_popup $m %X %Y"
591  #pedro
592  #$data(txt,ctext) tag bind Text <Enter> [list ::Editor::BalloonHlp $this]
593  #set data(menu) [::BayesText::MenuCreate $data(txt)]
594  set data(menu) $m
595  #Quitar los eventos que pueden dar conflictos
596  bind Text <Control-a> ""
597  # necesario para q al escribir el simbolo del euro no ejecute tb el comando
598  #bind Text <Control-e> "::Editor::CmdSelectAll $this"
599  bind Text <Control-f> ""
600  bind Text <Control-i> ""
601  bind Text <Control-n> ""
602  bind Text <Control-t> ""
603   
604  # eventos asociados al formulario
605  bind $data(txt) <F1>        "::Editor::CmdHelpEditor $this ; break"
606  bind $data(txt) <F3>        "Editor::CmdFindNext $this ; break"
607  bind $data(txt) <F5>        "::Editor::CmdRefresh $this ; break"
608  bind $data(txt) <F7>        "::Editor::CmdSyntaxCheck $this ; break"
609  bind $data(txt) <F8>        "::Editor::CmdDecompile $this  ; break"
610  bind $data(txt) <F9>        "Editor::CmdSaveCompile $this ; break"
611  bind $data(txt) <F11>       "Editor::CmdCompile $this ; break"
612  bind $data(txt) <Control-KeyRelease> "::Editor::OnControlKey $this %K %k ; break"
613  bind $data(f)   <Destroy>    +[list ::Editor::Destroy $this %W]
614  Configure $this
615  $data(f) bind <Control-F4> "$data(f) kill; break"
616  #BalloonHelp para Sintaxis de funciones al escribir
617  bind $data(txt) <parenleft>    [list ::Editor::AnalyzeCurrentText $this]
618  bind $data(txt) <parenright>   [list destroy $data(txt).balloon]
619  bind $data(txt) <BackSpace>    [list destroy $data(txt).balloon]
620  bind $data(txt) <Return>       [list destroy $data(txt).balloon]
621  bind $data(txt) <Escape>       [list destroy $data(txt).balloon]
622  bind $data(txt) <Any-Leave>    [list destroy $data(txt).balloon]
623  return $this
624}
625
626#pedro-start
627
628#/////////////////////////////////////////////////////////////////////////////
629proc ::Editor::AnalyzeCurrentText { this } {
630#
631#PURPOSE: Verifica si el texto escrito pertenece a alguna funcion definida
632#         , se muestra la sintaxis y su descripcion como BalloonHlp.
633#         Se activa cuando el usuario pulsa "(". El balloon creado se destruye
634#         con backspace o ")". Ver Binds.
635#/////////////////////////////////////////////////////////////////////////////
636  upvar \#0 ${this}::data data
637  #Guardo posicion del cursor
638  set origen  [$data(txt) index insert]
639  set def     $origen
640  set anatext " "
641  #descompongo el index de origen en  partes
642  set invariante [lindex [split $origen .] 0 ]
643  set variante   [lindex [split $origen .] 1 ]
644  set a 1;
645 
646  # Verifico que no estemos en el index n,0
647  if { $variante == 0 } {
648    return   
649  }
650  set def 1
651  # Recorro hacia atras a partir del insert index para obtener index de la ultima
652  # letra de la palabra inmediatamente detras del "("
653  while { [expr ![regexp {[A-Za-z0-9]} $anatext]] && $variante > 0 && $def > 0} { 
654    set def [expr $variante -$a]
655    set anatext [$data(txt) get "$invariante.$def"]
656    incr a   
657  }
658  # Encuentro la letra, obtener nombre de la funcion con wordstart y wordend.
659  set ori  [$data(txt) index "$invariante.$def wordstart"]
660  set end  [$data(txt) index "$invariante.$def wordend"]
661  set word [$data(txt) get $ori $end]
662
663  # procedimiento para establecer posicion del BalloonHelp bajo el Cursor
664  set lineinfox     [lindex [$data(txt) dlineinfo $origen] 2]
665  # hallo el total de caracteres en la linea con la segunda parte del insert index
666  set totalchars [lindex [split [$data(txt) index "$invariante.end"] . ] 1]
667  # Necesito convertir el indice del cursor en coordenadas de pantalla [pixelx pixely]
668  # posicion del "(" MULT por largo de linea en pixeles ENTRE total de letras.
669  # más posicion relativa de la ventana = posicion en X
670  set posicionbichox [expr (round(($variante * $lineinfox) / $totalchars)) + \
671                     ([winfo rootx $data(txt)])]
672 
673  # Posicion de linea + alto de linea + posicion relativa de la ventana = Posicion Y
674  set posicionbichoy [expr ([lindex [$data(txt) dlineinfo $origen] 1]) + \
675                           ([lindex [$data(txt) dlineinfo $origen] 3]) + \
676                           ([winfo rooty $data(txt)])]
677 
678  # Ejecuto un BalloonHlp usando los 3 ultimos parametros opcionales.
679  ::Editor::BalloonHlp $this $data(txt) $word 1 $posicionbichox $posicionbichoy 1
680  #Ayuda creada.
681}
682
683
684#///////////////////////////////////////////////////////////////////////////
685proc ::Editor::BalloonHlp {this w arg {fixed 0} {posx 0} {posy 0} {special 0}} {
686# PURPOSE: Look for Tol value of the compiled variable and display balloon text
687#          If availiable.
688# ARGS   : Instance, Window, VarName
689#///////////////////////////////////////////////////////////////////////////
690  upvar \#0 ${this}::data data
691  #el segundo condicional impide que se cree el balloon si existe otro
692  if { ($data(balloon) == 1 && [expr !([winfo exist $data(txt).balloon])]) || \
693        $special == 1} {
694   #creacion del toplevel para mostrar ayuda
695   set definition [::TclInfoVar "Anything" $arg]
696   #Continuamos mostrando solo si la variable tiene algo.
697   if { [llength $definition] < 1 } {
698      return
699    } else {
700    set top $w.balloon
701    catch {destroy $top}
702    toplevel $top -bd 1 -bg black
703    wm overrideredirect $top 1
704    #obtengo info de la variable 
705     set cont [lindex $definition end-2]
706     set desc [lindex $definition end]
707     set information "$arg: \n Valor: $desc \n Definicion: $cont" 
708     #Crear Helpwindow
709     font create Letra1 -family "Arial" -slant roman -size 8
710     pack [message $top.txt -aspect 10000 -bg lightyellow \
711         -font Letra1 -text $information]
712     #Fixed 1 para invocado por text, Fixed 0 por defecto, obedece al raton.
713     if { $fixed != 1} {
714       #Si el balloon es invocado por el raton, obedecemos a posicion del raton.
715       # A partir de la posicion del raton, modificamos vars para poner el toplevel
716       # amarillo en un lugar diferente al cursor,  nunca sobre el.
717        set wmx [winfo pointerx $w]
718        set wmy [winfo pointery $w]
719        incr wmx 40
720        set wmy [expr $wmy - 40]
721      } else {
722         #Si el Balloon es invocado por el texto, obedecemos a la posicion del indice.
723         set wmx $posx
724         set wmy $posy
725      }
726      #muestro
727      wm geometry $top \
728      [winfo reqwidth $top.txt]x[winfo reqheight $top.txt]+$wmx+$wmy
729      raise $top
730      font delete Letra1
731    }
732  }
733}
734#pedro-end
735
736
737#///////////////////////////////////////////////////////////////////////////
738  proc ::Editor::OnControlKey {this keysym keycode} {
739#
740# PURPOSE: Control the "Control + Key Press"
741#
742# PARAMETERS: this ->  Instance of editor
743#             keysym -> The keysym corresponding to the event,
744#                       substituted as a textual string
745#             keycode -> The keycode field from the event
746#
747#///////////////////////////////////////////////////////////////////////////
748  #puts "PLATFORM: $::tcl_platform(platform)"
749  switch [string toupper $keysym] {
750    A { ::Editor::CmdOpen      $this }
751    E { ::Editor::CmdSelectAll $this }
752    F { ::Editor::CmdFind      $this }
753    G { ::Editor::CmdSearch    $this }
754    I { ::Editor::CmdIdent     $this }
755    N { ::Editor::CmdNew       $this }
756    R { ::Editor::CmdReplace   $this }
757    S { ::Editor::CmdSave      $this }
758    T { ::Editor::CmdFont      $this }
759    U { ::Editor::CmdUnIdent   $this }
760    X { ::Editor::CmdCut       $this }
761    Y { ::Editor::CmdRedo      $this }
762    Z { ::Editor::CmdUndo      $this }
763    C { if { [string equal $::tcl_platform(platform) "unix"] } {
764          ::Editor::CmdCopy $this
765        } elseif { [string equal $::tcl_platform(platform) "windows"] } {
766          switch $keysym {
767            C {
768              ::Editor::CmdCopy $this }
769          }
770        }
771      }
772    V { if { [string equal $::tcl_platform(platform) "unix"] } {
773          ::Editor::CmdPaste $this
774        } elseif { [string equal $::tcl_platform(platform) "windows"] } {
775          switch $keysym {
776            V {
777              ::Editor::CmdPaste $this }
778          }
779        }
780      }
781  }
782} 
783
784
785#/////////////////////////////////////////////////////////////////////////////
786  proc ::Editor::TracePosition {this name1 name2 op} {
787#
788# PURPOSE: Sets position of cursor and lines info in status bar each time var
789#          'position' changes.
790#
791# PARAMETERS:
792#   this  -> Instance of editor
793#   name1, name2, op ->
794#     Name1 and name2 give the name(s) for the variable being accessed: if the
795#     variable is a scalar then name1 gives the variable's name and name2 is
796#     an empty string; if the variable is an array element then name1 gives
797#     the name of the array and name2 gives the index into the array; if an
798#     entire array is being deleted and the trace was registered on the
799#     overall array, rather than a single element, then name1 gives the array
800#     name and name2 is an empty string. Name1 and name2 are not necessarily
801#     the same as the name used in the trace variable command: the upvar
802#     command allows a procedure to reference a variable under a different
803#     name. Op indicates what operation is being performed on the variable,
804#     and is one of r, w, or u.
805#
806#/////////////////////////////////////////////////////////////////////////////
807  upvar \#0 ${this}::data data
808 
809  set pos [split $data(position) .]
810  set text "[mc Lin]. [lindex $pos 0]  [mc Col]. [lindex $pos 1]"
811  $data(sb,posi) configure -text $text
812  set pos [split [Supertext::text_index $data(txt) end] .]
813  $data(sb,nlin) configure -text "[lindex $pos 0] [mc lines]"
814}
815
816
817#/////////////////////////////////////////////////////////////////////////////
818  proc ::Editor::TraceNameFile {this name1 name2 op} {
819#
820# PURPOSE: Sets edited file name each time var 'nameFile' changes.
821#
822# PARAMETERS:
823#   this  -> Instance of editor
824#   name1, name2, op -> see above
825#
826#/////////////////////////////////////////////////////////////////////////////
827  upvar \#0 ${this}::data data
828
829  if {$data(nameFile) != ""} {
830    set data(labelWindow) $data(nameFile)
831  } else  {
832    set data(labelWindow) "untitled.tol"
833  }
834  $data(f) configure -title "$data(labelWindow) - [mc [list Bayes Editor]]"
835}
836
837
838#/////////////////////////////////////////////////////////////////////////////
839  proc ::Editor::TraceSaved {this name1 name2 op} {
840#
841# PURPOSE: Sets saved/not saved info in status bar each time var 'isSaved'
842#          changes.
843#
844# PARAMETERS:
845#   this  -> Instance of editor
846#   name1, name2, op -> see above
847#
848#/////////////////////////////////////////////////////////////////////////////
849  upvar \#0 ${this}::data data
850
851  if $data(isSaved) {
852    $data(sb,modi) configure -text [mc "Saved"] -relief groove
853    #$data(tb,save) configure -state disabled
854  } else  {
855    $data(sb,modi) configure -text [mc "Not Saved"] -relief raised
856    #$data(tb,save) configure -state normal
857  }
858}
859
860
861#/////////////////////////////////////////////////////////////////////////////
862  proc ::Editor::TraceSelected {this name1 name2 op} {
863#
864# PURPOSE: Sets ??? each time var 'selected' changes.
865#
866# PARAMETERS:
867#   this  -> Instance of editor
868#   name1, name2, op -> see above
869#
870#/////////////////////////////////////////////////////////////////////////////
871  upvar \#0 ${this}::data data
872  if $data(selected) {
873#    $data(tb,cut) configure -state normal
874#    $data(tb,copy) configure -state normal
875  } else  {
876#    $data(tb,cut)  configure -state disabled
877#    $data(tb,copy) configure -state disabled
878  }
879}
880
881
882#/////////////////////////////////////////////////////////////////////////////
883  proc ::Editor::TraceCompiled {this name1 name2 op} {
884#
885# PURPOSE: Sets compiled/not compiled info in status bar each time var
886#          'isCompiled' changes.
887#
888# PARAMETERS:
889#   this  -> Instance of editor
890#   name1, name2, op -> see above
891#
892#/////////////////////////////////////////////////////////////////////////////
893  upvar \#0 ${this}::data data
894
895  if {$data(isCompiled) eq 2} {
896    $data(sb,comp) configure -text [mc "Compiling"] -relief solid
897    $data(tb,savecom) configure -state disabled
898    $data(menu) entryconfigure 0 -state disabled
899  } else  {
900    $data(tb,savecom) configure -state normal
901    $data(menu) entryconfigure 0 -state normal
902    if {$data(isCompiled) eq 1} {
903      $data(sb,comp) configure -text [mc "Compiled"] -relief groove
904    } else  {
905      $data(sb,comp) configure -text [mc "Not Compiled"] -relief raised
906    }
907  }
908}
909
910
911
912#/////////////////////////////////////////////////////////////////////////////
913  proc ::Editor::TraceUndo {this name1 name2 op} {
914#
915# PURPOSE: Enables/disables undo button in toolbar each time value of undo
916#          index changes. (see supertext.tcl)
917#
918# PARAMETERS:
919#   this  -> Instance of editor
920#   name1, name2, op -> see above
921#
922#/////////////////////////////////////////////////////////////////////////////
923  upvar \#0 ${this}::data data
924  #if {[llength $Supertext::undo($data(txt,supertext))]}
925  if { $::Supertext::undoIndex($data(txt,supertext)) != -1 } {
926#    $data(tb,undo) configure -state normal
927  } else {
928#    $data(tb,undo) configure -state disabled
929  }
930}
931
932
933
934proc ::Editor::GetText {this} {
935  upvar \#0 ${this}::data data
936  return $data(txt,ctext)
937}
938
939proc ::Editor::PreProc {this args} {
940  upvar \#0 ${this}::data data
941  set command [lindex $args 0]
942  switch $command {
943    insert {
944      set data(isSaved) 0
945      set data(position) [Supertext::text_index $data(txt) insert]
946    }
947    delete {
948      set data(isSaved) 0
949      set data(position) [Supertext::text_index $data(txt) insert]
950    }
951    tag {
952      if {[string equal [lindex $args 2] "sel"]} {
953        switch [lindex $args 1] {
954          add     {set data(selected) 1}
955          remove  {set data(selected) 0}
956        }
957      }
958    }
959    mark {
960      if {[string equal [lindex $args 2] "anchor"]} {
961        set data(position) [Supertext::text_index $data(txt) insert]
962      }
963    }
964    see {
965      set data(position) [Supertext::text_index $data(txt) insert]
966    }
967    undo {
968      set data(position) [Supertext::text_index $data(txt) insert]
969    }
970  }
971  #Tolcon_Trace $args
972}
973
974
975#/////////////////////////////////////////////////////////////////////////////
976# File management commands (new, open, save, save as...)
977#/////////////////////////////////////////////////////////////////////////////
978
979#/////////////////////////////////////////////////////////////////////////////
980  proc ::Editor::CmdNew {this} {
981#
982# PURPOSE: Cleans editor to edit a new white document
983#
984# PARAMETERS:
985#   this  -> Instance of editor
986#
987#/////////////////////////////////////////////////////////////////////////////
988  upvar \#0 ${this}::data data
989
990  if [string equal [CheckOpen $this] "cancel"] return
991  $data(txt) delete 1.0 end
992  InitState $this new
993  InsertFileHeader $this
994}
995
996
997#/////////////////////////////////////////////////////////////////////////////
998  proc ::Editor::UpdateListEdited {path} {
999#
1000# PURPOSE: Updates list of last edited files adding a new file path.
1001#
1002# PARAMETERS:
1003#   path  -> path of the last edited file
1004#
1005#/////////////////////////////////////////////////////////////////////////////
1006  variable options
1007  # guardamos el ultimo directorio abierto
1008  set options(lastDir) [file dirname $path]
1009  if { [set idx [lsearch $options(edited) $path]] == -1 } {
1010    set options(edited) [linsert $options(edited) 0 $path]
1011  } else {
1012    set ll ""
1013    lappend ll $path
1014    set i 0
1015    foreach f $options(edited) {
1016      if  {$i != $idx} {
1017        lappend ll $f
1018      }
1019      incr i
1020    }
1021    set options(edited) $ll
1022  }
1023  set options(edited) [lrange $options(edited) 0 [expr $options(numEdited)-1]] 
1024}
1025
1026
1027#/////////////////////////////////////////////////////////////////////////////
1028  proc ::Editor::CmdOpen {{this ""}} {
1029#
1030# PURPOSE: Asks for a file path and if it's given opens it into the editor
1031#          window.
1032#
1033# PARAMETERS:
1034#   this -> Instance of editor
1035#
1036#/////////////////////////////////////////////////////////////////////////////
1037  variable options
1038  variable typelist
1039  variable defExt
1040
1041  if {$this == ""} {
1042    set parent .
1043  } else  {
1044    upvar \#0 ${this}::data data
1045    set parent $data(txt)
1046    if [string equal [CheckOpen $this] "cancel"] return
1047  }
1048
1049  set path [tk_getOpenFile -title [mc "Open"] \
1050              -parent $parent -initialdir $options(lastDir) \
1051              -defaultextension $defExt -filetypes $typelist]
1052
1053  if {$path != ""} {
1054    # abrimos solo si no esta ya abierto
1055    foreach ins [namespace children ::Editor] {
1056      upvar \#0 ${ins}::data data
1057      if {[string equal $data(nameFile) $path]} {
1058        $data(f) raise
1059                set resp [tk_messageBox -type ok -icon warning \
1060                  -message [mc "The file is allready opened!"] ]
1061        return
1062      }
1063    }
1064    if {$this == ""} {
1065      set this [New $path]
1066    }
1067    GetFromFile $this $path
1068  }
1069}
1070
1071
1072#/////////////////////////////////////////////////////////////////////////////
1073  proc ::Editor::GetFromFile {this path {run 0}} {
1074#
1075# PURPOSE: Loads a file into the editor window.
1076#
1077# PARAMETERS:
1078#   this -> Instance of editor
1079#   path -> file's path
1080#
1081#/////////////////////////////////////////////////////////////////////////////
1082  upvar \#0 ${this}::data data
1083
1084  $data(txt) delete 1.0 end
1085  if [::BayesText::Open $data(txt) $path] {
1086    set data(nameFile) $path
1087    set data(mTime) [file mtime $path]
1088    UpdateListEdited $path
1089    # Guardamos en el ini por si se cae el interface para que guarde
1090    # la lista de archivos recientes
1091    WriteIni $this
1092  } else {
1093    set data(nameFile) ""
1094  }
1095  $data(f) raise
1096  InitState $this open
1097  tk::TextSetCursor $data(txt) 1.0
1098  if { $run } {
1099    CmdSaveCompile $this
1100  }
1101}
1102
1103#/////////////////////////////////////////////////////////////////////////////
1104  proc ::Editor::CheckAll {} {
1105#
1106# PURPOSE: Checks for files opened if anyone has changed and asks for saving.
1107#
1108#/////////////////////////////////////////////////////////////////////////////
1109  foreach ins [namespace children ::Editor] {
1110    if {[CheckOpen $ins] eq "cancel"} {
1111      return cancel
1112    }
1113  }
1114}
1115
1116#/////////////////////////////////////////////////////////////////////////////
1117  proc ::Editor::CheckOpen {this {type "yesnocancel"}} {
1118#
1119# PURPOSE: Checks if a file has changed and asks for saving.
1120#
1121# PARAMETERS:
1122#   this -> Instance of editor
1123#   type -> type of messageBox to ask. (yesnocancel by default)
1124#
1125# RETURN: Returns user answer for saving.
1126#
1127#/////////////////////////////////////////////////////////////////////////////
1128  upvar \#0 ${this}::data data
1129   
1130  # comprobamos si necesita ser guardado
1131  if { !$data(isSaved)} {
1132    if {$data(nameFile) != ""} {
1133      set name $data(nameFile)
1134    } else  {
1135      set name "untitled.tol"
1136    }
1137    # preguntamos por conformidad
1138    set parent $data(txt)
1139    set rq [tk_messageBox -type $type -icon warning -title [mc "Warning"]\
1140            -parent $parent -message "[mc "File %1\$s has changed!" $name].\n\
1141            [mc "Do you want to save changes?"]"]
1142    switch -exact $rq {
1143      yes {
1144        if {$data(nameFile) != "" } {
1145          FileSave $this $data(nameFile)
1146          set data(mTime) [file mtime $data(nameFile)]
1147        } else {
1148          CmdSaveAs $this $data(nameFile)
1149          set data(mTime) [file mtime $data(nameFile)]
1150        }
1151      }
1152      cancel {return cancel}
1153      default {return ok}
1154    }
1155  }
1156  return ok
1157}
1158
1159
1160#/////////////////////////////////////////////////////////////////////////////
1161  proc ::Editor::CmdSave {this} {
1162#
1163# PURPOSE: Saves text actually opened in the editor. If doesn't have a name,
1164#          asks for ti (CmdSaveAs).
1165#
1166# PARAMETERS:
1167#   this -> Instance of editor
1168#
1169# RETURN: Returns 1 if file has been saved correctly or 0 if not.
1170#
1171#/////////////////////////////////////////////////////////////////////////////
1172  upvar \#0 ${this}::data data
1173
1174  if {$data(nameFile) == ""} {
1175    set ok [CmdSaveAs $this]
1176  } else  {
1177    if { $data(mTime) eq [file mtime $data(nameFile)] } {
1178      set ok [FileSave $this $data(nameFile)]
1179      set data(mTime) [file mtime $data(nameFile)]
1180    } else {
1181      set parent $data(txt)
1182      set msg "[mc File] $data(nameFile) [mc {has been changed externally!}] \
1183               \n[mc {Do you want to rewrite it and save new changes?}]"
1184      set rq [tk_messageBox -type okcancel -icon warning -title [mc "Warning"]\
1185            -parent $parent -message $msg]
1186      set ok -1
1187      switch -exact $rq {
1188        ok {
1189          set ok [FileSave $this $data(nameFile)]
1190          # updates the modification time
1191          set data(mTime) [file mtime $data(nameFile)]
1192        }
1193      }
1194    }
1195  }
1196  return $ok
1197}
1198
1199
1200#/////////////////////////////////////////////////////////////////////////////
1201  proc ::Editor::CmdSaveAs {this {nf ""}} {
1202#
1203# PURPOSE: Saves text actually opened in editor asking for the user to select
1204#          a file to save it.
1205#
1206# PARAMETERS:
1207#   this -> Instance of editor
1208#   nf   -> name of file proposed
1209#
1210# RETURN: Returns 1 if file has been saved correctly or 0 if not.
1211#
1212#/////////////////////////////////////////////////////////////////////////////
1213  variable options
1214  variable typelist
1215  variable defExt
1216  upvar \#0 ${this}::data data
1217   
1218  if {$nf == ""} {
1219    set dir $options(lastDir)
1220    set fil ""     
1221  } else  {
1222    set dir "[file dirname $nf]"
1223    set fil "[file tail $nf]"   
1224  }
1225  set path [tk_getSaveFile -title [mc "Save as"] -initialdir $dir \
1226       -initialfile $fil -parent $data(txt) \
1227       -defaultextension $defExt -filetypes $typelist]
1228  if {![string equal $path ""] } {
1229    set ok [FileSave $this $path]
1230    set data(mTime) [file mtime $data(nameFile)]
1231  } else {
1232    set ok 0
1233  }
1234  return $ok
1235}
1236
1237
1238#/////////////////////////////////////////////////////////////////////////////
1239  proc ::Editor::FileSave { this path } {
1240#
1241# PURPOSE: Saves text actually opened in editor in a text file.
1242#
1243# PARAMETERS:
1244#   this -> Instance of editor
1245#   path -> name of file
1246#
1247# RETURN: Returns 1 if file has been saved correctly or 0 if not.
1248#
1249#/////////////////////////////////////////////////////////////////////////////
1250  variable options
1251  upvar \#0 ${this}::data data
1252
1253  if [::BayesText::Save $data(txt) $path] {
1254    set data(nameFile) $path
1255    InitState $this save
1256    # guardamos el ultimo directorio utilizado
1257    set options(lastDir) [file dirname $path]
1258    UpdateListEdited $path
1259    set ok 1
1260  } else  {
1261    set ok 0
1262  }
1263  return $ok
1264}
1265
1266#/////////////////////////////////////////////////////////////////////////////
1267  proc ::Editor::CmdTkcvs { this mode} {
1268#
1269# PURPOSE: Execute CVS utilities
1270#
1271# PARAMETERS:
1272#   this -> Instance of editor
1273#   mode -> type of execution (0 -> tkCvs, 1 -> tkdiff)
1274#
1275#/////////////////////////////////////////////////////////////////////////////
1276  global toltk_bin
1277  global tkcvs_library
1278 
1279  variable options
1280  upvar \#0 ${this}::data data
1281 
1282  if {$mode == 0} {
1283    set cmd "[file join $toltk_bin wish84.exe] [file join $tkcvs_library tkcvs.tcl]"
1284    #exec c:/TclTk/bin/wish84.exe c:/TclTk/bin/tkcvs.tcl -dir $options(lastDir) &
1285    exec $cmd -dir $options(lastDir) &
1286  } else {
1287    set cmd "[file join $toltk_bin wish84.exe] [file join $tkcvs_library tkdiff.tcl]"
1288    #exec c:/TclTk/bin/wish84.exe c:/TclTk/bin/tkdiff.tcl $data(nameFile) &
1289    exec $cmd $data(nameFile) &
1290  }
1291
1292 
1293}
1294
1295#/////////////////////////////////////////////////////////////////////////////
1296# Comandos de edición (deshacer, cortar, copiar, pegar, buscar, remplazar,...)
1297#/////////////////////////////////////////////////////////////////////////////
1298proc ::Editor::CmdUndo {this} {
1299  upvar \#0 ${this}::data data
1300  $data(txt) undo
1301}
1302
1303proc ::Editor::CmdRedo {this} {
1304  upvar \#0 ${this}::data data
1305#  $data(txt) redo
1306  Tolcon_Trace "---------------------------"
1307}
1308
1309proc ::Editor::CmdCut {this} {
1310  upvar \#0 ${this}::data data
1311  ::BayesText::Cut $data(txt)
1312}
1313
1314proc ::Editor::CmdCopy {this} {
1315  upvar \#0 ${this}::data data
1316  ::BayesText::Copy $data(txt)
1317}
1318
1319proc ::Editor::CmdPaste {this} {
1320  upvar \#0 ${this}::data data
1321  ::BayesText::Paste $data(txt)
1322}
1323
1324proc ::Editor::CmdSelectAll {this} {
1325  upvar \#0 ${this}::data data
1326  ::BayesText::SelectAll $data(txt)
1327}
1328
1329proc ::Editor::CmdHelpEditor {this} {
1330    upvar \#0 ${this}::data data
1331    ShowHelp Tb4Eda
1332}
1333
1334proc ::Editor::CmdFind {this} {
1335  upvar \#0 ${this}::data data
1336  ::BayesText::FindShow $data(txt,ctext)
1337}
1338
1339proc ::Editor::CmdSearch {this} {
1340  upvar \#0 ${this}::data data
1341  :::BayesText::SearchShow  $data(txt)
1342}
1343
1344proc ::Editor::CmdFindNext {this {txt ""}} {
1345  upvar \#0 ${this}::data data
1346  eval ::BayesText::FindShow $data(txt,ctext) 1 {$txt}
1347}
1348
1349proc ::Editor::CmdReplace {this} {
1350  upvar \#0 ${this}::data data
1351  ::BayesText::ReplaceShow $data(txt,ctext)
1352}
1353
1354proc ::Editor::CmdIdent {this} {
1355  upvar \#0 ${this}::data data
1356  variable options
1357  ::BayesText::Ident $data(txt,ctext) $options(charsIdent)
1358}
1359
1360proc ::Editor::CmdUnIdent {this} {
1361  upvar \#0 ${this}::data data
1362  variable options
1363  ::BayesText::UnIdent $data(txt,ctext) $options(charsIdent)
1364}
1365
1366
1367#/////////////////////////////////////////////////////////////////////////////
1368# Comandos
1369#/////////////////////////////////////////////////////////////////////////////
1370proc ::Editor::CmdFont {this} {
1371  variable options
1372  global toltk_options
1373  upvar \#0 ${this}::data data
1374  set fnt [::BayesText::FontChange $data(txt)]
1375  if {$fnt != ""} {
1376    set options(font) $fnt
1377    font configure ctfnBold   -family [lindex $fnt 0] -size [lindex $fnt 1]
1378    font configure ctfnNormal -family [lindex $fnt 0] -size [lindex $fnt 1]
1379    UpdateMarkPos $this [winfo height $data(txt)]
1380  }
1381}
1382
1383proc ::Editor::CmdPrint {this} {
1384  upvar \#0 ${this}::data data
1385  global tcl_platform
1386  if { [string equal $tcl_platform(platform) "windows"] } {
1387    #int PrintCmd(ClientData clientData, Tcl_Interp *interp, int argc, char **argv)
1388#    printer open
1389#    printer styledialog
1390#    printer jobdialog
1391#    puts "print from [printer getattr firstpage] to [printer getattr lastpage]"
1392#    printer opendoc
1393#    printer openpage
1394#    printer test   ; # funcion que usa para imprimir
1395#    printer text [$data(txt) get 1.0 end]
1396#    printer closepage
1397#    printer closedoc
1398#    printer close
1399  }
1400}
1401
1402proc ::Editor::CmdSaveCompile {this} {
1403  upvar \#0 ${this}::data data
1404
1405  #Si se está compilando no hago nada
1406  if {$data(isCompiled) eq 2} { return }
1407  set ok [CmdSave $this]
1408  if {$ok} {
1409    CmdCompileFile $this
1410  }
1411}
1412
1413#/////////////////////////////////////////////////////////////////////////////
1414proc ::Editor::CmdCompileFile {this} {
1415#/////////////////////////////////////////////////////////////////////////////
1416  upvar \#0 ${this}::data data
1417  #Si se está compilando no hago nada
1418  if {$data(isCompiled) eq 2} { return }
1419  $data(tb,balloon) configure -state disabled
1420  #set check [::BayesText::TolFileSyntaxCheck $data(nameFile)]
1421  set check 1
1422  if {$check} {
1423    set data(isCompiled) 2
1424    ::TolConsole::Include $data(nameFile)
1425    set data(isCompiled) 1
1426   
1427    #pedro-start
1428    # Mapear contenido de texto de la instancia y generar ayudas dinamicas
1429    # Puede tomar entre 5 y 10 segundos
1430    #::Editor::VariableMap $this
1431    set data(balloon) 1
1432    ::Editor::CmdBalloon $this
1433    update idletasks
1434    #pedro-fin
1435   
1436  } else  {
1437    # hay errores
1438    tk_messageBox -type ok -icon warning -title [mc Editor] -parent $data(txt) \
1439            -message "[mc {Syntax errors in file}]\n\
1440                      [mc {Look over output window}]"
1441  }
1442}
1443
1444#pedro-start
1445#/////////////////////////////////////////////////////////////////////////////
1446proc ::Editor::wordindexes {s} {
1447# PURPOSE: Divide un texto en palabras, devuelve los indices de inicio y final de
1448#          cada palabra.
1449#          Subtract whole words from a paragraph, returns a pair of index values
1450#          indicating where the word starts and where it ends.
1451#
1452# ARGS:    user defined text widget
1453#/////////////////////////////////////////////////////////////////////////////
1454    set i 0
1455    set res {}
1456    foreach c [split $s ""] {
1457        if {$c!=" " && $i==[string wordstart $s $i] && [regexp {[A-Za-z]} $c]} {
1458            lappend res $i [string wordend $s $i]
1459        }
1460        incr i
1461    }
1462    set res
1463 }
1464
1465#/////////////////////////////////////////////////////////////////////////////
1466proc ::Editor::VariableMap {this} {
1467# PURPOSE: Creates a tag inside the editor instance for each word in the tol text
1468#          excluding comment lines, virtually fragmenting the editor window in
1469#          about 6000 - 15000 pieces, depends on the amount of words.
1470#          Bind two mouse events to each tag created using  <Enter> and <Leave>,
1471#          this way we call the process BalloonHlp to display the help text.
1472#/////////////////////////////////////////////////////////////////////////////
1473#          Creamos un tag por cada palabra que se encuentre dentro del texto tol
1474#          excluyendo las lineas comentadas. A cada rango encontrado se le
1475#          hace un Bind a dos eventos del raton; <enter> y <leave> para entonces
1476#          llamar a BalloonHlp y mostrar la ayuda.
1477#
1478# ARGS:    Instance of Editor / Instancia del Editor
1479#
1480#
1481# TODO:   1) Tol is marvelous, did you know you can actually create 2 variables
1482#          with identical names differing only in the grammar type?.. example..
1483#          Real a1 = 2;
1484#          Set  a1 = SetOfText("","");
1485#          (This will create 2 separate variables with the same name.. amazing huh?)
1486#          This is PERFECLTY possible in our amazing language, wich SUCKS for
1487#          the purpuse of this procedure... that is, because analyzed text is
1488#          arbitrary. With no reading rules, i can't really determine the
1489#          variable type before calling BalloonHlp. If two variables happen to
1490#          have the same name, the ::TclInfoVar loop function will catch the info
1491#          on the last valid grammar type in the checklist (See Editor::BalloonHlp
1492#          for more details).
1493#         
1494#          The idea would be to determine the grammar type before calling BalloonHlp.
1495#          I ain't genious enought to take it that far out.... yet. :-D
1496#
1497#         2) I managed to exclude comment lines from being parsed as valid tags.
1498#            If you can manage to exclude text or quote delimited expressions
1499#            from the loop, you're my geek... and offcourse, you defenetly have
1500#            more free time than me. Good Luck.
1501#/////////////////////////////////////////////////////////////////////////////
1502  upvar \#0 ${this}::data data
1503  # Luego de compilar, obtengo la lista de variables creadas.
1504  # "const" sera lista de palabras que nunca seran variables
1505  set const [list Anything Code Complex CDate CTimeSet Date Matrix Polyn \
1506                  Ration Real Serie Set Special Struct Text TimeSet ]
1507   
1508  #Obtener lista de variables y funciones ya compiladas desde editor
1509  #controla el numero de linea mientras recorre el txt del editor
1510  set linenum 0
1511   
1512  foreach line [split [$data(txt) get 1.0 end-1c] \n] {
1513    incr linenum 1
1514    if { [string range $line 0 1] != "//" && [regexp "//" $line] == "0" } {
1515      foreach {from to} [::Editor::wordindexes $line] {
1516        #guardar palabra e indices
1517        set word [string range $line $from [expr $to-1]]
1518        set verif [lsearch -exact $const "$word"]
1519        if  { $verif == "-1" } {
1520          #solo se crea tag si no pertenece a ningun nombre de variable
1521          set num [expr rand()]
1522          #numero aleatorio para complementar nombres de tags repetidos
1523          set to [expr $to-1]
1524          #crear tag con nombre y rango dentro del text
1525          $data(txt) tag add "$word$num" "$linenum.$from" "$linenum.$to"
1526          #Crear bind a eventos para cada tag creado
1527          $data(txt) tag bind "$word$num" <Enter> "after 1500 [list ::Editor::BalloonHlp $this $data(txt) $word]"
1528          $data(txt) tag bind "$word$num" <Leave> "destroy $data(txt).balloon"
1529          #Subrayo las variables Definidas
1530          #if { [llength [::TclInfoVar "Anything" "$word" ]] > 0 } {
1531          #$data(txt) tag configure "$word$num" -underline 1 }
1532          update idletasks
1533        }
1534      }
1535    }
1536  }
1537  # - fin
1538}
1539
1540
1541#/////////////////////////////////////////////////////////////////////////////
1542proc ::Editor::CmdCompile {this} {
1543#/////////////////////////////////////////////////////////////////////////////
1544  upvar \#0 ${this}::data data
1545
1546  set idxs [$data(txt) tag ranges sel]
1547  Tolcon_Trace "idxs = $idxs"
1548  # Si hay seleccion evaluo texto seleccionado, sino incluyo el archivo
1549  if [llength $idxs] {
1550    ::TolConsole::EvalExpr [$data(txt) get [lindex $idxs 0] [lindex $idxs 1]]
1551  } else  {
1552    CmdSaveCompile $this
1553  }
1554}
1555
1556
1557#/////////////////////////////////////////////////////////////////////////////
1558proc ::Editor::CmdDecompile {this} {
1559#///////////////////////////////////////////////////////////////////////////// 
1560  upvar \#0 ${this}::data data
1561  if {$data(isCompiled) eq 1} {
1562    ::TolInspector::DecompileFile $data(nameFile)
1563  }
1564}
1565
1566
1567#/////////////////////////////////////////////////////////////////////////////
1568proc ::Editor::CmdSyntaxCheck {this} {
1569#///////////////////////////////////////////////////////////////////////////// 
1570  upvar \#0 ${this}::data data
1571  ::BayesText::TolSyntaxCheck $data(txt)
1572}
1573
1574
1575#/////////////////////////////////////////////////////////////////////////////
1576proc ::Editor::CmdRefresh {this} {
1577#///////////////////////////////////////////////////////////////////////////// 
1578  upvar \#0 ${this}::data data
1579
1580  foreach tag [$data(txt) tag names] {
1581    $data(txt) tag remove $tag 1.0 end
1582  }
1583  update idletasks
1584  $data(txt) highlight 1.0 end
1585}
1586
1587
1588#/////////////////////////////////////////////////////////////////////////////
1589proc ::Editor::CmdRightMargin {this} {
1590#///////////////////////////////////////////////////////////////////////////// 
1591  upvar \#0 ${this}::data data
1592  UpdateMarkPos $this [winfo height $data(txt)]
1593}
1594
1595
1596#/////////////////////////////////////////////////////////////////////////////
1597proc ::Editor::CmdOptions {this} {
1598#///////////////////////////////////////////////////////////////////////////// 
1599  upvar \#0 ${this}::data data
1600  OptionsCreate $this $data(txt)
1601}
1602
1603
1604#/////////////////////////////////////////////////////////////////////////////
1605proc ::Editor::CmdBalloon {this} {
1606# PURPOSE: Balloon Control
1607#/////////////////////////////////////////////////////////////////////////////
1608  upvar \#0 ${this}::data data
1609 
1610  if {  $data(balloon) != 1 } {
1611    #Reconfigure
1612    $data(tb,balloon) configure -state disabled
1613     #Recalculate values
1614     ::Editor::VariableMap $this
1615     #flag
1616     set data(balloon) 1
1617     #reconfigure
1618     $data(tb,balloon) configure -image [::Bitmap::get "balloon_enable"]
1619    $data(tb,balloon) configure -state normal
1620  } else {
1621     #destroy tag & binds
1622     $data(tb,balloon) configure -state disabled
1623       set tagnames [$data(txt) tag names]
1624       set limit [llength $tagnames]
1625       for {set x 6} {$x < $limit} {incr x} {
1626        $data(txt) tag delete [lindex $tagnames $x]
1627        #puts "tag eliminada"
1628       }
1629       set data(balloon) 0
1630       $data(tb,balloon) configure -image [::Bitmap::get "balloon_disable"]
1631      $data(tb,balloon) configure -state normal
1632  }
1633}
1634
1635
1636#/////////////////////////////////////////////////////////////////////////////
1637proc ::Editor::OptionsCreate {this path} {
1638#///////////////////////////////////////////////////////////////////////////// 
1639  set dialog [Dialog $path.d -title [mc "Editor Options"]\
1640            -modal local -parent $path]
1641  wm resizable $dialog 0 0
1642  wm protocol $dialog WM_DELETE_WINDOW [list ::Editor::OptionsDestroy $this $dialog]
1643  set w [$dialog getframe]
1644  set w_tabset [::blt::tabset $w.ts -relief flat -highlightthickness 0\
1645            -bd 0 -outerpad 0 -tier 2 -slant right -textside right ]
1646   
1647  #insertar tabset
1648  $w_tabset insert end Headers Others
1649  set f1 [frame $w_tabset.f1]
1650  set f2 [frame $w_tabset.f2]
1651   
1652   
1653  $w_tabset tab configure "Headers" -text [mc "Headers"] -window $f1\
1654          -fill both -padx 0 -selectbackground \#d9d9d9 -bg gray75
1655  $w_tabset tab configure "Others" -text [mc "Others"] -window $f2\
1656          -fill both -padx 0 -selectbackground \#d9d9d9 -bg gray75
1657   
1658  OptionsGet $this
1659  OptionsCreateHeaders $this $f1
1660  OptionsCreateOthers  $this $f2
1661   
1662  OptionsCheck $this
1663   
1664  set w_bbox \
1665    [ButtonBox $w.bb -orient horizontal -spacing 10 -padx 0 -pady 0 \
1666     -homogeneous false]
1667  $w_bbox add -text [mc "Accept"] -relief link \
1668    -helptext [mc "OK"] \
1669    -image [::Bitmap::get accept] -compound left -padx 5 -pady 1 \
1670    -command [list ::Editor::OptionsOK $this $dialog]
1671  $w_bbox add -text [mc "Cancel"] -relief link \
1672    -helptext [mc "Cancel"]\
1673    -image [::Bitmap::get cancelx] -compound left -padx 5 -pady 1 \
1674    -command [list ::Editor::OptionsDestroy $this $dialog]
1675  $w_bbox add -text [mc "Apply"] -relief link \
1676    -helptext [mc "Apply"]\
1677    -image [::Bitmap::get apply] -compound left -padx 5 -pady 1 \
1678    -command [list ::Editor::OptionsDestroy $this $dialog]
1679 
1680  pack $w_bbox   -fill x -expand false -side bottom
1681  pack $w_tabset -fill both -expand true
1682 
1683  bind $dialog <F1> "ShowHelp Tb4Eda ; break"   
1684  $dialog draw
1685}
1686
1687
1688#/////////////////////////////////////////////////////////////////////////////
1689proc ::Editor::OptionsCreateHeaders {this w} {
1690#///////////////////////////////////////////////////////////////////////////// 
1691  variable tmpOpt
1692   
1693  TitleFrame $w.tf1 -text [mc "Files of headers"]
1694  set f1 [$w.tf1 getframe]
1695   
1696  checkbutton $f1.chFileH -text [mc "Insert header in new files"]\
1697            -variable ::Editor::tmpOpt(var,chFileH)\
1698            -command [list ::Editor::OptionsCheckHeaderFileInsert $this]
1699  label  $f1.lFileH -text [mc "Files Header"]
1700  set tmpOpt(widget,eFileH) [entry  $f1.eFileH -width 50\
1701                  -textvariable ::Editor::tmpOpt(var,fileH)]
1702  set tmpOpt(widget,bFileH) [::Objects::ChooseFileCreate ::Editor::tmpOpt(var,fileH) $f1.bFileH]
1703
1704  label  $f1.lFuncH -text [mc "Functions Header"]
1705  entry  $f1.eFuncH -width 50 -textvariable ::Editor::tmpOpt(var,funcH)
1706  ::Objects::ChooseFileCreate ::Editor::tmpOpt(var,funcH) $f1.bFuncH
1707   
1708   
1709  frame $f1.f -width 25
1710   
1711  grid $f1.f $f1.chFileH -          -          -sticky nw -padx 2
1712  grid ^     $f1.lFileH  $f1.eFileH $f1.bFileH -sticky nw -padx 2
1713  grid ^     $f1.lFuncH  $f1.eFuncH $f1.bFuncH -sticky nw -padx 2
1714  grid rowconfigure    $f1 0 -weight 1
1715  grid columnconfigure $f1 3 -weight 1
1716   
1717  grid $w.tf1 -sticky news -padx 2
1718   
1719  grid rowconfigure    $w 1 -weight 1
1720  grid rowconfigure    $w 2 -weight 2
1721  grid columnconfigure $w 0 -weight 1   
1722}
1723
1724
1725#/////////////////////////////////////////////////////////////////////////////
1726proc ::Editor::OptionsCreateOthers {this w} {
1727#///////////////////////////////////////////////////////////////////////////// 
1728  variable tmpOpt
1729   
1730  TitleFrame $w.tf1 -text [mc "General Options"]
1731  set f1 [$w.tf1 getframe]
1732   
1733  checkbutton $f1.chEdited -text [mc "Files edited recently"]\
1734          -variable ::Editor::tmpOpt(var,chEdited)\
1735          -command [list ::Editor::OptionsCheckEdited $this]
1736   
1737  set tmpOpt(widget,edited) [SpinBox $f1.sbEdited -justify right -width 4 \
1738          -editable 0 -range {0 40} \
1739          -textvariable ::Editor::tmpOpt(var,numEdited)]
1740  label $f1.lFiles -text [mc files]
1741 
1742  checkbutton $f1.chLine -text [mc "Show line at"] \
1743          -variable ::Editor::tmpOpt(var,chLine)
1744  SpinBox $f1.sbLinePos -justify right -width 4 \
1745          -editable 0 -range {20 100} \
1746          -textvariable ::Editor::tmpOpt(var,posLine)
1747  label $f1.lChars -text [mc characters]
1748 
1749  label $f1.lCharsIdent -text [mc "Characters to ident"]
1750  SpinBox $f1.sbCharsIdent -justify right -width 4 \
1751          -editable 0 -range {1 8} \
1752          -textvariable ::Editor::tmpOpt(var,charsIdent)
1753
1754  frame $f1.f -width 25
1755   
1756  grid $f1.f $f1.chEdited     $f1.sbEdited     $f1.lFiles -sticky nw -padx 2
1757  grid ^     $f1.chLine       $f1.sbLinePos    $f1.lChars -sticky nw -padx 2
1758  grid ^     $f1.lCharsIdent  $f1.sbCharsIdent         -sticky nw -padx 2
1759  grid rowconfigure    $f1 2 -weight 1
1760  grid columnconfigure $f1 3 -weight 1
1761   
1762  grid $w.tf1 -sticky news -padx 2
1763   
1764  grid rowconfigure    $w 1 -weight 1
1765  grid rowconfigure    $w 2 -weight 2
1766  grid columnconfigure $w 0 -weight 1
1767}
1768
1769
1770#/////////////////////////////////////////////////////////////////////////////
1771proc ::Editor::OptionsGet {this} {
1772#///////////////////////////////////////////////////////////////////////////// 
1773  variable options
1774  variable tmpOpt
1775  set tmpOpt(var,chEdited)   $options(chEdited)
1776  set tmpOpt(var,numEdited)  $options(numEdited)
1777  set tmpOpt(var,chFileH)    $options(chFileH)
1778  set tmpOpt(var,fileH)      $options(fileH)
1779  set tmpOpt(var,funcH)      $options(funcH)
1780  set tmpOpt(var,chLine)     $options(chLine)
1781  set tmpOpt(var,posLine)    $options(posLine)
1782  set tmpOpt(var,charsIdent) $options(charsIdent)
1783}
1784
1785
1786#/////////////////////////////////////////////////////////////////////////////
1787proc ::Editor::OptionsSet {this} {
1788#///////////////////////////////////////////////////////////////////////////// 
1789  variable options
1790  variable tmpOpt
1791   
1792  regsub -all var, [array names ::Editor::tmpOpt var,*] "" optNames
1793  #Tolcon_Trace "$optNames"
1794  foreach it $optNames {
1795    set options($it) $tmpOpt(var,$it)
1796  } 
1797}
1798
1799
1800#/////////////////////////////////////////////////////////////////////////////
1801proc ::Editor::OptionsCheck {this} {
1802#///////////////////////////////////////////////////////////////////////////// 
1803  OptionsCheckEdited           $this
1804  OptionsCheckHeaderFileInsert $this
1805}
1806
1807
1808#/////////////////////////////////////////////////////////////////////////////
1809proc ::Editor::OptionsCheckEdited {this} {
1810#///////////////////////////////////////////////////////////////////////////// 
1811  variable tmpOpt
1812  if {!$tmpOpt(var,chEdited)} {     
1813    $tmpOpt(widget,edited) configure -state disabled
1814  } else  {
1815    $tmpOpt(widget,edited) configure -state normal
1816  }
1817}
1818
1819
1820#/////////////////////////////////////////////////////////////////////////////
1821proc ::Editor::OptionsCheckHeaderFileInsert {this} {
1822#///////////////////////////////////////////////////////////////////////////// 
1823  variable tmpOpt
1824  if {!$tmpOpt(var,chFileH)} {
1825    $tmpOpt(widget,eFileH) configure -state disabled
1826    $tmpOpt(widget,bFileH) configure -state disabled
1827  } else  {
1828    $tmpOpt(widget,eFileH) configure -state normal
1829    $tmpOpt(widget,bFileH) configure -state normal
1830  }
1831}
1832
1833
1834#/////////////////////////////////////////////////////////////////////////////
1835proc ::Editor::OptionsDestroy {this dialog} {
1836#///////////////////////////////////////////////////////////////////////////// 
1837  variable tmpOpt
1838  array unset tmpOpt
1839  destroy $dialog
1840}
1841
1842
1843#/////////////////////////////////////////////////////////////////////////////
1844proc ::Editor::OptionsApply {this} {
1845#///////////////////////////////////////////////////////////////////////////// 
1846  OptionsSet $this
1847  CmdRightMargin $this
1848}
1849
1850
1851#/////////////////////////////////////////////////////////////////////////////
1852proc ::Editor::OptionsOK {this dialog} {
1853#///////////////////////////////////////////////////////////////////////////// 
1854  OptionsApply   $this
1855  OptionsDestroy $this $dialog
1856}
1857
1858
1859#/////////////////////////////////////////////////////////////////////////////
1860# INIFILE
1861#/////////////////////////////////////////////////////////////////////////////
1862
1863
1864#/////////////////////////////////////////////////////////////////////////////
1865proc ::Editor::ReadIni {} {
1866#///////////////////////////////////////////////////////////////////////////// 
1867  variable options
1868  global toltk_options
1869
1870  set rini ::iniFile::Read
1871  set options(chFileH)    [$rini Editor insertFileH 0]
1872  set options(fileH)      [$rini Editor fileH      ""]
1873  set options(funcH)      [$rini Editor funcH      ""]
1874  set options(chEdited)   [$rini Editor saveRecent  1]
1875  set options(numEdited)  [$rini Editor numRecent   8]
1876  set options(edited)     [$rini Editor recent      {}]
1877  set options(font)       [$rini Editor font     $toltk_options(fonts,Fixed)]
1878  set options(lastDir)    [$rini Editor lastDir  ""]
1879  set options(chLine)     [$rini Editor chLine    1]
1880  set options(posLine)    [$rini Editor posLine  78]
1881  set options(charsIdent) [$rini Editor charsIdent 2]
1882}
1883
1884
1885#/////////////////////////////////////////////////////////////////////////////
1886  proc ::Editor::WriteIni {this} {
1887#
1888# PURPOSE: Write common Editor options to .ini file
1889#
1890# PARAMETERS:
1891#   this  -> Instance of editor
1892#
1893#/////////////////////////////////////////////////////////////////////////////
1894  variable options
1895  upvar \#0 ${this}::data data
1896  set wini ::iniFile::Write
1897
1898  $wini Editor insertFileH  $options(chFileH)
1899  $wini Editor fileH        $options(fileH)
1900  $wini Editor funcH        $options(funcH)
1901  $wini Editor saveRecent   $options(chEdited)
1902  $wini Editor numRecent    $options(numEdited)
1903  $wini Editor recent       $options(edited)
1904  $wini Editor font         $options(font)
1905  $wini Editor lastDir      $options(lastDir)
1906  $wini Editor chLine       $options(chLine)
1907  $wini Editor posLine      $options(posLine)
1908  $wini Editor charsIdent   $options(charsIdent)
1909  ::iniFile::Flush
1910}
1911
1912::Editor::ReadIni
Note: See TracBrowser for help on using the repository browser.