Почти работающий поиск переменных по каталогу для ansible.
This commit is contained in:
parent
4f6735dcea
commit
795861c0a1
|
@ -468,7 +468,7 @@ namespace eval Editor {
|
|||
bind $txt <Control-v> "Editor::SelectionPaste $txt"
|
||||
|
||||
#bind $txt <Control-adiaeresis> "auto_completition $txt"
|
||||
bind $txt <Control-l> "SearchVariable {$txt get {insert wordstart} {insert wordend}}"
|
||||
bind $txt <Control-l> "SearchVariable $txt"
|
||||
# bind $txt <Control-icircumflex> ""
|
||||
# bind $txt <Control-j> ""
|
||||
bind $txt <Control-i> "ImageBase64Encode $txt"
|
||||
|
|
|
@ -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}
|
||||
|
||||
|
|
|
@ -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 <Escape> {
|
||||
destroy $win
|
||||
# focus -force $txt.t
|
||||
break
|
||||
}
|
||||
bind $win.lBox <Escape> {
|
||||
destroy $win
|
||||
# focus -force $txt.t
|
||||
break
|
||||
}
|
||||
bind $win.lBox <Return> {
|
||||
# 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 <Any-Key> {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
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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])"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
20
projman.tcl
20
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)
|
||||
# }
|
||||
}
|
||||
}
|
||||
# }
|
||||
#
|
||||
|
|
Loading…
Reference in New Issue
Block a user