Refactoring auto update file structure (tree). Now structure updated when file was saving
Refactoring "Settings" dialog
This commit is contained in:
@@ -421,3 +421,4 @@ proc AboutDialog {} {
|
||||
$w.frmThanks.txtThanks configure -state disable
|
||||
}
|
||||
|
||||
|
||||
|
@@ -61,7 +61,6 @@ proc balloon { widget action args } {
|
||||
} ;# switch action
|
||||
} ;# proc balloon
|
||||
|
||||
|
||||
proc raise_balloon {widget text} {
|
||||
global BALLOON
|
||||
|
||||
@@ -78,11 +77,3 @@ proc raise_balloon {widget text} {
|
||||
update
|
||||
} ;# proc raise_balloon
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
136
lib/editor.tcl
136
lib/editor.tcl
@@ -614,7 +614,7 @@ proc EditFile {tree node fileName} {
|
||||
# set w [$noteBook insert end $node -text "$file" -image [Bitmap::get [file join $imgDir [GetImage $fileName].gif]] \
|
||||
#-background $editor(bg) -foreground $editor(fg)]
|
||||
set w [$noteBook insert end $node -text "$file" -image [Bitmap::get [file join $imgDir [GetImage $fileName].gif]]]
|
||||
|
||||
puts $w
|
||||
# create array with file names #
|
||||
if {[info exists fileList($node)] != 1} {
|
||||
set fileList($node) [list $fileName 0]
|
||||
@@ -643,60 +643,9 @@ proc EditFile {tree node fileName} {
|
||||
set lineNumber 1
|
||||
# Progress start
|
||||
# LabelUpdate .frmStatus.frmProgress.lblProgress "[::msgcat::mc "Opened file in progress"]"
|
||||
|
||||
while {[gets $file line]>=0} {
|
||||
# Insert procedure names into tree #
|
||||
regsub -all {\t} $line " " line
|
||||
$w.text insert end "$line\n"
|
||||
# set progress $lineNumber
|
||||
set keyWord ""
|
||||
set procName ""
|
||||
|
||||
if {$fileExt == "php" || $fileExt == "phtml"} {
|
||||
regexp -nocase -all -- {(function) (.*?)\(} $line match keyWord procName
|
||||
#puts "$keyWord --- $procName"
|
||||
|
||||
} else {
|
||||
scan $line "%s%s" keyWord procName
|
||||
}
|
||||
|
||||
###################
|
||||
#regexp -nocase -all -line -- {proc (::|)(\w+)(::|)(\w+) \{(.*)\} \{} string match v1 v2 v3 v4 v5
|
||||
#regexp -nocase -all -line -- {proc (.*) \{(.*)\}} $line match procName params
|
||||
if {[regexp -nocase -all -line -- {proc (::|)(\w+)(::|)(\w+) \{(.*)\} \{} $line match v1 v2 v3 v4 params]} {
|
||||
set procName "$v1$v2$v3$v4"
|
||||
lappend procList($activeProject) [list $procName [string trim $params]]
|
||||
puts "proc $procName $params"
|
||||
}
|
||||
if {[regexp -nocase -all -line -- {set (\w+)} $line match varName]} {
|
||||
#set varList($activeProject) [list [string trim $varName]]
|
||||
#puts "variable $varName"
|
||||
}
|
||||
|
||||
###################
|
||||
|
||||
# && $procName != ""
|
||||
if {$keyWord == "proc" || $keyWord == "let" || $keyWord == "class" || $keyWord == "sub" || $keyWord == "function" || $keyWord == "fun" } {
|
||||
set dot "_"
|
||||
set openBrace [string first "\{" $line]
|
||||
set closeBrace [expr [string first "\}" $line]-1]
|
||||
set var [string range $line $openBrace end]
|
||||
regsub -all ":" $procName "_" prcNode
|
||||
if {$keyWord == "proc" || $keyWord == "sub" || $keyWord == "function" || $keyWord == "let"} {
|
||||
set img "proc.gif"
|
||||
} elseif {$keyWord == "class"} {
|
||||
set img "class.gif"
|
||||
}
|
||||
if {$keyWord =="proc"} {
|
||||
|
||||
#$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
|
||||
}
|
||||
}
|
||||
#puts [$tree nodes $node]
|
||||
while {[gets $file line] >=0} {
|
||||
ReadFileStructure "openFile" $line $lineNumber $tree $node
|
||||
incr lineNumber
|
||||
}
|
||||
close $file
|
||||
@@ -971,34 +920,55 @@ proc TextOperation {oper} {
|
||||
}
|
||||
unset nb
|
||||
}
|
||||
proc ReadFileStructure {mod line lineNumber tree node} {
|
||||
global projDir workDir imgDir noteBook fontNormal fontBold fileList replace nodeEdit procList
|
||||
global backUpFileCreate fileExt progress editor braceHighLightBG braceHighLightFG activeProject
|
||||
global varList
|
||||
|
||||
# Insert procedure names into tree #
|
||||
regsub -all {\t} $line " " line
|
||||
set w $noteBook.f$node
|
||||
if {$mod eq "openFile"} {
|
||||
$w.text insert end "$line\n"
|
||||
}
|
||||
# set progress $lineNumber
|
||||
set keyWord ""
|
||||
set procName ""
|
||||
|
||||
if {$fileExt == "php" || $fileExt == "phtml"} {
|
||||
regexp -nocase -all -- {(function) (.*?)\(} $line match keyWord procName
|
||||
#puts "$keyWord --- $procName"
|
||||
} else {
|
||||
scan $line "%s%s" keyWord procName
|
||||
}
|
||||
|
||||
###################
|
||||
#regexp -nocase -all -line -- {proc (::|)(\w+)(::|)(\w+) \{(.*)\} \{} string match v1 v2 v3 v4 v5
|
||||
#regexp -nocase -all -line -- {proc (.*) \{(.*)\}} $line match procName params
|
||||
if {[regexp -nocase -all -line -- {proc (::|)(\w+)(::|)(\w+) \{(.*)\} \{} $line match v1 v2 v3 v4 params]} {
|
||||
set procName "$v1$v2$v3$v4"
|
||||
lappend procList($activeProject) [list $procName [string trim $params]]
|
||||
puts "proc $procName $params"
|
||||
}
|
||||
if {$keyWord == "proc" || $keyWord == "let" || $keyWord == "class" || $keyWord == "sub" || $keyWord == "function" || $keyWord == "fun" } {
|
||||
set dot "_"
|
||||
set openBrace [string first "\{" $line]
|
||||
set closeBrace [expr [string first "\}" $line]-1]
|
||||
set var [string range $line $openBrace end]
|
||||
regsub -all ":" $procName "_" prcNode
|
||||
if {$keyWord == "proc" || $keyWord == "sub" || $keyWord == "function" || $keyWord == "let"} {
|
||||
set img "proc.gif"
|
||||
} elseif {$keyWord == "class"} {
|
||||
set img "class.gif"
|
||||
}
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
####################################
|
||||
GetOp
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@@ -29,6 +29,7 @@ proc FileDialog {nbNode operation} {
|
||||
{"Text files" {} TEXT}
|
||||
{"All files" *}
|
||||
}
|
||||
variable tree
|
||||
if {$nbNode eq "files"} {
|
||||
set tree .frmBody.frmCat.noteBook.ffiles.frmTreeFiles.treeFiles
|
||||
} elseif {$nbNode eq "projects"} {
|
||||
@@ -131,9 +132,22 @@ proc FileDialog {nbNode operation} {
|
||||
$noteBook itemconfigure $nbNode -text $file
|
||||
set fileList($nbNode) [list $file 0]
|
||||
} else {
|
||||
set contents [$text get 0.0 end]
|
||||
set fhandle [open [file join $dir $file] "w"]
|
||||
puts $fhandle $contents nonewline
|
||||
set lineNumber 1
|
||||
# Progress start
|
||||
# LabelUpdate .frmStatus.frmProgress.lblProgress "[::msgcat::mc "Opened file in progress"]"
|
||||
set linesCount [$text count -lines $lineNumber.0 end]
|
||||
foreach item [$tree nodes $node] {
|
||||
puts $item
|
||||
$tree delete $item
|
||||
}
|
||||
for {set lineNumber 1} {$lineNumber <= $linesCount} {incr lineNumber} {
|
||||
set line [$text get $lineNumber.0 $lineNumber.end]
|
||||
#puts $line
|
||||
puts $fhandle $line
|
||||
ReadFileStructure "updateFile" $line $lineNumber $tree $node
|
||||
#exit
|
||||
}
|
||||
close $fhandle
|
||||
EditFlag $node [file join $dir $file] 0
|
||||
}
|
||||
@@ -599,3 +613,5 @@ proc FileOperation::FileDialog {tree operation} {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@@ -156,7 +156,7 @@ $m add separator
|
||||
$m add command -label [::msgcat::mc "Print"] -command PrintDialog\
|
||||
-font $fontNormal -accelerator "Ctrl+P"
|
||||
$m add separator
|
||||
$m add command -label [::msgcat::mc "Settings"] -command Settings -font $fontNormal
|
||||
$m add command -label [::msgcat::mc "Settings"] -command {Settings $noteBook} -font $fontNormal
|
||||
$m add separator
|
||||
$m add command -label [::msgcat::mc "Exit"] -command Quit -font $fontNormal -accelerator "Ctrl+Q"
|
||||
|
||||
@@ -376,7 +376,6 @@ $noteBook bindtabs <Button-3> {catch [PopupMenuTab .popupTabs %X %Y]}
|
||||
|
||||
#bind . <Control-udiaeresis> PageTab
|
||||
#bind . <Control-M> PageTab
|
||||
|
||||
bind . <Control-Next> {PageTab 1}
|
||||
bind . <Control-Prior> {PageTab -1}
|
||||
|
||||
@@ -398,3 +397,5 @@ if {[info exists workingProject]} {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@@ -93,3 +93,4 @@ proc GetMenu {m} {
|
||||
|
||||
|
||||
|
||||
|
||||
|
@@ -100,3 +100,4 @@ namespace eval pane {
|
||||
|
||||
|
||||
|
||||
|
||||
|
@@ -1007,5 +1007,6 @@ proc InsertTitle {newFile type} {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@@ -6,31 +6,25 @@
|
||||
######################################################
|
||||
|
||||
## SETTING DIALOG ##
|
||||
proc Settings {} {
|
||||
proc Settings {nBook} {
|
||||
global fontNormal fontBold imgDir workDir
|
||||
global editor color nb topLevelGeometry
|
||||
global main editFrm network
|
||||
global toolBar autoFormat backUpDel backUpCreate backUpShow localeSet localeList wrapSet wrapList
|
||||
set topLevelGeometry [winfo geometry .]
|
||||
set w .pref
|
||||
# destroy the find window if it already exists
|
||||
if {[winfo exists $w]} {
|
||||
destroy $w
|
||||
if {[$nBook index settings] != -1} {
|
||||
$nBook delete settings
|
||||
}
|
||||
set w [$nBook insert end settings -text [::msgcat::mc "Settings"]]
|
||||
$nBook raise settings
|
||||
|
||||
toplevel $w
|
||||
wm title $w [::msgcat::mc "Settings"]
|
||||
# wm resizable $w 0 0
|
||||
wm geometry $w 464x450+0+0
|
||||
wm transient $w .
|
||||
#frame $w.frmMain -borderwidth 1 -bg $editor(bg)
|
||||
# destroy the find window if it already exists
|
||||
frame $w.frmMain -borderwidth 1
|
||||
pack $w.frmMain -side top -fill both -expand 1
|
||||
#frame $w.frmBtn -borderwidth 1 -bg $editor(bg)
|
||||
frame $w.frmBtn -borderwidth 1
|
||||
pack $w.frmBtn -side top -fill x
|
||||
|
||||
set nb [NoteBook $w.frmMain.noteBook -font $fontBold -side top -bg $editor(bg) -fg $editor(fg)]
|
||||
set nb [NoteBook $w.frmMain.noteBook -font $fontBold -side bottom -bg $editor(bg) -fg $editor(fg)]
|
||||
pack $nb -fill both -expand true -padx 2 -pady 2
|
||||
|
||||
button $w.frmBtn.btnFind -text [::msgcat::mc "Save"] -font $fontNormal -width 12 -relief groove \
|
||||
@@ -134,11 +128,12 @@ proc Settings {} {
|
||||
puts $file "\nset workingProject \"\""
|
||||
|
||||
close $file
|
||||
destroy .pref
|
||||
#destroy $w
|
||||
.frmBody.frmWork.noteBook delete settings
|
||||
}
|
||||
button $w.frmBtn.btnCancel -text [::msgcat::mc "Close"] -relief groove -width 12\
|
||||
-font $fontNormal -command "destroy $w" -bg $editor(bg) -fg $editor(fg)
|
||||
pack $w.frmBtn.btnFind $w.frmBtn.btnCancel -fill x -padx 2 -pady 2 -side left
|
||||
-font $fontNormal -command "destroy $w; $nBook delete settings " -bg $editor(bg) -fg $editor(fg)
|
||||
pack $w.frmBtn.btnFind $w.frmBtn.btnCancel -fill x -padx 5 -pady 5 -side right
|
||||
|
||||
################## MAIN PREF ##########################
|
||||
set main [$nb insert end main -text "[::msgcat::mc "Main"]"]
|
||||
@@ -229,7 +224,7 @@ proc Settings {} {
|
||||
pack $frm_7.lblTgzDir -side left
|
||||
pack $frm_7.txtTgzDir -side left -fill x -expand true
|
||||
pack $frm_7.btnTgzDir -side left
|
||||
|
||||
|
||||
set frm_8 [frame $main.frmRpmNamed -bg $editor(bg)]
|
||||
label $frm_8.lblRpmNamed -text [::msgcat::mc "RPM file mask"] -width 30 -anchor w\
|
||||
-font $fontNormal -fg $editor(fg)
|
||||
@@ -340,7 +335,7 @@ proc Settings {} {
|
||||
|
||||
set frm_15 [frame $editFrm.frmAutoFormat -bg $editor(bg)]
|
||||
label $frm_15.lblAutoFormat -text [::msgcat::mc "Text autoformat"]\
|
||||
-width 30 -anchor w -font $fontNormal
|
||||
-width 30 -anchor w -font $fontNormal
|
||||
checkbutton $frm_15.chkAutoFormat -text "" -variable autoFormat \
|
||||
-font $fontNormal -onvalue true -offvalue false
|
||||
pack $frm_15.lblAutoFormat -side left
|
||||
@@ -878,4 +873,3 @@ proc SaveSettings {} {
|
||||
$noteBook raise [$noteBook page end]
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user