Переделал дилог навигации по переменным

This commit is contained in:
svkalinin 2022-09-16 16:26:52 +03:00
parent 3689e582e7
commit bc432b8d84
2 changed files with 56 additions and 29 deletions

View File

@ -29,7 +29,11 @@ namespace eval NB {
} }
proc PressTab {w x y} { proc PressTab {w x y} {
$w select [$w identify tab $x $y] if {[$w identify tab $x $y] ne ""} {
$w select [$w identify tab $x $y]
} else {
return
}
if {[$w identify $x $y] == "close_button"} { if {[$w identify $x $y] == "close_button"} {
FileOper::Close FileOper::Close
} else { } else {

View File

@ -162,14 +162,21 @@ proc SearchVariable {txt} {
return return
} }
} }
proc GetVariableFilePath {txt} {
set str [$txt get {insert linestart} {insert lineend}]
if [regexp -nocase -all -- {^([0-9A-Za-z\-_:]*?) :: (.*?) :: (.*?)$} $str match vName vValue vPath] {
return $vPath
}
}
proc FindVariablesDialog {txt args} { proc FindVariablesDialog {txt args} {
global editors lexers global editors lexers cfgVariables
# variable txt # variable txt
variable win variable win
variable t $txt
# set txt $w.frmText.t # set txt $w.frmText.t
set box [$txt bbox insert] set box [$txt bbox insert]
set x [expr [lindex $box 0] + [winfo rootx $txt] ] set x [expr [lindex $box 0] + [winfo rootx $txt] ]
set y [expr [lindex $box 1] + [winfo rooty $txt] + [lindex $box 3] ] set y [expr [lindex $box 1] + [winfo rooty $txt] + [lindex $box 3] ]
set win .findVariables set win .findVariables
@ -177,12 +184,15 @@ proc FindVariablesDialog {txt args} {
toplevel $win toplevel $win
wm transient $win . wm transient $win .
wm overrideredirect $win 1 wm overrideredirect $win 1
# set win [canvas $win.c -yscrollcommand "$win.v set" -xscrollcommand "$win.h set"]
# listbox $win.lBox -width 50 -border 2 -yscrollcommand "$win.yscroll set" -border 1 # listbox $win.lBox -width 50 -border 2 -yscrollcommand "$win.yscroll set" -border 1
ttk::treeview $win.lBox -show headings -height 5\ # ttk::treeview $win.lBox -show headings -height 5\
-columns "variable value path" -displaycolumns "variable value path"\ # -columns "variable value path" -displaycolumns "variable value path"\
-yscrollcommand [list $win.v set] -xscrollcommand [list $win.h set] # -yscrollcommand [list $win.v set] -xscrollcommand [list $win.h set]
ctext $win.lBox -height 5 -font $cfgVariables(font) -wrap none \
-yscrollcommand [list $win.v set] -xscrollcommand [list $win.h set] \
-linemapfg $cfgVariables(lineNumberFG) -linemapbg $cfgVariables(lineNumberBG)
ttk::scrollbar $win.v -orient vertical -command "$win.lBox yview" ttk::scrollbar $win.v -orient vertical -command "$win.lBox yview"
ttk::scrollbar $win.h -orient horizontal -command "$win.lBox xview" ttk::scrollbar $win.h -orient horizontal -command "$win.lBox xview"
@ -196,53 +206,62 @@ proc FindVariablesDialog {txt args} {
grid columnconfigure $win 0 -weight 1 grid columnconfigure $win 0 -weight 1
grid rowconfigure $win 0 -weight 1 grid rowconfigure $win 0 -weight 1
$win.lBox heading variable -text [::msgcat::mc "Variable"] # $win.lBox heading variable -text [::msgcat::mc "Variable"]
$win.lBox heading value -text [::msgcat::mc "Value"] # $win.lBox heading value -text [::msgcat::mc "Value"]
$win.lBox heading path -text [::msgcat::mc "File path"] # $win.lBox heading path -text [::msgcat::mc "File path"]
set height 0 # set height 0
foreach { word } $args { foreach { word } $args {
foreach lst $word { foreach lst $word {
# set l [split $lst " "] # set l [split $lst " "]
puts "[lindex $lst 0] -[lindex $lst 1] -[lindex $lst 2]" puts "[lindex $lst 0] -[lindex $lst 1] -[lindex $lst 2]"
# lappend l2 [lindex $l 0] [lindex $l 1] [file tail [lindex $l 2]] # lappend l2 [lindex $l 0] [lindex $l 1] [file tail [lindex $l 2]]
$win.lBox insert {} end -values $lst -text {1 2 3} # $win.lBox insert {} end -values $lst -text {1 2 3}
$win.lBox insert end "[lindex $lst 0] :: [lindex $lst 1] :: [lindex $lst 2]\n"
# $win.lBox insert end $word # $win.lBox insert end $word
incr height incr height
} }
} }
$win.lBox selection set I001 # $win.lBox selection set I001
# catch { $win.lBox activate 0 ; $win.lBox selection set 0 0 } # catch { $win.lBox activate 0 ; $win.lBox selection set 0 0 }
if { $height > 10 } { set height 10 } if { $height > 10 } { set height 10 }
$win.lBox configure -height $height $win.lBox configure -height $height
bind $win <Escape> { bind $win <Escape> {
destroy $win destroy $win
# focus -force $txt.t focus -force $t.t
break break
} }
bind $win.lBox <Escape> { bind $win.lBox <Escape> {
destroy $win destroy $win
# focus -force $txt.t focus -force $t.t
break break
} }
bind $win.lBox <Return> { bind $win.lBox <Return> {
# set findString [dict get $lexers [dict get $editors $Editor::txt fileType] procFindString] # set findString [dict get $lexers [dict get $editors $Editor::txt fileType] procFindString]
set id [$win.lBox selection] # set id [$win.lBox selection]
set values [$win.lBox item $id -values] # set values [$win.lBox item $id -values]
set key [lindex [split $id "::"] 0] # set key [lindex [split $id "::"] 0]
puts "- $id - $values - $key" #
# puts "- $id - $values - $key"
# regsub -all {PROCNAME} $findString $values str # regsub -all {PROCNAME} $findString $values str
# Editor::FindFunction "$str" # Editor::FindFunction "$str"
destroy .findVariables set path [GetVariableFilePath $win.lBox]
FileOper::Edit [lindex $values 2] if {$path ne ""} {
destroy .findVariables
FileOper::Edit $path
}
# $txt tag remove sel 1.0 end # $txt tag remove sel 1.0 end
# focus $Editor::txt.t # focus $Editor::txt.t
break break
} }
# bind $win.lBox <Double-ButtonPress-1> {Tree::DoublePressItem $win.lBox} # bind $win.lBox <Double-ButtonPress-1> {Tree::DoublePressItem $win.lBox}
bind $win.lBox <ButtonRelease-1> { bind $win.lBox <ButtonRelease-1> {
Tree::PressItem $win.lBox set path [GetVariableFilePath $win.lBox]
if {$path ne ""} {
destroy .findVariables
FileOper::Edit $path
}
break break
} }
@ -255,9 +274,13 @@ proc FindVariablesDialog {txt args} {
if [expr [expr $topHeight - $y] < $winGeom] { if [expr [expr $topHeight - $y] < $winGeom] {
set y [expr $topHeight - $winGeom] set y [expr $topHeight - $winGeom]
} }
ctext::addHighlightClassForRegexp $win.lBox namespaces #4f64ff {::}
$win.lBox highlight 1.0 end
wm geom $win +$x+$y wm geom $win +$x+$y
focus -force $win.lBox $win.lBox see 1.0
$win.lBox focus I001 focus -force $win.lBox.t
# $win.lBox focus I001
} }