From a46c13788f871e03b2d16f9f6152920895150704 Mon Sep 17 00:00:00 2001 From: Sergey Kalinin Date: Fri, 12 Jan 2018 13:44:26 +0300 Subject: [PATCH] Begining work with autocomplition procedure for variables --- CHANGELOG | 2 ++ completition.tcl | 32 +++++++++++++++++++++----------- editor.tcl | 13 +++++++++++-- highlight/tcl.tcl | 1 + main.tcl | 5 ----- msgcat.add | 18 ------------------ procedure.tcl | 2 ++ projman.tcl | 1 + taglist.tcl | 1 + 9 files changed, 39 insertions(+), 36 deletions(-) delete mode 100644 msgcat.add diff --git a/CHANGELOG b/CHANGELOG index 95174b2..8ff1f8a 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -12,6 +12,7 @@ - Actualizing information into "About" dialog - Corrected color settings for all widgets - Change default color scheme +- Remove ctag, change autocomplitt procedure 0.4.4 @@ -361,5 +362,6 @@ Fixed bug with PageRise function + diff --git a/completition.tcl b/completition.tcl index dafef10..93cf7d8 100644 --- a/completition.tcl +++ b/completition.tcl @@ -36,9 +36,10 @@ proc auto_completition { widget } { } ;# proc auto_completition ## PROCEDURE LIST ## -## by BanZaj ## +## by BanZaj ## + proc auto_completition_proc { widget } { - global procList activeProject noteBook + global procList activeProject noteBook varList set nodeEdit [$noteBook raise] if {$nodeEdit == "" || $nodeEdit == "newproj" || $nodeEdit == "about" || $nodeEdit == "debug"} { return @@ -51,24 +52,29 @@ proc auto_completition_proc { widget } { set cnt 0 set pos "1.0" set last_pos "" - set pattern "$start_word\\w*" + puts "$start_word" + puts [regsub -all -- "\$" $start_word "\\\$" word] + puts $word #set list_word($start_word) 1 - if [info exists procList($activeProject)] { - set len [llength $procList($activeProject)] + if {[string index $start_word 0] == "\$"} { + set workList $varList($activeProject) + } else { + set workList $procList($activeProject) + } + if [info exists workList] { + set len [llength $workList] } else { return } set i 0 while {$len >=$i} { - set line [lindex $procList($activeProject) $i] + set line [lindex $ $i] scan $line "%s" word - if [regexp -nocase -all -- {\s\{.*?\}+\s} $line par] { - regsub -all (\{|\}) $par " " par - set word_ "$word [string trim $par]" - if {[string match "$start_word*" $word]} {set list_word($word_) $i} + if {[string match "$start_word*" $word]} { + set list_word($word) $i } incr i - } + } bindtags $widget [list CompletitionBind [winfo toplevel $widget] $widget Text sysAfter all] bind CompletitionBind "bindtags $widget {[list [winfo toplevel $widget] $widget Text sysAfter all]}; catch { destroy .aCompletition }" bind CompletitionBind {auto_completition_key %W %K %A ; break} @@ -165,3 +171,7 @@ proc auto_completition_key { widget K A } { + + + + diff --git a/editor.tcl b/editor.tcl index c72d9c6..cb97c32 100644 --- a/editor.tcl +++ b/editor.tcl @@ -853,8 +853,8 @@ proc TextEncode {encode} { ## EDITING FILE ## proc EditFile {node fileName} { - global projDir workDir imgDir tree noteBook fontNormal fontBold w fileList replace nodeEdit - global backUpFileCreate fileExt progress editor braceHighLightBG braceHighLightFG + global projDir workDir imgDir tree noteBook fontNormal fontBold w fileList replace nodeEdit procList + global backUpFileCreate fileExt progress editor braceHighLightBG braceHighLightFG activeProject set nodeEdit $node set replace 0 set file [file tail $fileName] @@ -923,14 +923,22 @@ proc EditFile {node fileName} { } elseif {$keyWord == "class"} { set img "class.gif" } + if {$keyWord =="proc"} { + lappend procList($activeProject) [list $procName "param"] + #$w.text tag add procName $lineNumber.[expr $startPos + $length] $lineNumber.[string wordend $line [expr $startPos + $length +2]] + } if {[$tree exists $prcNode$dot$lineNumber] !=1} { $tree insert end $node $prcNode$dot$lineNumber -text $procName \ -data "prc_$procName"\ -image [Bitmap::get [file join $imgDir $img]] -font $fontNormal } } + if {$keyWord =="set"} { + lappend varList($activeProject) [list $procName "param"]] + } incr lineNumber } + #puts $procList close $file $w.text mark set insert 0.0 $w.text see insert @@ -1138,3 +1146,4 @@ GetOp + diff --git a/highlight/tcl.tcl b/highlight/tcl.tcl index aebda82..0511d42 100644 --- a/highlight/tcl.tcl +++ b/highlight/tcl.tcl @@ -225,3 +225,4 @@ proc HighLightTCL {text line lineNumber node} { + diff --git a/main.tcl b/main.tcl index af21c34..7afc480 100644 --- a/main.tcl +++ b/main.tcl @@ -385,8 +385,3 @@ $tree configure -redraw 1 set activeProject "" focus -force $tree - - - - - diff --git a/msgcat.add b/msgcat.add deleted file mode 100644 index 1945c4a..0000000 --- a/msgcat.add +++ /dev/null @@ -1,18 +0,0 @@ -Вот пища для размышлений. Уточну. Этот код предназначен для работы под Win32 при условии, что весть текст набран в koi8-r кодировке. Как его доделать, думаю, сообразишь сам: -set lang ru -set mc_source { - mcset $lang "File" "Файл" - mcset $lang "New..." "Новый..." -} - -set mc_source [encoding convertto koi8-r $mc_source] -set mc_source [encoding convertfrom cp1251 $mc_source] - -eval $mc_source - -++++++++++++++++++++++++++ -set mc_source [encoding convertto koi8-r $mc_source] -set mc_source [encoding convertfrom [encoding system] $mc_source] - - - diff --git a/procedure.tcl b/procedure.tcl index a215dc2..39a2c24 100644 --- a/procedure.tcl +++ b/procedure.tcl @@ -1115,3 +1115,5 @@ proc TextOperation {oper} { + + diff --git a/projman.tcl b/projman.tcl index b794b51..1e3195c 100755 --- a/projman.tcl +++ b/projman.tcl @@ -132,3 +132,4 @@ option add *Scrollbar.background $editor(bg) startupFile + diff --git a/taglist.tcl b/taglist.tcl index 3e88820..8ea21de 100644 --- a/taglist.tcl +++ b/taglist.tcl @@ -53,3 +53,4 @@ proc GetTagList_ {tagFile} { +