source: tol/tolbase/lib/toltk/editor.tcl @ 7b5e14e

1941-docker-image-to-testdevel
Last change on this file since 7b5e14e was 320d511, checked in by Jorge Pérez <josp.jorge@…>, 17 years ago

::Editor::InsertText

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

  • Property mode set to 100644
File size: 64.1 KB
RevLine 
[6d7779d]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
[320d511]931proc ::Editor::InsertText {this new_text {pos end} } {
932  upvar \#0 ${this}::data data
933  $data(txt) insert $pos $new_text
934}
[6d7779d]935
936proc ::Editor::GetText {this} {
937  upvar \#0 ${this}::data data
938  return $data(txt,ctext)
939}
940
941proc ::Editor::PreProc {this args} {
942  upvar \#0 ${this}::data data
943  set command [lindex $args 0]
944  switch $command {
945    insert {
946      set data(isSaved) 0
947      set data(position) [Supertext::text_index $data(txt) insert]
948    }
949    delete {
950      set data(isSaved) 0
951      set data(position) [Supertext::text_index $data(txt) insert]
952    }
953    tag {
954      if {[string equal [lindex $args 2] "sel"]} {
955        switch [lindex $args 1] {
956          add     {set data(selected) 1}
957          remove  {set data(selected) 0}
958        }
959      }
960    }
961    mark {
962      if {[string equal [lindex $args 2] "anchor"]} {
963        set data(position) [Supertext::text_index $data(txt) insert]
964      }
965    }
966    see {
967      set data(position) [Supertext::text_index $data(txt) insert]
968    }
969    undo {
970      set data(position) [Supertext::text_index $data(txt) insert]
971    }
972  }
973  #Tolcon_Trace $args
974}
975
976
977#/////////////////////////////////////////////////////////////////////////////
978# File management commands (new, open, save, save as...)
979#/////////////////////////////////////////////////////////////////////////////
980
981#/////////////////////////////////////////////////////////////////////////////
982  proc ::Editor::CmdNew {this} {
983#
984# PURPOSE: Cleans editor to edit a new white document
985#
986# PARAMETERS:
987#   this  -> Instance of editor
988#
989#/////////////////////////////////////////////////////////////////////////////
990  upvar \#0 ${this}::data data
991
992  if [string equal [CheckOpen $this] "cancel"] return
993  $data(txt) delete 1.0 end
994  InitState $this new
995  InsertFileHeader $this
996}
997
998
999#/////////////////////////////////////////////////////////////////////////////
1000  proc ::Editor::UpdateListEdited {path} {
1001#
1002# PURPOSE: Updates list of last edited files adding a new file path.
1003#
1004# PARAMETERS:
1005#   path  -> path of the last edited file
1006#
1007#/////////////////////////////////////////////////////////////////////////////
1008  variable options
1009  # guardamos el ultimo directorio abierto
1010  set options(lastDir) [file dirname $path]
1011  if { [set idx [lsearch $options(edited) $path]] == -1 } {
1012    set options(edited) [linsert $options(edited) 0 $path]
1013  } else {
1014    set ll ""
1015    lappend ll $path
1016    set i 0
1017    foreach f $options(edited) {
1018      if  {$i != $idx} {
1019        lappend ll $f
1020      }
1021      incr i
1022    }
1023    set options(edited) $ll
1024  }
1025  set options(edited) [lrange $options(edited) 0 [expr $options(numEdited)-1]] 
1026}
1027
1028
1029#/////////////////////////////////////////////////////////////////////////////
1030  proc ::Editor::CmdOpen {{this ""}} {
1031#
1032# PURPOSE: Asks for a file path and if it's given opens it into the editor
1033#          window.
1034#
1035# PARAMETERS:
1036#   this -> Instance of editor
1037#
1038#/////////////////////////////////////////////////////////////////////////////
1039  variable options
1040  variable typelist
1041  variable defExt
1042
1043  if {$this == ""} {
1044    set parent .
1045  } else  {
1046    upvar \#0 ${this}::data data
1047    set parent $data(txt)
1048    if [string equal [CheckOpen $this] "cancel"] return
1049  }
1050
1051  set path [tk_getOpenFile -title [mc "Open"] \
1052              -parent $parent -initialdir $options(lastDir) \
1053              -defaultextension $defExt -filetypes $typelist]
1054
1055  if {$path != ""} {
1056    # abrimos solo si no esta ya abierto
1057    foreach ins [namespace children ::Editor] {
1058      upvar \#0 ${ins}::data data
1059      if {[string equal $data(nameFile) $path]} {
1060        $data(f) raise
1061                set resp [tk_messageBox -type ok -icon warning \
1062                  -message [mc "The file is allready opened!"] ]
1063        return
1064      }
1065    }
1066    if {$this == ""} {
1067      set this [New $path]
1068    }
1069    GetFromFile $this $path
1070  }
1071}
1072
1073
1074#/////////////////////////////////////////////////////////////////////////////
1075  proc ::Editor::GetFromFile {this path {run 0}} {
1076#
1077# PURPOSE: Loads a file into the editor window.
1078#
1079# PARAMETERS:
1080#   this -> Instance of editor
1081#   path -> file's path
1082#
1083#/////////////////////////////////////////////////////////////////////////////
1084  upvar \#0 ${this}::data data
1085
1086  $data(txt) delete 1.0 end
1087  if [::BayesText::Open $data(txt) $path] {
1088    set data(nameFile) $path
1089    set data(mTime) [file mtime $path]
1090    UpdateListEdited $path
1091    # Guardamos en el ini por si se cae el interface para que guarde
1092    # la lista de archivos recientes
1093    WriteIni $this
1094  } else {
1095    set data(nameFile) ""
1096  }
1097  $data(f) raise
1098  InitState $this open
1099  tk::TextSetCursor $data(txt) 1.0
1100  if { $run } {
1101    CmdSaveCompile $this
1102  }
1103}
1104
1105#/////////////////////////////////////////////////////////////////////////////
1106  proc ::Editor::CheckAll {} {
1107#
1108# PURPOSE: Checks for files opened if anyone has changed and asks for saving.
1109#
1110#/////////////////////////////////////////////////////////////////////////////
1111  foreach ins [namespace children ::Editor] {
1112    if {[CheckOpen $ins] eq "cancel"} {
1113      return cancel
1114    }
1115  }
1116}
1117
1118#/////////////////////////////////////////////////////////////////////////////
1119  proc ::Editor::CheckOpen {this {type "yesnocancel"}} {
1120#
1121# PURPOSE: Checks if a file has changed and asks for saving.
1122#
1123# PARAMETERS:
1124#   this -> Instance of editor
1125#   type -> type of messageBox to ask. (yesnocancel by default)
1126#
1127# RETURN: Returns user answer for saving.
1128#
1129#/////////////////////////////////////////////////////////////////////////////
1130  upvar \#0 ${this}::data data
1131   
1132  # comprobamos si necesita ser guardado
1133  if { !$data(isSaved)} {
1134    if {$data(nameFile) != ""} {
1135      set name $data(nameFile)
1136    } else  {
1137      set name "untitled.tol"
1138    }
1139    # preguntamos por conformidad
1140    set parent $data(txt)
1141    set rq [tk_messageBox -type $type -icon warning -title [mc "Warning"]\
1142            -parent $parent -message "[mc "File %1\$s has changed!" $name].\n\
1143            [mc "Do you want to save changes?"]"]
1144    switch -exact $rq {
1145      yes {
1146        if {$data(nameFile) != "" } {
1147          FileSave $this $data(nameFile)
1148          set data(mTime) [file mtime $data(nameFile)]
1149        } else {
1150          CmdSaveAs $this $data(nameFile)
1151          set data(mTime) [file mtime $data(nameFile)]
1152        }
1153      }
1154      cancel {return cancel}
1155      default {return ok}
1156    }
1157  }
1158  return ok
1159}
1160
1161
1162#/////////////////////////////////////////////////////////////////////////////
1163  proc ::Editor::CmdSave {this} {
1164#
1165# PURPOSE: Saves text actually opened in the editor. If doesn't have a name,
1166#          asks for ti (CmdSaveAs).
1167#
1168# PARAMETERS:
1169#   this -> Instance of editor
1170#
1171# RETURN: Returns 1 if file has been saved correctly or 0 if not.
1172#
1173#/////////////////////////////////////////////////////////////////////////////
1174  upvar \#0 ${this}::data data
1175
1176  if {$data(nameFile) == ""} {
1177    set ok [CmdSaveAs $this]
1178  } else  {
1179    if { $data(mTime) eq [file mtime $data(nameFile)] } {
1180      set ok [FileSave $this $data(nameFile)]
1181      set data(mTime) [file mtime $data(nameFile)]
1182    } else {
1183      set parent $data(txt)
1184      set msg "[mc File] $data(nameFile) [mc {has been changed externally!}] \
1185               \n[mc {Do you want to rewrite it and save new changes?}]"
1186      set rq [tk_messageBox -type okcancel -icon warning -title [mc "Warning"]\
1187            -parent $parent -message $msg]
1188      set ok -1
1189      switch -exact $rq {
1190        ok {
1191          set ok [FileSave $this $data(nameFile)]
1192          # updates the modification time
1193          set data(mTime) [file mtime $data(nameFile)]
1194        }
1195      }
1196    }
1197  }
1198  return $ok
1199}
1200
1201
1202#/////////////////////////////////////////////////////////////////////////////
1203  proc ::Editor::CmdSaveAs {this {nf ""}} {
1204#
1205# PURPOSE: Saves text actually opened in editor asking for the user to select
1206#          a file to save it.
1207#
1208# PARAMETERS:
1209#   this -> Instance of editor
1210#   nf   -> name of file proposed
1211#
1212# RETURN: Returns 1 if file has been saved correctly or 0 if not.
1213#
1214#/////////////////////////////////////////////////////////////////////////////
1215  variable options
1216  variable typelist
1217  variable defExt
1218  upvar \#0 ${this}::data data
1219   
1220  if {$nf == ""} {
1221    set dir $options(lastDir)
1222    set fil ""     
1223  } else  {
1224    set dir "[file dirname $nf]"
1225    set fil "[file tail $nf]"   
1226  }
1227  set path [tk_getSaveFile -title [mc "Save as"] -initialdir $dir \
1228       -initialfile $fil -parent $data(txt) \
1229       -defaultextension $defExt -filetypes $typelist]
1230  if {![string equal $path ""] } {
1231    set ok [FileSave $this $path]
1232    set data(mTime) [file mtime $data(nameFile)]
1233  } else {
1234    set ok 0
1235  }
1236  return $ok
1237}
1238
1239
1240#/////////////////////////////////////////////////////////////////////////////
1241  proc ::Editor::FileSave { this path } {
1242#
1243# PURPOSE: Saves text actually opened in editor in a text file.
1244#
1245# PARAMETERS:
1246#   this -> Instance of editor
1247#   path -> name of file
1248#
1249# RETURN: Returns 1 if file has been saved correctly or 0 if not.
1250#
1251#/////////////////////////////////////////////////////////////////////////////
1252  variable options
1253  upvar \#0 ${this}::data data
1254
1255  if [::BayesText::Save $data(txt) $path] {
1256    set data(nameFile) $path
1257    InitState $this save
1258    # guardamos el ultimo directorio utilizado
1259    set options(lastDir) [file dirname $path]
1260    UpdateListEdited $path
1261    set ok 1
1262  } else  {
1263    set ok 0
1264  }
1265  return $ok
1266}
1267
1268#/////////////////////////////////////////////////////////////////////////////
1269  proc ::Editor::CmdTkcvs { this mode} {
1270#
1271# PURPOSE: Execute CVS utilities
1272#
1273# PARAMETERS:
1274#   this -> Instance of editor
1275#   mode -> type of execution (0 -> tkCvs, 1 -> tkdiff)
1276#
1277#/////////////////////////////////////////////////////////////////////////////
1278  global toltk_bin
1279  global tkcvs_library
1280 
1281  variable options
1282  upvar \#0 ${this}::data data
1283 
1284  if {$mode == 0} {
1285    set cmd "[file join $toltk_bin wish84.exe] [file join $tkcvs_library tkcvs.tcl]"
1286    #exec c:/TclTk/bin/wish84.exe c:/TclTk/bin/tkcvs.tcl -dir $options(lastDir) &
1287    exec $cmd -dir $options(lastDir) &
1288  } else {
1289    set cmd "[file join $toltk_bin wish84.exe] [file join $tkcvs_library tkdiff.tcl]"
1290    #exec c:/TclTk/bin/wish84.exe c:/TclTk/bin/tkdiff.tcl $data(nameFile) &
1291    exec $cmd $data(nameFile) &
1292  }
1293
1294 
1295}
1296
1297#/////////////////////////////////////////////////////////////////////////////
1298# Comandos de edición (deshacer, cortar, copiar, pegar, buscar, remplazar,...)
1299#/////////////////////////////////////////////////////////////////////////////
1300proc ::Editor::CmdUndo {this} {
1301  upvar \#0 ${this}::data data
1302  $data(txt) undo
1303}
1304
1305proc ::Editor::CmdRedo {this} {
1306  upvar \#0 ${this}::data data
1307#  $data(txt) redo
1308  Tolcon_Trace "---------------------------"
1309}
1310
1311proc ::Editor::CmdCut {this} {
1312  upvar \#0 ${this}::data data
1313  ::BayesText::Cut $data(txt)
1314}
1315
1316proc ::Editor::CmdCopy {this} {
1317  upvar \#0 ${this}::data data
1318  ::BayesText::Copy $data(txt)
1319}
1320
1321proc ::Editor::CmdPaste {this} {
1322  upvar \#0 ${this}::data data
1323  ::BayesText::Paste $data(txt)
1324}
1325
1326proc ::Editor::CmdSelectAll {this} {
1327  upvar \#0 ${this}::data data
1328  ::BayesText::SelectAll $data(txt)
1329}
1330
1331proc ::Editor::CmdHelpEditor {this} {
1332    upvar \#0 ${this}::data data
1333    ShowHelp Tb4Eda
1334}
1335
1336proc ::Editor::CmdFind {this} {
1337  upvar \#0 ${this}::data data
1338  ::BayesText::FindShow $data(txt,ctext)
1339}
1340
1341proc ::Editor::CmdSearch {this} {
1342  upvar \#0 ${this}::data data
1343  :::BayesText::SearchShow  $data(txt)
1344}
1345
1346proc ::Editor::CmdFindNext {this {txt ""}} {
1347  upvar \#0 ${this}::data data
1348  eval ::BayesText::FindShow $data(txt,ctext) 1 {$txt}
1349}
1350
1351proc ::Editor::CmdReplace {this} {
1352  upvar \#0 ${this}::data data
1353  ::BayesText::ReplaceShow $data(txt,ctext)
1354}
1355
1356proc ::Editor::CmdIdent {this} {
1357  upvar \#0 ${this}::data data
1358  variable options
1359  ::BayesText::Ident $data(txt,ctext) $options(charsIdent)
1360}
1361
1362proc ::Editor::CmdUnIdent {this} {
1363  upvar \#0 ${this}::data data
1364  variable options
1365  ::BayesText::UnIdent $data(txt,ctext) $options(charsIdent)
1366}
1367
1368
1369#/////////////////////////////////////////////////////////////////////////////
1370# Comandos
1371#/////////////////////////////////////////////////////////////////////////////
1372proc ::Editor::CmdFont {this} {
1373  variable options
1374  global toltk_options
1375  upvar \#0 ${this}::data data
1376  set fnt [::BayesText::FontChange $data(txt)]
1377  if {$fnt != ""} {
1378    set options(font) $fnt
1379    font configure ctfnBold   -family [lindex $fnt 0] -size [lindex $fnt 1]
1380    font configure ctfnNormal -family [lindex $fnt 0] -size [lindex $fnt 1]
1381    UpdateMarkPos $this [winfo height $data(txt)]
1382  }
1383}
1384
1385proc ::Editor::CmdPrint {this} {
1386  upvar \#0 ${this}::data data
1387  global tcl_platform
1388  if { [string equal $tcl_platform(platform) "windows"] } {
1389    #int PrintCmd(ClientData clientData, Tcl_Interp *interp, int argc, char **argv)
1390#    printer open
1391#    printer styledialog
1392#    printer jobdialog
1393#    puts "print from [printer getattr firstpage] to [printer getattr lastpage]"
1394#    printer opendoc
1395#    printer openpage
1396#    printer test   ; # funcion que usa para imprimir
1397#    printer text [$data(txt) get 1.0 end]
1398#    printer closepage
1399#    printer closedoc
1400#    printer close
1401  }
1402}
1403
1404proc ::Editor::CmdSaveCompile {this} {
1405  upvar \#0 ${this}::data data
1406
1407  #Si se está compilando no hago nada
1408  if {$data(isCompiled) eq 2} { return }
1409  set ok [CmdSave $this]
1410  if {$ok} {
1411    CmdCompileFile $this
1412  }
1413}
1414
1415#/////////////////////////////////////////////////////////////////////////////
1416proc ::Editor::CmdCompileFile {this} {
1417#/////////////////////////////////////////////////////////////////////////////
1418  upvar \#0 ${this}::data data
1419  #Si se está compilando no hago nada
1420  if {$data(isCompiled) eq 2} { return }
1421  $data(tb,balloon) configure -state disabled
1422  #set check [::BayesText::TolFileSyntaxCheck $data(nameFile)]
1423  set check 1
1424  if {$check} {
1425    set data(isCompiled) 2
1426    ::TolConsole::Include $data(nameFile)
1427    set data(isCompiled) 1
1428   
1429    #pedro-start
1430    # Mapear contenido de texto de la instancia y generar ayudas dinamicas
1431    # Puede tomar entre 5 y 10 segundos
1432    #::Editor::VariableMap $this
1433    set data(balloon) 1
1434    ::Editor::CmdBalloon $this
1435    update idletasks
1436    #pedro-fin
1437   
1438  } else  {
1439    # hay errores
1440    tk_messageBox -type ok -icon warning -title [mc Editor] -parent $data(txt) \
1441            -message "[mc {Syntax errors in file}]\n\
1442                      [mc {Look over output window}]"
1443  }
1444}
1445
1446#pedro-start
1447#/////////////////////////////////////////////////////////////////////////////
1448proc ::Editor::wordindexes {s} {
1449# PURPOSE: Divide un texto en palabras, devuelve los indices de inicio y final de
1450#          cada palabra.
1451#          Subtract whole words from a paragraph, returns a pair of index values
1452#          indicating where the word starts and where it ends.
1453#
1454# ARGS:    user defined text widget
1455#/////////////////////////////////////////////////////////////////////////////
1456    set i 0
1457    set res {}
1458    foreach c [split $s ""] {
1459        if {$c!=" " && $i==[string wordstart $s $i] && [regexp {[A-Za-z]} $c]} {
1460            lappend res $i [string wordend $s $i]
1461        }
1462        incr i
1463    }
1464    set res
1465 }
1466
1467#/////////////////////////////////////////////////////////////////////////////
1468proc ::Editor::VariableMap {this} {
1469# PURPOSE: Creates a tag inside the editor instance for each word in the tol text
1470#          excluding comment lines, virtually fragmenting the editor window in
1471#          about 6000 - 15000 pieces, depends on the amount of words.
1472#          Bind two mouse events to each tag created using  <Enter> and <Leave>,
1473#          this way we call the process BalloonHlp to display the help text.
1474#/////////////////////////////////////////////////////////////////////////////
1475#          Creamos un tag por cada palabra que se encuentre dentro del texto tol
1476#          excluyendo las lineas comentadas. A cada rango encontrado se le
1477#          hace un Bind a dos eventos del raton; <enter> y <leave> para entonces
1478#          llamar a BalloonHlp y mostrar la ayuda.
1479#
1480# ARGS:    Instance of Editor / Instancia del Editor
1481#
1482#
1483# TODO:   1) Tol is marvelous, did you know you can actually create 2 variables
1484#          with identical names differing only in the grammar type?.. example..
1485#          Real a1 = 2;
1486#          Set  a1 = SetOfText("","");
1487#          (This will create 2 separate variables with the same name.. amazing huh?)
1488#          This is PERFECLTY possible in our amazing language, wich SUCKS for
1489#          the purpuse of this procedure... that is, because analyzed text is
1490#          arbitrary. With no reading rules, i can't really determine the
1491#          variable type before calling BalloonHlp. If two variables happen to
1492#          have the same name, the ::TclInfoVar loop function will catch the info
1493#          on the last valid grammar type in the checklist (See Editor::BalloonHlp
1494#          for more details).
1495#         
1496#          The idea would be to determine the grammar type before calling BalloonHlp.
1497#          I ain't genious enought to take it that far out.... yet. :-D
1498#
1499#         2) I managed to exclude comment lines from being parsed as valid tags.
1500#            If you can manage to exclude text or quote delimited expressions
1501#            from the loop, you're my geek... and offcourse, you defenetly have
1502#            more free time than me. Good Luck.
1503#/////////////////////////////////////////////////////////////////////////////
1504  upvar \#0 ${this}::data data
1505  # Luego de compilar, obtengo la lista de variables creadas.
1506  # "const" sera lista de palabras que nunca seran variables
1507  set const [list Anything Code Complex CDate CTimeSet Date Matrix Polyn \
[de6ceb5]1508                  Ratio Ration Real Serie Set Special Struct Text TimeSet ]
[6d7779d]1509   
1510  #Obtener lista de variables y funciones ya compiladas desde editor
1511  #controla el numero de linea mientras recorre el txt del editor
1512  set linenum 0
1513   
1514  foreach line [split [$data(txt) get 1.0 end-1c] \n] {
1515    incr linenum 1
1516    if { [string range $line 0 1] != "//" && [regexp "//" $line] == "0" } {
1517      foreach {from to} [::Editor::wordindexes $line] {
1518        #guardar palabra e indices
1519        set word [string range $line $from [expr $to-1]]
1520        set verif [lsearch -exact $const "$word"]
1521        if  { $verif == "-1" } {
1522          #solo se crea tag si no pertenece a ningun nombre de variable
1523          set num [expr rand()]
1524          #numero aleatorio para complementar nombres de tags repetidos
1525          set to [expr $to-1]
1526          #crear tag con nombre y rango dentro del text
1527          $data(txt) tag add "$word$num" "$linenum.$from" "$linenum.$to"
1528          #Crear bind a eventos para cada tag creado
1529          $data(txt) tag bind "$word$num" <Enter> "after 1500 [list ::Editor::BalloonHlp $this $data(txt) $word]"
1530          $data(txt) tag bind "$word$num" <Leave> "destroy $data(txt).balloon"
1531          #Subrayo las variables Definidas
1532          #if { [llength [::TclInfoVar "Anything" "$word" ]] > 0 } {
1533          #$data(txt) tag configure "$word$num" -underline 1 }
1534          update idletasks
1535        }
1536      }
1537    }
1538  }
1539  # - fin
1540}
1541
1542
1543#/////////////////////////////////////////////////////////////////////////////
1544proc ::Editor::CmdCompile {this} {
1545#/////////////////////////////////////////////////////////////////////////////
1546  upvar \#0 ${this}::data data
1547
1548  set idxs [$data(txt) tag ranges sel]
1549  Tolcon_Trace "idxs = $idxs"
1550  # Si hay seleccion evaluo texto seleccionado, sino incluyo el archivo
1551  if [llength $idxs] {
1552    ::TolConsole::EvalExpr [$data(txt) get [lindex $idxs 0] [lindex $idxs 1]]
1553  } else  {
1554    CmdSaveCompile $this
1555  }
1556}
1557
1558
1559#/////////////////////////////////////////////////////////////////////////////
1560proc ::Editor::CmdDecompile {this} {
1561#///////////////////////////////////////////////////////////////////////////// 
1562  upvar \#0 ${this}::data data
1563  if {$data(isCompiled) eq 1} {
1564    ::TolInspector::DecompileFile $data(nameFile)
1565  }
1566}
1567
1568
1569#/////////////////////////////////////////////////////////////////////////////
1570proc ::Editor::CmdSyntaxCheck {this} {
1571#///////////////////////////////////////////////////////////////////////////// 
1572  upvar \#0 ${this}::data data
1573  ::BayesText::TolSyntaxCheck $data(txt)
1574}
1575
1576
1577#/////////////////////////////////////////////////////////////////////////////
1578proc ::Editor::CmdRefresh {this} {
1579#///////////////////////////////////////////////////////////////////////////// 
1580  upvar \#0 ${this}::data data
1581
1582  foreach tag [$data(txt) tag names] {
1583    $data(txt) tag remove $tag 1.0 end
1584  }
1585  update idletasks
1586  $data(txt) highlight 1.0 end
1587}
1588
1589
1590#/////////////////////////////////////////////////////////////////////////////
1591proc ::Editor::CmdRightMargin {this} {
1592#///////////////////////////////////////////////////////////////////////////// 
1593  upvar \#0 ${this}::data data
1594  UpdateMarkPos $this [winfo height $data(txt)]
1595}
1596
1597
1598#/////////////////////////////////////////////////////////////////////////////
1599proc ::Editor::CmdOptions {this} {
1600#///////////////////////////////////////////////////////////////////////////// 
1601  upvar \#0 ${this}::data data
1602  OptionsCreate $this $data(txt)
1603}
1604
1605
1606#/////////////////////////////////////////////////////////////////////////////
1607proc ::Editor::CmdBalloon {this} {
1608# PURPOSE: Balloon Control
1609#/////////////////////////////////////////////////////////////////////////////
1610  upvar \#0 ${this}::data data
1611 
1612  if {  $data(balloon) != 1 } {
1613    #Reconfigure
1614    $data(tb,balloon) configure -state disabled
1615     #Recalculate values
1616     ::Editor::VariableMap $this
1617     #flag
1618     set data(balloon) 1
1619     #reconfigure
1620     $data(tb,balloon) configure -image [::Bitmap::get "balloon_enable"]
1621    $data(tb,balloon) configure -state normal
1622  } else {
1623     #destroy tag & binds
1624     $data(tb,balloon) configure -state disabled
1625       set tagnames [$data(txt) tag names]
1626       set limit [llength $tagnames]
1627       for {set x 6} {$x < $limit} {incr x} {
1628        $data(txt) tag delete [lindex $tagnames $x]
1629        #puts "tag eliminada"
1630       }
1631       set data(balloon) 0
1632       $data(tb,balloon) configure -image [::Bitmap::get "balloon_disable"]
1633      $data(tb,balloon) configure -state normal
1634  }
1635}
1636
1637
1638#/////////////////////////////////////////////////////////////////////////////
1639proc ::Editor::OptionsCreate {this path} {
1640#///////////////////////////////////////////////////////////////////////////// 
1641  set dialog [Dialog $path.d -title [mc "Editor Options"]\
1642            -modal local -parent $path]
1643  wm resizable $dialog 0 0
1644  wm protocol $dialog WM_DELETE_WINDOW [list ::Editor::OptionsDestroy $this $dialog]
1645  set w [$dialog getframe]
1646  set w_tabset [::blt::tabset $w.ts -relief flat -highlightthickness 0\
1647            -bd 0 -outerpad 0 -tier 2 -slant right -textside right ]
1648   
1649  #insertar tabset
1650  $w_tabset insert end Headers Others
1651  set f1 [frame $w_tabset.f1]
1652  set f2 [frame $w_tabset.f2]
1653   
1654   
1655  $w_tabset tab configure "Headers" -text [mc "Headers"] -window $f1\
1656          -fill both -padx 0 -selectbackground \#d9d9d9 -bg gray75
1657  $w_tabset tab configure "Others" -text [mc "Others"] -window $f2\
1658          -fill both -padx 0 -selectbackground \#d9d9d9 -bg gray75
1659   
1660  OptionsGet $this
1661  OptionsCreateHeaders $this $f1
1662  OptionsCreateOthers  $this $f2
1663   
1664  OptionsCheck $this
1665   
1666  set w_bbox \
1667    [ButtonBox $w.bb -orient horizontal -spacing 10 -padx 0 -pady 0 \
1668     -homogeneous false]
1669  $w_bbox add -text [mc "Accept"] -relief link \
1670    -helptext [mc "OK"] \
1671    -image [::Bitmap::get accept] -compound left -padx 5 -pady 1 \
1672    -command [list ::Editor::OptionsOK $this $dialog]
1673  $w_bbox add -text [mc "Cancel"] -relief link \
1674    -helptext [mc "Cancel"]\
1675    -image [::Bitmap::get cancelx] -compound left -padx 5 -pady 1 \
1676    -command [list ::Editor::OptionsDestroy $this $dialog]
1677  $w_bbox add -text [mc "Apply"] -relief link \
1678    -helptext [mc "Apply"]\
1679    -image [::Bitmap::get apply] -compound left -padx 5 -pady 1 \
1680    -command [list ::Editor::OptionsDestroy $this $dialog]
1681 
1682  pack $w_bbox   -fill x -expand false -side bottom
1683  pack $w_tabset -fill both -expand true
1684 
1685  bind $dialog <F1> "ShowHelp Tb4Eda ; break"   
1686  $dialog draw
1687}
1688
1689
1690#/////////////////////////////////////////////////////////////////////////////
1691proc ::Editor::OptionsCreateHeaders {this w} {
1692#///////////////////////////////////////////////////////////////////////////// 
1693  variable tmpOpt
1694   
1695  TitleFrame $w.tf1 -text [mc "Files of headers"]
1696  set f1 [$w.tf1 getframe]
1697   
1698  checkbutton $f1.chFileH -text [mc "Insert header in new files"]\
1699            -variable ::Editor::tmpOpt(var,chFileH)\
1700            -command [list ::Editor::OptionsCheckHeaderFileInsert $this]
1701  label  $f1.lFileH -text [mc "Files Header"]
1702  set tmpOpt(widget,eFileH) [entry  $f1.eFileH -width 50\
1703                  -textvariable ::Editor::tmpOpt(var,fileH)]
1704  set tmpOpt(widget,bFileH) [::Objects::ChooseFileCreate ::Editor::tmpOpt(var,fileH) $f1.bFileH]
1705
1706  label  $f1.lFuncH -text [mc "Functions Header"]
1707  entry  $f1.eFuncH -width 50 -textvariable ::Editor::tmpOpt(var,funcH)
1708  ::Objects::ChooseFileCreate ::Editor::tmpOpt(var,funcH) $f1.bFuncH
1709   
1710   
1711  frame $f1.f -width 25
1712   
1713  grid $f1.f $f1.chFileH -          -          -sticky nw -padx 2
1714  grid ^     $f1.lFileH  $f1.eFileH $f1.bFileH -sticky nw -padx 2
1715  grid ^     $f1.lFuncH  $f1.eFuncH $f1.bFuncH -sticky nw -padx 2
1716  grid rowconfigure    $f1 0 -weight 1
1717  grid columnconfigure $f1 3 -weight 1
1718   
1719  grid $w.tf1 -sticky news -padx 2
1720   
1721  grid rowconfigure    $w 1 -weight 1
1722  grid rowconfigure    $w 2 -weight 2
1723  grid columnconfigure $w 0 -weight 1   
1724}
1725
1726
1727#/////////////////////////////////////////////////////////////////////////////
1728proc ::Editor::OptionsCreateOthers {this w} {
1729#///////////////////////////////////////////////////////////////////////////// 
1730  variable tmpOpt
1731   
1732  TitleFrame $w.tf1 -text [mc "General Options"]
1733  set f1 [$w.tf1 getframe]
1734   
1735  checkbutton $f1.chEdited -text [mc "Files edited recently"]\
1736          -variable ::Editor::tmpOpt(var,chEdited)\
1737          -command [list ::Editor::OptionsCheckEdited $this]
1738   
1739  set tmpOpt(widget,edited) [SpinBox $f1.sbEdited -justify right -width 4 \
1740          -editable 0 -range {0 40} \
1741          -textvariable ::Editor::tmpOpt(var,numEdited)]
1742  label $f1.lFiles -text [mc files]
1743 
1744  checkbutton $f1.chLine -text [mc "Show line at"] \
1745          -variable ::Editor::tmpOpt(var,chLine)
1746  SpinBox $f1.sbLinePos -justify right -width 4 \
1747          -editable 0 -range {20 100} \
1748          -textvariable ::Editor::tmpOpt(var,posLine)
1749  label $f1.lChars -text [mc characters]
1750 
1751  label $f1.lCharsIdent -text [mc "Characters to ident"]
1752  SpinBox $f1.sbCharsIdent -justify right -width 4 \
1753          -editable 0 -range {1 8} \
1754          -textvariable ::Editor::tmpOpt(var,charsIdent)
1755
1756  frame $f1.f -width 25
1757   
1758  grid $f1.f $f1.chEdited     $f1.sbEdited     $f1.lFiles -sticky nw -padx 2
1759  grid ^     $f1.chLine       $f1.sbLinePos    $f1.lChars -sticky nw -padx 2
1760  grid ^     $f1.lCharsIdent  $f1.sbCharsIdent         -sticky nw -padx 2
1761  grid rowconfigure    $f1 2 -weight 1
1762  grid columnconfigure $f1 3 -weight 1
1763   
1764  grid $w.tf1 -sticky news -padx 2
1765   
1766  grid rowconfigure    $w 1 -weight 1
1767  grid rowconfigure    $w 2 -weight 2
1768  grid columnconfigure $w 0 -weight 1
1769}
1770
1771
1772#/////////////////////////////////////////////////////////////////////////////
1773proc ::Editor::OptionsGet {this} {
1774#///////////////////////////////////////////////////////////////////////////// 
1775  variable options
1776  variable tmpOpt
1777  set tmpOpt(var,chEdited)   $options(chEdited)
1778  set tmpOpt(var,numEdited)  $options(numEdited)
1779  set tmpOpt(var,chFileH)    $options(chFileH)
1780  set tmpOpt(var,fileH)      $options(fileH)
1781  set tmpOpt(var,funcH)      $options(funcH)
1782  set tmpOpt(var,chLine)     $options(chLine)
1783  set tmpOpt(var,posLine)    $options(posLine)
1784  set tmpOpt(var,charsIdent) $options(charsIdent)
1785}
1786
1787
1788#/////////////////////////////////////////////////////////////////////////////
1789proc ::Editor::OptionsSet {this} {
1790#///////////////////////////////////////////////////////////////////////////// 
1791  variable options
1792  variable tmpOpt
1793   
1794  regsub -all var, [array names ::Editor::tmpOpt var,*] "" optNames
1795  #Tolcon_Trace "$optNames"
1796  foreach it $optNames {
1797    set options($it) $tmpOpt(var,$it)
1798  } 
1799}
1800
1801
1802#/////////////////////////////////////////////////////////////////////////////
1803proc ::Editor::OptionsCheck {this} {
1804#///////////////////////////////////////////////////////////////////////////// 
1805  OptionsCheckEdited           $this
1806  OptionsCheckHeaderFileInsert $this
1807}
1808
1809
1810#/////////////////////////////////////////////////////////////////////////////
1811proc ::Editor::OptionsCheckEdited {this} {
1812#///////////////////////////////////////////////////////////////////////////// 
1813  variable tmpOpt
1814  if {!$tmpOpt(var,chEdited)} {     
1815    $tmpOpt(widget,edited) configure -state disabled
1816  } else  {
1817    $tmpOpt(widget,edited) configure -state normal
1818  }
1819}
1820
1821
1822#/////////////////////////////////////////////////////////////////////////////
1823proc ::Editor::OptionsCheckHeaderFileInsert {this} {
1824#///////////////////////////////////////////////////////////////////////////// 
1825  variable tmpOpt
1826  if {!$tmpOpt(var,chFileH)} {
1827    $tmpOpt(widget,eFileH) configure -state disabled
1828    $tmpOpt(widget,bFileH) configure -state disabled
1829  } else  {
1830    $tmpOpt(widget,eFileH) configure -state normal
1831    $tmpOpt(widget,bFileH) configure -state normal
1832  }
1833}
1834
1835
1836#/////////////////////////////////////////////////////////////////////////////
1837proc ::Editor::OptionsDestroy {this dialog} {
1838#///////////////////////////////////////////////////////////////////////////// 
1839  variable tmpOpt
1840  array unset tmpOpt
1841  destroy $dialog
1842}
1843
1844
1845#/////////////////////////////////////////////////////////////////////////////
1846proc ::Editor::OptionsApply {this} {
1847#///////////////////////////////////////////////////////////////////////////// 
1848  OptionsSet $this
1849  CmdRightMargin $this
1850}
1851
1852
1853#/////////////////////////////////////////////////////////////////////////////
1854proc ::Editor::OptionsOK {this dialog} {
1855#///////////////////////////////////////////////////////////////////////////// 
1856  OptionsApply   $this
1857  OptionsDestroy $this $dialog
1858}
1859
1860
1861#/////////////////////////////////////////////////////////////////////////////
1862# INIFILE
1863#/////////////////////////////////////////////////////////////////////////////
1864
1865
1866#/////////////////////////////////////////////////////////////////////////////
1867proc ::Editor::ReadIni {} {
1868#///////////////////////////////////////////////////////////////////////////// 
1869  variable options
1870  global toltk_options
1871
1872  set rini ::iniFile::Read
1873  set options(chFileH)    [$rini Editor insertFileH 0]
1874  set options(fileH)      [$rini Editor fileH      ""]
1875  set options(funcH)      [$rini Editor funcH      ""]
1876  set options(chEdited)   [$rini Editor saveRecent  1]
1877  set options(numEdited)  [$rini Editor numRecent   8]
1878  set options(edited)     [$rini Editor recent      {}]
1879  set options(font)       [$rini Editor font     $toltk_options(fonts,Fixed)]
1880  set options(lastDir)    [$rini Editor lastDir  ""]
1881  set options(chLine)     [$rini Editor chLine    1]
1882  set options(posLine)    [$rini Editor posLine  78]
1883  set options(charsIdent) [$rini Editor charsIdent 2]
1884}
1885
1886
1887#/////////////////////////////////////////////////////////////////////////////
1888  proc ::Editor::WriteIni {this} {
1889#
1890# PURPOSE: Write common Editor options to .ini file
1891#
1892# PARAMETERS:
1893#   this  -> Instance of editor
1894#
1895#/////////////////////////////////////////////////////////////////////////////
1896  variable options
1897  upvar \#0 ${this}::data data
1898  set wini ::iniFile::Write
1899
1900  $wini Editor insertFileH  $options(chFileH)
1901  $wini Editor fileH        $options(fileH)
1902  $wini Editor funcH        $options(funcH)
1903  $wini Editor saveRecent   $options(chEdited)
1904  $wini Editor numRecent    $options(numEdited)
1905  $wini Editor recent       $options(edited)
1906  $wini Editor font         $options(font)
1907  $wini Editor lastDir      $options(lastDir)
1908  $wini Editor chLine       $options(chLine)
1909  $wini Editor posLine      $options(posLine)
1910  $wini Editor charsIdent   $options(charsIdent)
1911  ::iniFile::Flush
1912}
1913
1914::Editor::ReadIni
Note: See TracBrowser for help on using the repository browser.