Refactoring auto update file structure (tree). Now structure updated when file was saving

Refactoring "Settings" dialog
0.4.6
Sergey Kalinin 2018-02-20 14:13:47 +03:00
parent 309a88874c
commit 1f36044d66
12 changed files with 122 additions and 148 deletions

4
BUGS
View File

@ -28,7 +28,3 @@ balloon окне показать формат этой команды (такж
- При установки переменной editor(wrap) значения none на длинных строках при появлениии нижнего скролбара наблюдается глюк пока не объяснимый :( - При установки переменной editor(wrap) значения none на длинных строках при появлениии нижнего скролбара наблюдается глюк пока не объяснимый :(
Скрол бар начинает мерцать (то появиться то исчезнет) Скрол бар начинает мерцать (то появиться то исчезнет)

View File

@ -6,6 +6,10 @@
######################################################### #########################################################
0.4.5 0.4.5
20.02.2018
- Refactoring auto update file structure (tree). Now structure updated when file was saving
- Refactoring "Settings" dialog
19.02.2018 19.02.2018
- Fix "New file" ctrl+n hotkey - Fix "New file" ctrl+n hotkey
@ -380,6 +384,3 @@ characters to the right of the insertion cursor.

View File

@ -421,3 +421,4 @@ proc AboutDialog {} {
$w.frmThanks.txtThanks configure -state disable $w.frmThanks.txtThanks configure -state disable
} }

View File

@ -61,7 +61,6 @@ proc balloon { widget action args } {
} ;# switch action } ;# switch action
} ;# proc balloon } ;# proc balloon
proc raise_balloon {widget text} { proc raise_balloon {widget text} {
global BALLOON global BALLOON
@ -78,11 +77,3 @@ proc raise_balloon {widget text} {
update update
} ;# proc raise_balloon } ;# proc raise_balloon

View File

@ -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]] \ # set w [$noteBook insert end $node -text "$file" -image [Bitmap::get [file join $imgDir [GetImage $fileName].gif]] \
#-background $editor(bg) -foreground $editor(fg)] #-background $editor(bg) -foreground $editor(fg)]
set w [$noteBook insert end $node -text "$file" -image [Bitmap::get [file join $imgDir [GetImage $fileName].gif]]] set w [$noteBook insert end $node -text "$file" -image [Bitmap::get [file join $imgDir [GetImage $fileName].gif]]]
puts $w
# create array with file names # # create array with file names #
if {[info exists fileList($node)] != 1} { if {[info exists fileList($node)] != 1} {
set fileList($node) [list $fileName 0] set fileList($node) [list $fileName 0]
@ -643,60 +643,9 @@ proc EditFile {tree node fileName} {
set lineNumber 1 set lineNumber 1
# Progress start # Progress start
# LabelUpdate .frmStatus.frmProgress.lblProgress "[::msgcat::mc "Opened file in progress"]" # LabelUpdate .frmStatus.frmProgress.lblProgress "[::msgcat::mc "Opened file in progress"]"
#puts [$tree nodes $node]
while {[gets $file line]>=0} { while {[gets $file line] >=0} {
# Insert procedure names into tree # ReadFileStructure "openFile" $line $lineNumber $tree $node
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
}
}
incr lineNumber incr lineNumber
} }
close $file close $file
@ -971,34 +920,55 @@ proc TextOperation {oper} {
} }
unset nb 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 GetOp

View File

@ -29,6 +29,7 @@ proc FileDialog {nbNode operation} {
{"Text files" {} TEXT} {"Text files" {} TEXT}
{"All files" *} {"All files" *}
} }
variable tree
if {$nbNode eq "files"} { if {$nbNode eq "files"} {
set tree .frmBody.frmCat.noteBook.ffiles.frmTreeFiles.treeFiles set tree .frmBody.frmCat.noteBook.ffiles.frmTreeFiles.treeFiles
} elseif {$nbNode eq "projects"} { } elseif {$nbNode eq "projects"} {
@ -131,9 +132,22 @@ proc FileDialog {nbNode operation} {
$noteBook itemconfigure $nbNode -text $file $noteBook itemconfigure $nbNode -text $file
set fileList($nbNode) [list $file 0] set fileList($nbNode) [list $file 0]
} else { } else {
set contents [$text get 0.0 end]
set fhandle [open [file join $dir $file] "w"] 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 close $fhandle
EditFlag $node [file join $dir $file] 0 EditFlag $node [file join $dir $file] 0
} }
@ -599,3 +613,5 @@ proc FileOperation::FileDialog {tree operation} {

View File

@ -156,7 +156,7 @@ $m add separator
$m add command -label [::msgcat::mc "Print"] -command PrintDialog\ $m add command -label [::msgcat::mc "Print"] -command PrintDialog\
-font $fontNormal -accelerator "Ctrl+P" -font $fontNormal -accelerator "Ctrl+P"
$m add separator $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 separator
$m add command -label [::msgcat::mc "Exit"] -command Quit -font $fontNormal -accelerator "Ctrl+Q" $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-udiaeresis> PageTab
#bind . <Control-M> PageTab #bind . <Control-M> PageTab
bind . <Control-Next> {PageTab 1} bind . <Control-Next> {PageTab 1}
bind . <Control-Prior> {PageTab -1} bind . <Control-Prior> {PageTab -1}
@ -398,3 +397,5 @@ if {[info exists workingProject]} {

View File

@ -93,3 +93,4 @@ proc GetMenu {m} {

View File

@ -100,3 +100,4 @@ namespace eval pane {

View File

@ -1007,5 +1007,6 @@ proc InsertTitle {newFile type} {

View File

@ -6,31 +6,25 @@
###################################################### ######################################################
## SETTING DIALOG ## ## SETTING DIALOG ##
proc Settings {} { proc Settings {nBook} {
global fontNormal fontBold imgDir workDir global fontNormal fontBold imgDir workDir
global editor color nb topLevelGeometry global editor color nb topLevelGeometry
global main editFrm network global main editFrm network
global toolBar autoFormat backUpDel backUpCreate backUpShow localeSet localeList wrapSet wrapList global toolBar autoFormat backUpDel backUpCreate backUpShow localeSet localeList wrapSet wrapList
set topLevelGeometry [winfo geometry .] set topLevelGeometry [winfo geometry .]
set w .pref if {[$nBook index settings] != -1} {
# destroy the find window if it already exists $nBook delete settings
if {[winfo exists $w]} {
destroy $w
} }
set w [$nBook insert end settings -text [::msgcat::mc "Settings"]]
$nBook raise settings
toplevel $w # destroy the find window if it already exists
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)
frame $w.frmMain -borderwidth 1 frame $w.frmMain -borderwidth 1
pack $w.frmMain -side top -fill both -expand 1 pack $w.frmMain -side top -fill both -expand 1
#frame $w.frmBtn -borderwidth 1 -bg $editor(bg)
frame $w.frmBtn -borderwidth 1 frame $w.frmBtn -borderwidth 1
pack $w.frmBtn -side top -fill x 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 pack $nb -fill both -expand true -padx 2 -pady 2
button $w.frmBtn.btnFind -text [::msgcat::mc "Save"] -font $fontNormal -width 12 -relief groove \ button $w.frmBtn.btnFind -text [::msgcat::mc "Save"] -font $fontNormal -width 12 -relief groove \
@ -134,11 +128,12 @@ proc Settings {} {
puts $file "\nset workingProject \"\"" puts $file "\nset workingProject \"\""
close $file close $file
destroy .pref #destroy $w
.frmBody.frmWork.noteBook delete settings
} }
button $w.frmBtn.btnCancel -text [::msgcat::mc "Close"] -relief groove -width 12\ button $w.frmBtn.btnCancel -text [::msgcat::mc "Close"] -relief groove -width 12\
-font $fontNormal -command "destroy $w" -bg $editor(bg) -fg $editor(fg) -font $fontNormal -command "destroy $w; $nBook delete settings " -bg $editor(bg) -fg $editor(fg)
pack $w.frmBtn.btnFind $w.frmBtn.btnCancel -fill x -padx 2 -pady 2 -side left pack $w.frmBtn.btnFind $w.frmBtn.btnCancel -fill x -padx 5 -pady 5 -side right
################## MAIN PREF ########################## ################## MAIN PREF ##########################
set main [$nb insert end main -text "[::msgcat::mc "Main"]"] 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.lblTgzDir -side left
pack $frm_7.txtTgzDir -side left -fill x -expand true pack $frm_7.txtTgzDir -side left -fill x -expand true
pack $frm_7.btnTgzDir -side left pack $frm_7.btnTgzDir -side left
set frm_8 [frame $main.frmRpmNamed -bg $editor(bg)] set frm_8 [frame $main.frmRpmNamed -bg $editor(bg)]
label $frm_8.lblRpmNamed -text [::msgcat::mc "RPM file mask"] -width 30 -anchor w\ label $frm_8.lblRpmNamed -text [::msgcat::mc "RPM file mask"] -width 30 -anchor w\
-font $fontNormal -fg $editor(fg) -font $fontNormal -fg $editor(fg)
@ -340,7 +335,7 @@ proc Settings {} {
set frm_15 [frame $editFrm.frmAutoFormat -bg $editor(bg)] set frm_15 [frame $editFrm.frmAutoFormat -bg $editor(bg)]
label $frm_15.lblAutoFormat -text [::msgcat::mc "Text autoformat"]\ 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 \ checkbutton $frm_15.chkAutoFormat -text "" -variable autoFormat \
-font $fontNormal -onvalue true -offvalue false -font $fontNormal -onvalue true -offvalue false
pack $frm_15.lblAutoFormat -side left pack $frm_15.lblAutoFormat -side left
@ -878,4 +873,3 @@ proc SaveSettings {} {
$noteBook raise [$noteBook page end] $noteBook raise [$noteBook page end]
} }

View File

@ -112,36 +112,36 @@ source [file join $dataDir main.tcl]
#option add *tree.foreground red widgetDefault #option add *tree.foreground red widgetDefault
# Set colors for widgets # Set colors for widgets
option add *Frame.Background $editor(bg) startupFile option add *Frame.Background $editor(bg) interactive
option add *ScrollableFrame.Background $editor(bg) startupFile option add *ScrollableFrame.Background $editor(bg) interactive
option add *ScrolledWindow.Background $editor(bg) startupFile option add *ScrolledWindow.Background $editor(bg) interactive
option add *Button.Foreground $editor(fg) startupFile option add *Button.Foreground $editor(fg) interactive
option add *Button.Background $editor(bg) startupFile option add *Button.Background $editor(bg) interactive
option add *Button.activeBackground $editor(bg) userDefault option add *Button.activeBackground $editor(bg) userDefault
option add *Button.activeForeground $editor(fg) userDefault option add *Button.activeForeground $editor(fg) userDefault
option add *Entry.Foreground $editor(fg) startupFile option add *Entry.Foreground $editor(fg) interactive
option add *Entry.Background $editor(bg) startupFile option add *Entry.Background $editor(bg) interactive
option add *Label.Foreground $editor(fg) startupFile option add *Label.Foreground $editor(fg) interactive
option add *Label.Background $editor(bg) interactive option add *Label.Background $editor(bg) interactive
option add *Checkbox.Foreground $editor(fg) startupFile option add *Checkbox.Foreground $editor(fg) interactive
option add *Checkbox.Background $editor(bg) startupFile option add *Checkbox.Background $editor(bg) interactive
option add *Checkbutton.Foreground $editor(fg) startupFile option add *Checkbutton.Foreground $editor(fg) interactive
option add *Checkbutton.Background $editor(bg) startupFile option add *Checkbutton.Background $editor(bg) interactive
option add *Combobox.Foreground $editor(fg) startupFile option add *Combobox.Foreground $editor(fg) interactive
option add *Combobox.Background $editor(bg) startupFile option add *Combobox.Background $editor(bg) interactive
option add *Text.Foreground $editor(fg) startupFile option add *Text.Foreground $editor(fg) interactive
option add *Text.Background $editor(bg) startupFile option add *Text.Background $editor(bg) interactive
option add *Tree.Background $editor(bg) startupFile option add *Tree.Background $editor(bg) interactive
option add *Tree.Foreground $editor(fg) startupFile option add *Tree.Foreground $editor(fg) interactive
option add *Scrollbar.Background $editor(bg) startupFile option add *Scrollbar.Background $editor(bg) interactive
option add *Canvas.Background $editor(bg) startupFile option add *Canvas.Background $editor(bg) interactive
option add *Canvas.Foreground $editor(fg) startupFile option add *Canvas.Foreground $editor(fg) interactive
option add *Node.Foreground $editor(fg) startupFile option add *Node.Foreground $editor(fg) interactive
option add *NoteBook.bg $editor(bg) startupFile option add *NoteBook.bg $editor(bg) interactive
option add *NoteBook.fg $editor(fg) startupFile option add *NoteBook.fg $editor(fg) interactive
option add *Listbox.Foreground $editor(fg) startupFile option add *Listbox.Foreground $editor(fg) interactive
option add *Listbox.Background $editor(bg) startupFile option add *Listbox.Background $editor(bg) interactive
#option add *Button.font $guifont userDefault #option add *Button.font $guifont userDefault
#option add *Label.font $guifont userDefault #option add *Label.font $guifont userDefault
@ -176,3 +176,4 @@ option add *Dialog.msg.background $editor(bg)
# #
# #