From 795861c0a1a257d0b740ce2f1fa4d9db4a1f56dd Mon Sep 17 00:00:00 2001 From: Sergey Kalinin Date: Fri, 2 Sep 2022 21:42:40 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=BE=D1=87=D1=82=D0=B8=20=D1=80=D0=B0?= =?UTF-8?q?=D0=B1=D0=BE=D1=82=D0=B0=D1=8E=D1=89=D0=B8=D0=B9=20=D0=BF=D0=BE?= =?UTF-8?q?=D0=B8=D1=81=D0=BA=20=D0=BF=D0=B5=D1=80=D0=B5=D0=BC=D0=B5=D0=BD?= =?UTF-8?q?=D0=BD=D1=8B=D1=85=20=D0=BF=D0=BE=20=D0=BA=D0=B0=D1=82=D0=B0?= =?UTF-8?q?=D0=BB=D0=BE=D0=B3=D1=83=20=D0=B4=D0=BB=D1=8F=20ansible.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/editor.tcl | 4 +-- lib/lexers.tcl | 3 +- lib/procedure.tcl | 84 +++++++++++++++++++++++++++++++++++++++---- lib/readstructure.tcl | 12 ++++--- projman.tcl | 22 ++++++------ 5 files changed, 98 insertions(+), 27 deletions(-) diff --git a/lib/editor.tcl b/lib/editor.tcl index fc3a1b4..d8e3272 100644 --- a/lib/editor.tcl +++ b/lib/editor.tcl @@ -468,7 +468,7 @@ namespace eval Editor { bind $txt "Editor::SelectionPaste $txt" #bind $txt "auto_completition $txt" - bind $txt "SearchVariable {$txt get {insert wordstart} {insert wordend}}" + bind $txt "SearchVariable $txt" # bind $txt "" # bind $txt "" bind $txt "ImageBase64Encode $txt" @@ -679,7 +679,7 @@ proc FindFunction {findString} { # ---------------------------------------------------------------------- # Вызов диалога со списком процедур или функций присутствующих в тексте - proc GoToFunction { w } { + proc GoToFunction { w } { global tree editors set txt $w.frmText.t # set start_word [$txt get "insert - 1 chars wordstart" insert] diff --git a/lib/lexers.tcl b/lib/lexers.tcl index 5a361be..1841322 100644 --- a/lib/lexers.tcl +++ b/lib/lexers.tcl @@ -43,6 +43,5 @@ dict set lexers YML procFindString {(- name:)\s*?PROCNAME} dict set lexers YML procRegexpCommand {regexp -nocase -all -- {^\s*?- (name):\s(.+?)$} $line match keyWord procName} dict set lexers YML varRegexpCommand {regexp -nocase -all -- {^\s*?([a-zA-Z0-9\-_$]+):\s+(.+?)(\s*$)} $line match varName varValue lineEnd} -dict set lexers ALL varDirectory {vars group_vars host_vars} - +dict set lexers ALL varDirectory {variables vars group_vars host_vars} diff --git a/lib/procedure.tcl b/lib/procedure.tcl index c6f7cb7..dafde27 100644 --- a/lib/procedure.tcl +++ b/lib/procedure.tcl @@ -136,14 +136,86 @@ namespace eval Help { } } -proc SearchVariable {varName} { +proc SearchVariable {txt} { global fileStructure project variables - # puts "$fileStructure" - foreach key [dict keys $project] { - foreach f [dict get $project $key] { - foreach v [dict get $project $key $f] { - puts "--$v" + set varName [$txt get {insert wordstart} {insert wordend}] + puts ">>>$varName<<<" + if {[info exists project] == 0} {return} + foreach f [array names project] { + puts "--$f" + puts "----" + foreach a $project($f) { + puts "-----$variables($a)" + foreach b $variables($a) { + puts "------$b -- [lindex $b 0]" + if {$varName eq [lindex $b 0]} { + puts "УРААААААА $varName = $b в файле $a \n\t [lindex $b 0]" + FindVariablesDialog $txt "$varName: $a" + } } } } } +proc FindVariablesDialog {txt args} { + global editors lexers + # variable txt + variable win + # set txt $w.frmText.t + set box [$txt bbox insert] + set x [expr [lindex $box 0] + [winfo rootx $txt] ] + set y [expr [lindex $box 1] + [winfo rooty $txt] + [lindex $box 3] ] + + set win .findVariables + + if { [winfo exists $win] } { destroy $win } + toplevel $win + wm transient $win . + wm overrideredirect $win 1 + + listbox $win.lBox -width 50 -border 2 -yscrollcommand "$win.yscroll set" -border 1 + ttk::scrollbar $win.yscroll -orient vertical -command "$win.lBox yview" + pack $win.lBox -expand true -fill y -side left + pack $win.yscroll -side left -expand false -fill y + + foreach { word } $args { + $win.lBox insert end $word + } + + catch { $win.lBox activate 0 ; $win.lBox selection set 0 0 } + + if { [set height [llength $args]] > 10 } { set height 10 } + $win.lBox configure -height $height + + bind $win { + destroy $win + # focus -force $txt.t + break + } + bind $win.lBox { + destroy $win + # focus -force $txt.t + break + } + bind $win.lBox { + # set findString [dict get $lexers [dict get $editors $Editor::txt fileType] procFindString] + set values [.findVariables.lBox get [.findVariables.lBox curselection]] + # regsub -all {PROCNAME} $findString $values str + # Editor::FindFunction "$str" + destroy .findVariables + # $txt tag remove sel 1.0 end + # focus $Editor::txt.t + break + } + bind $win.lBox {Editor::ListBoxSearch %W %A} + # Определям расстояние до края экрана (основного окна) и если + # оно меньше размера окна со списком то сдвигаем его вверх + set winGeom [winfo reqheight $win] + set topHeight [winfo height .] + # puts "$x, $y, $winGeom, $topHeight" + if [expr [expr $topHeight - $y] < $winGeom] { + set y [expr $topHeight - $winGeom] + } + wm geom $win +$x+$y +} + + diff --git a/lib/readstructure.tcl b/lib/readstructure.tcl index 17b9b00..be95341 100644 --- a/lib/readstructure.tcl +++ b/lib/readstructure.tcl @@ -50,16 +50,17 @@ proc GetVariablesFromFile {fileName} { proc ReadFilesFromDirectory {directory root {type ""}} { global procList project lexers variables + foreach i [split [dict get $lexers ALL varDirectory] " "] { lappend l [string trim $i] - # puts $i + # puts "---->$i" } if {[catch {cd $directory}] != 0} { return "" } foreach fileName [glob -nocomplain *] { - puts "Find file: $fileName" - if {[lsearch $l [file tail $fileName]] != -1 && [file isdirectory $fileName] == 1} { + puts "Find file: $fileName [lsearch -exact -nocase $l $fileName]" + if {[lsearch -exact $l $fileName] != -1 && [file isdirectory [file join $root $directory $fileName]] == 1} { # puts "--- $root $fileName" ReadFilesFromDirectory [file join $directory $fileName] $root "var" } elseif {[file isdirectory $fileName] == 1} { @@ -69,9 +70,10 @@ proc ReadFilesFromDirectory {directory root {type ""}} { if {$type eq "var"} { # puts ">>>>>$root $fileName" # puts "[GetVariablesFromFile $fileName]" - dict set project $root $fileName "[GetVariablesFromFile $fileName]" + # dict set project $root [file join $root $directory $fileName];# "[GetVariablesFromFile $fileName]" + lappend project($root) [file join $root $directory $fileName] set variables([file join $root $directory $fileName]) [GetVariablesFromFile $fileName] - puts "[file join $root $directory $fileName]---$variables([file join $root $directory $fileName])" + # puts "[file join $root $directory $fileName]---$variables([file join $root $directory $fileName])" } } } diff --git a/projman.tcl b/projman.tcl index 114c7ba..83445bf 100755 --- a/projman.tcl +++ b/projman.tcl @@ -10,7 +10,7 @@ exec wish "$0" -- "$@" ###################################################### # Version: 2.0.0 # Release: alpha -# Build: 01092022165308 +# Build: 02092022214055 ###################################################### # определим текущую версию, релиз и т.д. @@ -123,14 +123,12 @@ if [info exists opened] { } } - foreach key [dict keys $project] { - foreach f [dict get $project $key] { - puts "----$f" - - # dict set project $root fileName $fileName - # puts "--- [dict get $project $key fileName]" - # foreach v [dict get $project $key fileName] { - # puts "--$v" - # } - } - } +# if [info exists project] { + # foreach f [array names project] { + # puts "--$f" + # puts "----" + # foreach a [split $project($f) " "] { + # puts $variables($a) + # } + # } +#