source: tol/tolbase/lib/toltk/editor.tcl @ 817b775

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

merging from NameBlock/VMatrix branch

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

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