Added gray theme

Fixed work with file from directory but not project.
This commit is contained in:
Sergey Kalinin
2018-02-13 13:23:40 +03:00
parent fa64acd016
commit a64b6b0e9a
111 changed files with 1324 additions and 1011 deletions

View File

@@ -388,15 +388,15 @@ proc FileDialog {tree operation} {
if {$operation == "open"} {
set dir $projDir
set fullPath [tk_getOpenFile -initialdir $dir -filetypes \
$types -parent $noteBook]
set fullPath [tk_getOpenFile -initialdir $dir -filetypes $types -parent $noteBook]
set file [string range $fullPath [expr [string last "/" $fullPath]+1] end]
regsub -all "." $file "_" node
set dir [file dirname $fullPath]
set file [file tail $fullPath]
set name [file rootname $file]
set ext [string range [file extension $file] 1 end]
set node "$name$dot$ext"
EditFile $node $fullPath
EditFile $tree $node $fullPath
return 1
} elseif {$operation == "delete"} {
set node [$tree selection get]
@@ -447,9 +447,10 @@ proc FileDialog {tree operation} {
set img [GetImage $file]
if {$operation == "open"} {
set fullPath [tk_getOpenFile -initialdir $dir -filetypes \
$types -parent $noteBook]
set fullPath [tk_getOpenFile -initialdir $dir -filetypes $types -parent $noteBook]
puts $fullPath
set file [string range $fullPath [expr [string last "/" $fullPath]+1] end]
regsub -all "." $file "_" node
$noteBook insert end $node -text "$file"
EditFile $node $fullPath
@@ -511,6 +512,7 @@ proc FileDialog {tree operation} {
set node [$noteBook raise]
return
}
set tree [GetTreeForNode $node]
set editFlag [lindex $fileList($node) 1]
set closedFile [file tail [lindex $fileList($node) 0]]
if {$editFlag == 1} {
@@ -525,6 +527,7 @@ proc FileDialog {tree operation} {
}
no {
set index 0
set nl [$tree nodes $node 0 end]
if {$nl != ""} {
foreach n $nl {
@@ -571,6 +574,7 @@ proc FileDialog {tree operation} {
set nodeList [$noteBook pages 0 end]
$noteBook raise [$noteBook page 0]
set nbNode [$noteBook raise]
set tree [GetTreeForNode $nbNode]
while {$nbNode != ""} {
if {$nbNode == "newproj" || $nbNode == "settings" || $nbNode == "about" || $nbNode == "debug"} {
$noteBook delete $nbNode
@@ -726,6 +730,8 @@ proc PageRaise {tree node} {
global noteBook fileList editor nodeEdit
#puts $node
$noteBook raise $node
set tree [GetTreeForNode $node]
set nodeEdit [$noteBook raise]
#set nodeEdit $node
puts $node
@@ -748,7 +754,8 @@ proc PageRaise {tree node} {
LabelUpdate .frmStatus.frmFile.lblFile "[file size $item] b."
if {[lindex $fileList($node) 1] == 0} {
LabelUpdate .frmStatus.frmProgress.lblProgress ""
$noteBook itemconfigure $node -foreground $editor(nbNormal)
$noteBook itemconfigure $node
#-foreground $editor(nbNormal)
} else {
LabelUpdate .frmStatus.frmProgress.lblProgress [::msgcat::mc "File modify"]
$noteBook itemconfigure $node -foreground $editor(nbModify)
@@ -1231,3 +1238,9 @@ GetOp

302
lib/filedialog.tcl Normal file
View File

@@ -0,0 +1,302 @@
#!
######################################################
# projman
# Distributed under GNU Public License
# Author: Sergey Kalinin s.v.kalinin28@gmail.com
# Copyright (c) "https://nuk-svk.ru", 2018, https://bitbucket.org/svk28/projman
######################################################
namespace eval FileOperation {
global noteBook fontNormal fontBold fileList noteBook projDir activeProject imgDir editor
}
proc FileOperation::Open {} {
set dir $projDir
set fullPath [tk_getOpenFile -initialdir $dir -filetypes $types -parent $noteBook]
set file [string range $fullPath [expr [string last "/" $fullPath]+1] end]
regsub -all "." $file "_" node
set dir [file dirname $fullPath]
set file [file tail $fullPath]
set name [file rootname $file]
set ext [string range [file extension $file] 1 end]
set node "$name$dot$ext"
EditFile $node $fullPath
return 1
}
proc FileOperation::Close {} {
set node [$noteBook raise]
if {$node == "newproj" || $node == "settings" || $node == "about" || $node == "debug"} {
$noteBook delete $node
set node [$noteBook raise]
return
} else {
if {$node == ""} {return}
if {[info exists fileList($node)] == 0} {return}
set fullPath [lindex $fileList($node) 0]
set dir [file dirname $fullPath]
set file [file tail $fullPath]
set text "$noteBook.f$node.text"
}
}
proc FileOperation::Save {} {
}
proc FileOperation::SaveAll {} {
}
proc FileOperation::Delete {} {
set node [$tree selection get]
set fullPath [$tree itemcget $node -data]
set dir [file dirname $fullPath]
set file [file tail $fullPath]
set answer [tk_messageBox -message "[::msgcat::mc "Delete file"] \"$file\"?"\
-type yesno -icon question -default yes]
case $answer {
yes {
FileDialog $tree close
file delete -force "$fullPath"
$tree delete $node
$tree configure -redraw 1
return 0
}
}
}
## FILE OPERATION ##
proc FileOperation::FileDialog {tree operation} {
global noteBook fontNormal fontBold fileList noteBook projDir activeProject imgDir editor
set dot "_"
set types {
{"Tcl files" {.tcl}}
{"Tk files" {.tk}}
{"Rivet files" {.rvt}}
{"TclHttpd Template" {.tml}}
{"Sql files" {.sql}}
{"Html files" {.html}}
{"Text files" {.txt}}
{"JAVA files" {.java}}
{"PERL files" {.pl}}
{"PHP files" {.php}}
{"FORTRAN files" {.for}}
{"CAML or ML files" {.ml}}
{"CAML or ML interface files" {.mli}}
{"Ruby files" {.rb}}
{"Text files" {} TEXT}
{"All files" *}
}
if {$operation == "open"} {
FileOperation::Open
} elseif {$operation == "delete"} {
FileOperation::Delete
} elseif {$operation == "close"} {
FileOperation::Close
} elseif {$operation == "close" && [info exists files] == 0} {
return
} else {
set node [$noteBook raise]
puts $node
if {$node == ""} {return}
if {[info exists fileList($node)] == 0} {return}
set fullPath [lindex $fileList($node) 0]
set dir [file dirname $fullPath]
set file [file tail $fullPath]
set text "$noteBook.f$node.text"
}
set name [file rootname $file]
set ext [string range [file extension $file] 1 end]
set treeSubNode "$name$dot$ext"
set img [GetImage $file]
if {$operation == "open"} {
set fullPath [tk_getOpenFile -initialdir $dir -filetypes $types -parent $noteBook]
puts $fullPath
set file [string range $fullPath [expr [string last "/" $fullPath]+1] end]
regsub -all "." $file "_" node
$noteBook insert end $node -text "$file"
EditFile $node $fullPath
} elseif {$operation == "save"} {
if {$name == "untitled"} {
set file [tk_getSaveFile -initialdir $dir -filetypes \
$types -parent $text -initialfile $file \
-defaultextension .$ext]
set contents [$text get 0.0 end]
set fhandle [open "$file" "w"]
puts $fhandle $contents nonewline
close $fhandle
file delete [file join $dir $name.$ext]
#$tree delete $treeSubNode
unset fileList($node)
# change data into tree and notebook
set dir [file dirname $file]
set file [file tail $file]
set name [file rootname $file]
set ext [string range [file extension $file] 1 end]
$tree itemconfigure $treeSubNode -text $name
set treeSubNode "$activeProject$dot$name$dot$ext"
#$tree insert end $activeProject $treeSubNode -text "$file" \
#-data "[file join $dir $file]" -open 1\
#-image [Bitmap::get [file join $imgDir $img.gif]]\
#-font $fontNormal
set nbNode [$noteBook raise]
$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
close $fhandle
EditFlag $node [file join $dir $file] 0
}
} elseif {$operation == "save_all"} {
set i 0
set nodeList [$noteBook pages 0 end]
set length [llength $nodeList]
while {$i < $length} {
set nbNode [lindex $nodeList $i]
if {[info exists fileList($nbNode)] == 1} {
set text "$noteBook.f$nbNode.text"
set savedFile [lindex $fileList($nbNode) 0]
set contents [$text get 0.0 end]
set fhandle [open [file join $dir $savedFile] "w"]
puts $fhandle $contents nonewline
close $fhandle
EditFlag $nbNode [file join $dir $savedFile] 0
}
incr i
}
} elseif {$operation == "close"} {
# delete file name from fileList array #
if {$node == "newproj" || $node == "settings" || $node == "about" || $node == "debug"} {
$noteBook delete $node
set node [$noteBook raise]
return
}
set editFlag [lindex $fileList($node) 1]
set closedFile [file tail [lindex $fileList($node) 0]]
if {$editFlag == 1} {
set answer [tk_messageBox\
-message "$closedFile [::msgcat::mc "File was modifyed. Save?"]"\
-type yesnocancel -icon warning\
-title [::msgcat::mc "Warning"]]
case $answer {
yes {
FileDialog $tree save
# FileDialog close
}
no {
set index 0
set nl [$tree nodes $node 0 end]
if {$nl != ""} {
foreach n $nl {
$tree delete $n
}
}
$noteBook delete $node
unset fileList($node)
$noteBook raise [$noteBook page $index]
set node [$noteBook raise]
}
cancel {
return 0
}
}
} else {
set index 0
set nl [$tree nodes $node 0 end]
if {$nl != ""} {
foreach n $nl {
$tree delete $n
}
}
#puts $node
$noteBook delete $node
unset fileList($node)
$noteBook raise [$noteBook page $index]
set node [$noteBook raise]
}
if {$node != ""} {
if {$node == "newproj" || $node == "settings" || $node == "about" || $node == "debug"} {
$noteBook delete $node
} else {
focus -force $noteBook.f$node
}
$tree selection set $node
} else {
LabelUpdate .frmStatus.frmLine.lblLine ""
LabelUpdate .frmStatus.frmFile.lblFile ""
LabelUpdate .frmStatus.frmOvwrt.lblOvwrt ""
LabelUpdate .frmStatus.frmProgress.lblProgress ""
}
} elseif {$operation == "close_all"} {
set nodeList [$noteBook pages 0 end]
$noteBook raise [$noteBook page 0]
set nbNode [$noteBook raise]
while {$nbNode != ""} {
if {$nbNode == "newproj" || $nbNode == "settings" || $nbNode == "about" || $nbNode == "debug"} {
$noteBook delete $nbNode
$noteBook raise [$noteBook page 0]
set nbNode [$noteBook raise]
}
if {[info exists fileList($nbNode)] == 1} {
set editFlag [lindex $fileList($nbNode) 1]
if {$editFlag == 1} {
set f [lindex $fileList($nbNode) 0]
set f [file tail $f]
set answer [tk_messageBox\
-message "$f [::msgcat::mc "File was modifyed. Save?"]"\
-type yesnocancel -icon warning\
-title [::msgcat::mc "Warning"]]
case $answer {
yes {
FileDialog $tree save
}
no {}
cancel {return cancel}
}
}
set nl [$tree nodes $nbNode 0 end]
if {$nl != ""} {
foreach n $nl {
$tree delete $n
}
}
$noteBook delete $nbNode
$noteBook raise [$noteBook page 0]
unset fileList($nbNode)
set nbNode [$noteBook raise]
}
}
LabelUpdate .frmStatus.frmLine.lblLine ""
LabelUpdate .frmStatus.frmFile.lblFile ""
LabelUpdate .frmStatus.frmOvwrt.lblOvwrt ""
} elseif {$operation == "save_as"} {
set file [tk_getSaveFile -initialdir $dir -filetypes \
$types -parent $text -initialfile $file]
if {$file != ""} {
set contents [$text get 0.0 end]
set fhandle [open $file "w"]
puts $fhandle $contents nonewline
close $fhandle
set dir [file dirname $file]
set file [file tail $file]
set name [string range $file 0 [expr [string last "." $file]-1]]
if {[string last "." $file] == -1} {
set ext [string range [file extension $file] 1 end]
} else {
set ext ""
}
set treeSubNode "$activeProject$dot$name$dot$ext"
$tree insert end $activeProject $treeSubNode -text "$file" \
-data "[file join $dir $file]" -open 1\
-image [Bitmap::get [file join $imgDir $img.gif]]\
-font $fontNormal
set nbNode [$noteBook raise]
$noteBook itemconfigure $nbNode -text $file
set fileList($nbNode) [list $file 0]
}
return 0
}
}

View File

@@ -7,7 +7,7 @@
Modules
## MAIN INTERFACE ##
wm geometry . 1024x768+0+0
wm geometry . 1200x1024+0+0
wm title . "Tcl/Tk Project Manager $ver"
wm iconname . "Tcl/Tk Project Manager $ver"
wm protocol . WM_DELETE_WINDOW Quit
@@ -35,7 +35,7 @@ $mn add command -label [::msgcat::mc "New directory"] -command {AddToProjDialog
-font $fontNormal -accelerator "Ctrl+N"
$mn add command -label [::msgcat::mc "New project"] -command {NewProjDialog "new"}\
-font $fontNormal
#$m add command -label [::msgcat::mc "Open"] -command {FileDialog open}\
#$m add command -label [::msgcat::mc "Open"] -command {FileDialog $tree open}\
#-font $fontNormal -accelerator "Ctrl+O" -state disable
$m add command -label [::msgcat::mc "Save"] -command {FileDialog $tree save}\
-font $fontNormal -accelerator "Ctrl+S"
@@ -219,6 +219,7 @@ proc CreateToolBar {} {
if {$toolBar == "Yes"} {
set bboxFile [ButtonBox .frmTool.bboxFile -spacing 0 -padx 1 -pady 1 -bg $editor(bg)]
add_toolbar_button $bboxFile new.png {AddToProjDialog file} [::msgcat::mc "Create new file"]
#add_toolbar_button $bboxFile open.png {FileDialog $tree open} [::msgcat::mc "Open file"]
add_toolbar_button $bboxFile save.png {FileDialog $tree save} [::msgcat::mc "Save file"]
add_toolbar_button $bboxFile save_as.png {FileDialog $tree save_as} [::msgcat::mc "Save file as"]
add_toolbar_button $bboxFile save_all.png {FileDialog $tree save_all} [::msgcat::mc "Save all"]
@@ -390,3 +391,8 @@ focus -force $tree

View File

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

View File

@@ -748,3 +748,4 @@ proc GetExtention {node} {

View File

@@ -677,7 +677,7 @@ proc MakeProj {action t} {
ok {return 0}
}
}
FileDialog save_all
FileDialog $tree save_all
set file [open [file join $workDir $activeProject.proj] r]
while {[gets $file line]>=0} {
scan $line "%s" keyWord
@@ -795,8 +795,6 @@ proc MakeProj {action t} {
fileevent $pipe readable [list DebugInfo $w.frame.text $pipe $f]
fconfigure $pipe -buffering none -blocking no
#fileevent $f readable [list DebugInfo $w.frame.text $f]
#fconfigure $f -buffering none -blocking no
}
## INSERT DEBUG INFORMATION INTO TEXT WIDGET ##
proc DebugInfo {widget file f} {
@@ -908,8 +906,3 @@ proc InsertTitle {newFile type} {

View File

@@ -30,6 +30,7 @@ proc FileTree::create {nb} {
} -opencmd {FileTree::select tree 1 $treeFiles} \
-closecmd {FileTree::select tree 1 $treeFiles}
]
puts $treeFiles
$frmTreeFiles setwidget $treeFiles
pack $frmTreeFiles -side top -fill both -expand true
$treeFiles bindText <ButtonPress-1> "TreeOneClick $treeFiles [$treeFiles selection get]"
@@ -555,12 +556,11 @@ proc UpdateTree {} {
GetProj $tree
}
proc GetTreeForNode {node} {
if {[.frmBody.frmCat.noteBook.ffiles.frmTreeFiles.treeFiles exists $node] ==1} {
return .frmBody.frmCat.noteBook.ffiles.frmTreeFiles.treeFiles
} elseif {[.frmBody.frmCat.noteBook.fprojects.frmTree.tree exists $node] ==1} {
return .frmBody.frmCat.noteBook.fprojects.frmTree.tree
}
}