Добавлены опции для включсения полджсказок по переменным и процедурам

This commit is contained in:
svkalinin 2022-10-28 13:27:54 +03:00
parent a981fdea6d
commit bcfb9fb7df
5 changed files with 101 additions and 6 deletions

View File

@ -56,6 +56,8 @@ selectBorder=0
editorWrap=word editorWrap=word
lineNumberShow=true lineNumberShow=true
tabSize=4 tabSize=4
procedureHelper=false
variableHelper=true
" "
proc Config::create {dir} { proc Config::create {dir} {
set cfgFile [open [file join $dir projman.ini] "w+"] set cfgFile [open [file join $dir projman.ini] "w+"]

View File

@ -367,13 +367,105 @@ namespace eval Editor {
} }
proc VarHelper {x y w word} {
global editors lexers variables
variable txt
variable win
# set txt $w.frmText.t
set txt $w
set win .varhelper
# puts "$x $y $w $word"
set varList [dict get $editors $txt variableList]
set findedVars ""
foreach i [lsearch -all $varList $word*] {
# puts [lindex $varList $i]
set item [lindex [lindex $varList $i] 0]
# puts $item
if {[lsearch $findedVars $item] eq "-1"} {
lappend findedVars $item
}
}
if { [winfo exists $win] } { destroy $win }
if {$findedVars eq ""} {
return
}
toplevel $win
wm transient $win .
wm overrideredirect $win 1
listbox $win.lBox -width 30 -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 } $findedVars {
$win.lBox insert end $word
}
catch { $win.lBox activate 0 ; $win.lBox selection set 0 0 }
if { [set height [llength $findedVars]] > 10 } { set height 10 }
$win.lBox configure -height $height
bind $win <Escape> {
destroy $Editor::win
focus -force $Editor::txt.t
break
}
bind $win.lBox <Escape> {
destroy $Editor::win
focus -force $Editor::txt.t
break
}
bind $win.lBox <Return> {
set findString [dict get $lexers [dict get $editors $Editor::txt fileType] procFindString]
set values [.gotofunction.lBox get [.gotofunction.lBox curselection]]
regsub -all {PROCNAME} $findString $values str
Editor::FindFunction $Editor::txt "$str"
destroy .gotofunction
$Editor::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
}
proc ReleaseKey {k txt} { proc ReleaseKey {k txt} {
global cfgVariables
set pos [$txt index insert] set pos [$txt index insert]
SearchBrackets $txt
switch $k {
Return {
set lineNum [lindex [split $pos "."] 0] set lineNum [lindex [split $pos "."] 0]
set posNum [lindex [split $pos "."] 1] set posNum [lindex [split $pos "."] 1]
SearchBrackets $txt
# set lineStart [$txt index "$pos linestart"]
# puts "$pos $lineStart"
if {$cfgVariables(variableHelper) eq "true"} {
set lastSymbol [string last "$" [$txt get $lineNum.0 $pos]]
if {$lastSymbol ne "-1"} {
set word [string trim [$txt get $lineNum.[expr $lastSymbol + 1] $pos]]
# puts "$pos; $lineNum; $pos; $lastSymbol; $word"
set box [$txt bbox insert]
set box_x [expr [lindex $box 0] + [winfo rootx $txt] ]
set box_y [expr [lindex $box 1] + [winfo rooty $txt] + [lindex $box 3] ]
Editor::VarHelper $box_x $box_y $txt $word
}
}
if {$cfgVariables(procedureHelper) eq "true"} {
puts "Find proc"
}
switch $k {
Return {
regexp {^(\s*)} [$txt get [expr $lineNum - 1].0 [expr $lineNum - 1].end] -> spaceStart regexp {^(\s*)} [$txt get [expr $lineNum - 1].0 [expr $lineNum - 1].end] -> spaceStart
# puts "$pos, $lineNum, $posNum, >$spaceStart<" # puts "$pos, $lineNum, $posNum, >$spaceStart<"
$txt insert insert $spaceStart $txt insert insert $spaceStart

View File

@ -141,6 +141,7 @@ namespace eval Git {
proc Diff {f} { proc Diff {f} {
global cfgVariables activeProject global cfgVariables activeProject
set cmd exec set cmd exec
set res ""
lappend cmd $cfgVariables(gitCommand) lappend cmd $cfgVariables(gitCommand)
lappend cmd "diff" lappend cmd "diff"
lappend cmd "--" lappend cmd "--"

View File

@ -69,7 +69,7 @@ proc ResetModifiedFlag {w} {
$w.frmText.t edit modified false $w.frmText.t edit modified false
set modified($w) "false" set modified($w) "false"
set lbl [string trimleft [$nbEditor tab $w -text] "* "] set lbl [string trimleft [$nbEditor tab $w -text] "* "]
puts "ResetModifiedFlag: $lbl" # puts "ResetModifiedFlag: $lbl"
$nbEditor tab $w -text $lbl $nbEditor tab $w -text $lbl
} }
proc SetModifiedFlag {w} { proc SetModifiedFlag {w} {
@ -77,7 +77,7 @@ proc SetModifiedFlag {w} {
#$w.frmText.t edit modified false #$w.frmText.t edit modified false
set modified($w) "true" set modified($w) "true"
set lbl [$nbEditor tab $w -text] set lbl [$nbEditor tab $w -text]
puts "SetModifiedFlag: $w; $modified($w); >$lbl<" # puts "SetModifiedFlag: $w; $modified($w); >$lbl<"
if {[regexp -nocase -all -- {^\*} $lbl match] == 0} { if {[regexp -nocase -all -- {^\*} $lbl match] == 0} {
set lbl "* $lbl" set lbl "* $lbl"
} }

View File

@ -10,7 +10,7 @@ exec wish "$0" -- "$@"
###################################################### ######################################################
# Version: 2.0.0 # Version: 2.0.0
# Release: alpha # Release: alpha
# Build: 21102022145927 # Build: 28102022132657
###################################################### ######################################################
# определим текущую версию, релиз и т.д. # определим текущую версию, релиз и т.д.