Fixed AddToProj procedure for file browser tree

Disable OpComplite procedure
This commit is contained in:
Sergey Kalinin 2018-02-22 15:45:46 +03:00
parent 9f4ee1ad33
commit 830bcfeb2f
5 changed files with 102 additions and 147 deletions

View File

@ -1,14 +1,16 @@
#########################################################
##########################################################
# Tcl/Tk Project Manager
# Distributed under GNU Public License
# Copyright (c) "Sergey Kalinin", 2001, http://nuk-svk.ru
# Author: Sergey Kalinin banzaj28@yandex.ru
#########################################################
##########################################################
0.4.5
22.02.2018
- Refactoring Settigs procedure source code
- Some changes into messages files (localisation)
- Fixed AddToProj procedure for file browser tree
- Disable OpComplite procedure
20.02.2018
- Refactoring auto update file structure (tree). Now structure updated when file was saving
@ -388,8 +390,3 @@ characters to the right of the insertion cursor.
- Fix small error with delete project procedure
- Fix uncorrect cursor position counter into editor

View File

@ -20,6 +20,29 @@ proc GetOp {} {
set opList(method) "\{\} \{\n\n\}"
set opList(class) "\{\n\n\}"
}
## COMPLITE PRODEDURE AND OPERATOR ##
proc OpComplite {text fileExt node} {
global opList autoFormat fileList
if {$node == "newproj" || $node == "settings" || $node == "about"} {return}
set pos [$text index insert]
set line [lindex [split $pos "."] 0]
set posNum [lindex [split $pos "."] 1]
set string [$text get $line.0 $pos]
set first [string wordstart $string [expr $posNum-1]]
set op [string range $string $first $posNum]
if {[info exists opList($op)] == 1} {
if {[string match "*\{" [$text get $pos $line.end]] != 1} {
$text insert $pos $opList($op)
set x [expr $posNum + 2]
$text mark set insert $line.$posNum
$text see $line.$posNum
} else {
return
}
}
}
## Alexander Dederer (aka Korwin) dederer-a@mail.ru ##
## SETTING DEFAULT STYLE FOR TEXT WIDGET ##
proc SetDefStyle { text args } {
@ -364,28 +387,6 @@ proc Replace {text incr} {
}
# focus -force .replace
}
## COMPLITE PRODEDURE AND OPERATOR ##
proc OpComplite {text fileExt node} {
global opList autoFormat fileList
if {$node == "newproj" || $node == "settings" || $node == "about"} {return}
set pos [$text index insert]
set line [lindex [split $pos "."] 0]
set posNum [lindex [split $pos "."] 1]
set string [$text get $line.0 $pos]
set first [string wordstart $string [expr $posNum-1]]
set op [string range $string $first $posNum]
if {[info exists opList($op)] == 1} {
if {[string match "*\{" [$text get $pos $line.end]] != 1} {
$text insert $pos $opList($op)
set x [expr $posNum + 2]
$text mark set insert $line.$posNum
$text see $line.$posNum
} else {
return
}
}
}
## OPEN AND CLOSE BRACE HIGHLIGHT ##
proc BraceHighLight {text} {
set pos [$text index insert]
@ -416,37 +417,6 @@ proc PageTab {key} {
}
}
proc _PageTab {} {
global noteBook tree fileList editor
set nodeList [$noteBook pages 0 end]
set length [llength $nodeList]
set node [$noteBook raise]
set nodeIndex [$noteBook index $node]
if {$nodeIndex == [expr $length-1]} {
set nextNode [$noteBook page 0]
} else {
set nextNode [$noteBook page [expr $nodeIndex + 1]]
}
$noteBook raise $nextNode
if {$nextNode == "newproj" || $nextNode == "settings" || $nextNode == "about" || $nextNode == "debug"} {
return
} else {
$tree selection set $nextNode
$tree see $nextNode
set item [$tree itemcget $nextNode -data]
focus -force $noteBook.f$nextNode.text
LabelUpdate .frmStatus.frmHelp.lblHelp "[FileAttr $item]"
LabelUpdate .frmStatus.frmFile.lblFile "[file size $item] b."
if {[lindex $fileList($nextNode) 1] == 0} {
LabelUpdate .frmStatus.frmProgress.lblProgress ""
$noteBook itemconfigure $node -foreground $editor(nbNormal)
} else {
LabelUpdate .frmStatus.frmProgress.lblProgress [::msgcat::mc "File modify"]
$noteBook itemconfigure $node -foreground $editor(nbModify)
}
}
}
## RAISED NOTEBOOK TAB IF CLICK MOUSE BUTTON ##
proc PageRaise {tree node} {
global noteBook fileList editor nodeEdit noteBookFiles
@ -744,7 +714,7 @@ proc EditFile {tree node fileName} {
bind $text <Key-space> {
if {$nodeEdit == ""} {return}
set textEdit "$noteBook.f$nodeEdit.text"
OpComplite $textEdit $fileExt $nodeEdit
#OpComplite $textEdit $fileExt $nodeEdit
if {[lindex $fileList($nodeEdit) 1] == 0} {
set fileList($nodeEdit) [list [lindex $fileList($nodeEdit) 0] 1]
LabelUpdate .frmStatus.frmProgress.lblProgress [::msgcat::mc "File modify"]
@ -981,6 +951,3 @@ proc ReadFileStructure {mod line lineNumber tree node} {
####################################
GetOp

View File

@ -129,9 +129,9 @@ menubutton .frmMenu.mnuFile -text [::msgcat::mc "File"] -menu .frmMenu.mnuFile.m
set m [menu .frmMenu.mnuFile.m -bg $editor(bg) -fg $editor(fg)]
$m add cascade -label [::msgcat::mc "New"] -menu $m.new -font $fontNormal
set mn [menu $m.new -bg $editor(bg) -fg $editor(fg)]
$mn add command -label [::msgcat::mc "New file"] -command {AddToProjDialog file}\
$mn add command -label [::msgcat::mc "New file"] -command {AddToProjDialog file [$noteBookFiles raise]}\
-font $fontNormal -accelerator "Ctrl+N"
$mn add command -label [::msgcat::mc "New directory"] -command {AddToProjDialog directory}\
$mn add command -label [::msgcat::mc "New directory"] -command {AddToProjDialog directory [$noteBookFiles raise]}\
-font $fontNormal -accelerator "Ctrl+N"
$mn add command -label [::msgcat::mc "New project"] -command {NewProjDialog "new"}\
-font $fontNormal
@ -222,8 +222,8 @@ bind . <F8> {MakeProj compile proj}
bind . <Control-F8> {MakeProj compile file}
bind . <F9> {MakeProj run proj}
bind . <Control-F9> {MakeProj run file}
bind . <Control-ograve> {AddToProjDialog file}
bind . <Control-n> {AddToProjDialog file}
bind . <Control-ograve> {AddToProjDialog file [$noteBookFiles raise]}
bind . <Control-n> {AddToProjDialog file [$noteBookFiles raise]}
#bind . <Control-ocircumflex> AddToProjDialog
#bind . <Control-a> AddToProjDialog
bind . <Control-eacute> Quit
@ -315,12 +315,14 @@ bind $frmTree.tree.c <Return> {
TreeDoubleClick $tree $node
}
$noteBookFiles bindtabs <ButtonRelease-1> "FileNotePageRaise [$noteBookFiles raise]"
## POPUP FILE-MENU ##
set m .popupFile
menu $m -font $fontNormal -bg $editor(bg) -fg $editor(fg)
$m add command -label [::msgcat::mc "New file"] -command {AddToProjDialog file}\
$m add command -label [::msgcat::mc "New file"] -command {AddToProjDialog file [$noteBookFiles raise]}\
-font $fontNormal -accelerator "Ctrl+N"
$m add command -label [::msgcat::mc "New directory"] -command {AddToProjDialog directory}\
$m add command -label [::msgcat::mc "New directory"] -command {AddToProjDialog directory [$noteBookFiles raise]}\
-font $fontNormal -accelerator "Alt + Ctrl+N"
$m add command -label [::msgcat::mc "Open"] -command {FileDialog [$noteBookFiles raise] open}\
-font $fontNormal -accelerator "Ctrl+O" -state disable
@ -342,7 +344,7 @@ $m add command -label [::msgcat::mc "Compile file"] -command {MakeProj compile f
$m add command -label [::msgcat::mc "Run file"] -command {MakeProj run file} -font $fontNormal \
-accelerator "Ctrl+F9"
$m add separator
$m add command -label [::msgcat::mc "Add to existing project"] -command {AddToProjDialog ""} \
$m add command -label [::msgcat::mc "Add to existing project"] -command {AddToProjDialog "" [$noteBookFiles raise]} \
-font $fontNormal -state disable
$m add command -label [::msgcat::mc "Add as new project"] -command {OpenProj [$noteBookFiles raise]} -font $fontNormal
@ -393,11 +395,3 @@ if {[info exists workingProject]} {
}
}

View File

@ -1,12 +1,10 @@
#######################################
##################################################
# Tcl/Tk Project Manager
# Distributed under GNU Public License
# Author: Serge Kalinin banzaj28@yandex.ru
# Copyright (c) "https://nuk-svk.ru", 2018,
# Home: https://bitbucket.org/svk28/projman
#######################################
## ADD FILE INTO PROJECTS ##
##################################################
proc NewProj {type proj l} {
global fontNormal fontBold tree projDir workDir activeProject fileList noteBook imgDir prjDir
@ -499,21 +497,23 @@ proc AddNewProjectIntoTree {proj} {
}
}
proc AddToProj {fileName mode} {
global projDir workDir activeProject tree noteBook fontNormal imgDir tree
## ADD FILE INTO PROJECTS ##
proc AddToProj {fileName mode workingTree} {
global projDir workDir activeProject noteBook fontNormal imgDir
set type [string trim [file extension $fileName] {.}]
destroy .addtoproj
set node [$tree selection get]
set fullPath [$tree itemcget $node -data]
set node [$workingTree selection get]
#puts "$fileName $mode $workingTree $node"
set fullPath [$workingTree itemcget $node -data]
if {[file isdirectory $fullPath] == 1} {
set dir $fullPath
set parentNode $node
} else {
set dir [file dirname $fullPath]
set parentNode [$tree parent $node]
set parentNode [$workingTree parent $node]
}
#puts "$node $parentNode $workingTree $fullPath"
if {$type == "tcl"} {
set img "tcl"
@ -548,12 +548,12 @@ proc AddToProj {fileName mode} {
set name [file rootname $fileName]
set ext [string range [file extension $fileName] 1 end]
set subNode "$name$dot$ext"
$tree insert end $parentNode $subNode -text $fileName \
$workingTree insert end $parentNode $subNode -text $fileName \
-data [file join $dir $fileName] -open 1\
-image [Bitmap::get [file join $imgDir $img.gif]]\
-font $fontNormal
if {[$tree itemcget $activeProject -open] == 0} {
$tree itemconfigure $activeProject -open 1
if {[$workingTree itemcget $parentNode -open] == 0} {
$workingTree itemconfigure $parentNode -open 1
}
set file [file join $dir $fileName]
@ -565,17 +565,25 @@ proc AddToProj {fileName mode} {
EditFile [GetTreeForNode $subNode] $subNode [file join $dir $fileName]
}
## ADD FILE INTO PROJECT DIALOG##
proc AddToProjDialog {mode} {
global projDir workDir activeProject imgDir tree mod
proc AddToProjDialog {mode node} {
global projDir workDir activeProject imgDir mod workingTree
set mod $mode
if {$activeProject == ""} {
set answer [tk_messageBox\
-message "[::msgcat::mc "Not found active project"]"\
-type ok -icon warning]
case $answer {
ok {return 0}
}
if {$node eq "files"} {
set workingTree .frmBody.frmCat.noteBook.ffiles.frmTreeFiles.treeFiles
} elseif {$node eq "projects"} {
set workingTree .frmBody.frmCat.noteBook.fprojects.frmTree.tree
} else {
puts "Error node"
return
}
# if {$activeProject == ""} {
# set answer [tk_messageBox\
# -message "[::msgcat::mc "Not found active project"]"\
# -type ok -icon warning]
# case $answer {
# ok {return 0}
# }
# }
set w .addtoproj
if {[winfo exists $w]} {
@ -596,17 +604,19 @@ proc AddToProjDialog {mode} {
entry $w.frmCanv.entImgTcl
pack $w.frmCanv.lblImgTcl $w.frmCanv.entImgTcl -expand true -padx 5 -pady 5 -side top
button $w.frmBtn.btnOk -text [::msgcat::mc "Create"] -relief groove -command {
AddToProj [.addtoproj.frmCanv.entImgTcl get] $mod
}
button $w.frmBtn.btnOk -text [::msgcat::mc "Create"] -relief groove \
-command {AddToProj [.addtoproj.frmCanv.entImgTcl get] $mod $workingTree}
button $w.frmBtn.btnCancel -text [::msgcat::mc "Close"] -command "destroy $w" -relief groove
pack $w.frmBtn.btnOk $w.frmBtn.btnCancel -padx 2 -pady 2 -fill x -side left
bind $w <Escape> "destroy .addtoproj"
bind $w.frmCanv.entImgTcl <Return> {
AddToProj [.addtoproj.frmCanv.entImgTcl get] $mod
AddToProj [.addtoproj.frmCanv.entImgTcl get] $mod $workingTree
}
focus -force $w.frmCanv.entImgTcl
puts "$node $workingTree $mode"
#unset type
}
proc AddToProjDialog_ {} {
@ -987,27 +997,3 @@ proc InsertTitle {newFile type} {
close $pipe
}

View File

@ -387,8 +387,13 @@ proc GetProj {tree} {
## SHOW PUP-UP MENUS ##
proc PopupMenuFileTree {treeFiles x y} {
#global fontNormal fontBold imgDir activeProject
#set node [$treeFiles selection get]
if {[$treeFiles selection get] != ""} {
set node [$treeFiles selection get]
$treeFiles selection set $node
} else {
return
}
#set item [$treeFiles itemcget $node -data]
if {[info exists fileList($node)] != 1} {
# set fileList($node) $item
@ -398,16 +403,14 @@ proc PopupMenuFileTree {treeFiles x y} {
proc PopupMenuTree {x y} {
global tree fontNormal fontBold imgDir activeProject
if {[$tree selection get] != ""} {
set node [$tree selection get]
if {$node ==""} {
set answer [tk_messageBox\
-message "[::msgcat::mc "Not found active project"]"\
-type ok -icon warning]
case $answer {
ok {return 0}
}
}
$tree selection set $node
} else {
return
}
#$tree selection set $node
set item [$tree itemcget $node -data]
if {[string range $item 0 2] == "prj"} {
set activeProject [string range $item 4 end]
@ -425,7 +428,7 @@ proc PopupMenuTree {x y} {
## OPEN TREE PROCEDURE
proc TreeOpen {node} {
global fontNormal tree projDir workDir activeProject fileList noteBook findString imgDir fontBold
set tree [GetTreeForNode $node]
$tree selection set $node
set item [$tree itemcget $node -data]
if {[string range $item 0 2] == "prj"} {
@ -449,7 +452,7 @@ proc TreeOpen {node} {
## CLOSE TREE PROCEDURE ##
proc TreeClose {node} {
global fontNormal tree projDir workDir activeProject fileList noteBook findString imgDir fontBold
set tree [GetTreeForNode $node]
$tree selection set $node
set item [$tree itemcget $node -data]
if {[string range $item 0 2] == "prj"} {
@ -582,7 +585,15 @@ proc GetTreeForNode {node} {
}
}
proc FileNotePageRaise {nb s} {
global workingTree
if {$nb eq "files"} {
set workingTree .frmBody.frmCat.noteBook.ffiles.frmTreeFiles.treeFiles
} elseif {$nb eq "projects"} {
set workingTree .frmBody.frmCat.noteBook.fprojects.frmTree.tree
} else {
puts "Error node"
return
}
}