source: tol/tolbase/lib/toltk/editor.tcl @ 0e07e12

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

fixes #1432, se implementa una opcion de menu contextual "Escape text" que abre una ventana de dialogo para realizar el escape del texto deseado. Si en el momento de seleccionar esta opción de menú hay un texto seleccionado este se utiliza como texto inicial a escapar. La ventana ofrece un botón para sustituir el texto seleccionado por el texto escapado.

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

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