From d3add6984d4c790e6b8fd3006b37d91b9f0053d7 Mon Sep 17 00:00:00 2001 From: Sergey Kalinin Date: Sun, 18 Feb 2018 15:01:56 +0300 Subject: [PATCH] - Fixed edit files into root node from file browser tree - Change "Delete project" dialog and procedure --- CHANGELOG | 6 + KNOWBUG | 10 + lib/editor.tcl | 6 +- lib/filedialog.tcl | 1 + lib/help.tcl | 5 +- lib/main.tcl | 17 +- lib/procedure.tcl | 3 + lib/projects.tcl | 527 ++++++++++++++++++++++++++++++++++++++++++- lib/projects_new.tcl | 502 ----------------------------------------- lib/settings.tcl | 7 +- lib/tree.tcl | 16 +- msgs/en.msg | 4 + msgs/ru.msg | 4 + projman.tcl | 88 +++++--- 14 files changed, 644 insertions(+), 552 deletions(-) create mode 100644 KNOWBUG delete mode 100644 lib/projects_new.tcl diff --git a/CHANGELOG b/CHANGELOG index f9ea128..dc589fc 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -6,6 +6,10 @@ ######################################################### 0.4.5 +18.02.2018 +- Fixed edit files into root node from file browser tree +- Change "Delete project" dialog and procedure + 17.02.2018 - Refactoring "Add New Projects" "Project Settings" (e.t.c.) dialogs - Added "Add as new project" dialog for file browser @@ -373,3 +377,5 @@ characters to the right of the insertion cursor. + + diff --git a/KNOWBUG b/KNOWBUG new file mode 100644 index 0000000..a19c26f --- /dev/null +++ b/KNOWBUG @@ -0,0 +1,10 @@ +###################################################### +# Tcl/Tk Project Manager +# Distributed under GNU Public License +# Author: Sergey Kalinin banzaj28@yandex.ru +# Copyright (c) "https://nuk-svk.ru", 2018, https://bitbucket.org/svk28/projman +###################################################### + +1. BaseALT SimplyLinux - Bwidget ScrolledWindow dont work with options: +-background +In Debian - it's all right. diff --git a/lib/editor.tcl b/lib/editor.tcl index 9ac931b..1717a8c 100644 --- a/lib/editor.tcl +++ b/lib/editor.tcl @@ -611,7 +611,10 @@ proc EditFile {tree node fileName} { set fileExt [string range [file extension $fileName] 1 end] set parentNode [$tree parent $node] set project [$tree itemcget $parentNode -data] + # 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]]] + # create array with file names # if {[info exists fileList($node)] != 1} { set fileList($node) [list $fileName 0] @@ -626,7 +629,7 @@ proc EditFile {tree node fileName} { set scrwin [ScrolledWindow $w.scrwin -bg $editor(bg)] pack $scrwin -fill both -expand true text $w.text\ - -relief sunken -wrap $editor(wrap) -highlightthickness 0 -undo 1 -font $editor(font)\ + -relief sunken -wrap $editor(wrap) -highlightthickness 0 -undo 1 -font $editor(font) -blockcursor true\ -selectborderwidth 0 -selectbackground $editor(selectbg) -width 10 -background $editor(bg) -foreground $editor(fg) pack $w.text -side left -fill both -expand true @@ -996,5 +999,6 @@ GetOp + diff --git a/lib/filedialog.tcl b/lib/filedialog.tcl index b3c2afa..c425538 100644 --- a/lib/filedialog.tcl +++ b/lib/filedialog.tcl @@ -598,3 +598,4 @@ proc FileOperation::FileDialog {tree operation} { } + diff --git a/lib/help.tcl b/lib/help.tcl index 51bc6b4..423c6e9 100644 --- a/lib/help.tcl +++ b/lib/help.tcl @@ -52,7 +52,7 @@ proc HlpTreeOneClick {node} { } ## GETTING TABLE OF CONTENT ## proc GetTOC {} { - global docDir hlpTree imgDir fontNormal lstSearch arr sourceEncode + global docDir hlpTree imgDir fontNormal lstSearch arr sourceEncode editor if {[catch {cd $docDir}] != 0} { return "" } @@ -73,6 +73,7 @@ proc GetTOC {} { set length [string length $a] set title [string range $a 1 [expr $length-2]] $hlpTree insert end root $nodeParent -text "$title" -font $fontNormal \ + -fill $editor(fg) \ -data "toc_$nodeParent" -open 0\ -image [Bitmap::get [file join $imgDir books.gif]] } @@ -85,6 +86,7 @@ proc GetTOC {} { set data [file join $dir $v3] $hlpTree insert end "$nodeParent" $subNode -text "$v5"\ -font $fontNormal -data "doc_$data" -open 0\ + -fill $editor(fg) \ -image [Bitmap::get [file join $imgDir file.gif]] $lstSearch insert end $v3 } else { @@ -322,3 +324,4 @@ proc TopLevelHelp {} { #GetContent $docDir/tcl.toc.html + diff --git a/lib/main.tcl b/lib/main.tcl index 86287ff..fc369d9 100644 --- a/lib/main.tcl +++ b/lib/main.tcl @@ -262,9 +262,11 @@ pack $frm6.lblOvwrt -fill x ########## PROJECT-FILE-FUNCTION TREE ################## -set frmCat [frame .frmBody.frmCat -border 1 -relief sunken -bg $editor(bg)] +#set frmCat [frame .frmBody.frmCat -border 1 -relief sunken -bg $editor(bg)] +set frmCat [frame .frmBody.frmCat -border 1 -relief sunken] pack $frmCat -side left -fill y -fill both -set frmWork [frame .frmBody.frmWork -border 1 -relief sunken -bg $editor(bg)] +#set frmWork [frame .frmBody.frmWork -border 1 -relief sunken -bg $editor(bg)] +set frmWork [frame .frmBody.frmWork -border 1 -relief sunken] pack $frmWork -side left -fill both -expand true ## CREATE PANE ## @@ -272,10 +274,13 @@ pane::create .frmBody.frmCat .frmBody.frmWork # NoteBook - Projects and Files #################### WORKING AREA #################### -set noteBookFiles [NoteBook $frmCat.noteBook -font $fontNormal -side top -bg $editor(bg) -fg $editor(fg)] +set noteBookFiles [NoteBook $frmCat.noteBook -font $fontNormal -side top -bg $editor(bg) -fg $editor(fg) \ +-activebackground $editor(bg) -activeforeground $editor(fg) ] pack $noteBookFiles -fill both -expand true -padx 2 -pady 2 -set nbProjects [$noteBookFiles insert end projects -text [::msgcat::mc "Projects"]] -set nbFiles [$noteBookFiles insert end files -text [::msgcat::mc "Files"]] +set nbProjects [$noteBookFiles insert end projects -text [::msgcat::mc "Projects"] \ +-activebackground $editor(bg) -activeforeground $editor(fg)] +set nbFiles [$noteBookFiles insert end files -text [::msgcat::mc "Files"] \ +-activebackground $editor(bg) -activeforeground $editor(fg)] # Create FileTree @@ -390,3 +395,5 @@ if {[info exists workingProject]} { } + + diff --git a/lib/procedure.tcl b/lib/procedure.tcl index 83b73da..e301cd6 100644 --- a/lib/procedure.tcl +++ b/lib/procedure.tcl @@ -326,6 +326,7 @@ proc Quit {} { if {[regexp -nocase -all -- {set topLevelGeometry} $line match]} { puts $file1 "set topLevelGeometry \"[winfo geometry .]\"" } elseif {[regexp -nocase -all -- {set workingProject} $line match]} { + puts "set workingProject \"$activeProject\"" puts $file1 "set workingProject \"$activeProject\"" } else { puts $file1 "$line" @@ -663,3 +664,5 @@ proc GetExtention {node} { } + + diff --git a/lib/projects.tcl b/lib/projects.tcl index edb27f8..c74f3aa 100644 --- a/lib/projects.tcl +++ b/lib/projects.tcl @@ -1,10 +1,504 @@ -########################################################### -# Tcl/Tk project Manager # -# Distributed under GNU Public License # -# Author: Sergey Kalinin banzaj28@yandex.ru # -# Copyright (c) "Sergey Kalinin", 2002, http://nuk-svk.ru # -########################################################### +####################################### +# 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 + global openProjDir tclDir frm lang operType + set operType $type + if {$operType == "edit" && $proj == ""} { + set answer [tk_messageBox\ + -message "[::msgcat::mc "Not found active project"]"\ + -type ok -icon warning -title [::msgcat::mc "Warning"]] + case $answer { + ok {return 0} + } + } + set typeProjects "Tcl Tcl/Tk Java Perl Fortran O'Caml PHP Ruby Erlang" + + set node [$noteBook page [$noteBook index newproj]] + if {$node != ""} { + $noteBook raise newproj + return 0 + } else { + set w [$noteBook insert end newproj -text [::msgcat::mc "New project"]] + } + set frm [frame $w.frmProjSettings] + pack $frm -fill both -expand true + + image create photo imgFold -format gif -file [file join $imgDir folder.gif] + variable frm_1 + set frm_1 [frame $frm.frmProjName] + label $frm_1.lblProjName -text [::msgcat::mc "Project name"] -width 20 -anchor w + entry $frm_1.txtProjName -textvariable txtProjName -bd 0 -relief flat + pack $frm_1.lblProjName -side left + pack $frm_1.txtProjName -side left -fill x -expand true + + ### + set frm_lang [frame $frm.frmLanguage] + set lang "Tcl" + label $frm_lang.lblLanguage -text [::msgcat::mc "Project type"] -width 20 -anchor w + set combo [ + ComboBox $frm_lang.txtLocale \ + -textvariable lang -editable false \ + -autocomplete true -autopost true \ + -selectbackground "#55c4d1" -selectborderwidth 0 \ + -values $typeProjects + ] + #$combo setvalues $lang + pack $frm_lang.lblLanguage -side left + pack $combo -fill x -expand true + bind $combo { append txtFileName ".[GetExtentionProj $lang]"} + ### + + set frm_2 [frame $frm.frmFileName] + label $frm_2.lblFileName -text [::msgcat::mc "Project file"] -width 20 -anchor w + entry $frm_2.txtFileName -textvariable txtFileName -bd 0 -relief flat + pack $frm_2.lblFileName -side left + pack $frm_2.txtFileName -side left -fill x -expand true + bind $frm_2.txtFileName { + append txtFileName ".[GetExtentionProj $lang]" + } + #$frm_2.txtFileName insert end $txtProjName + + set frm_8 [frame $frm.frmDirName] + label $frm_8.lblDirName -text [::msgcat::mc "Project dir"] -width 20 -anchor w + entry $frm_8.txtDirName -textvariable txtDirName + button $frm_8.btnDirName -image imgFold -relief flat \ + -command { + $frm.frmDirName.txtDirName configure -state normal + InsertEnt $frm.frmDirName.txtDirName [tk_chooseDirectory -initialdir $projDir -title "[::msgcat::mc "Select directory"]" -parent .] + $frm.frmDirName.txtDirName configure -state disable + } + pack $frm_8.lblDirName -side left + pack $frm_8.txtDirName -side left -fill x -expand true + pack $frm_8.btnDirName -side left + bind $frm_8.txtDirName { + + } + + set frm_13 [frame $frm.frmCompiler] + label $frm_13.lblCompiler -text [::msgcat::mc "Compiler"]\ + -width 20 -anchor w + entry $frm_13.txtCompiler -textvariable txtCompiler + button $frm_13.btnCompiler -image imgFold -relief flat\ + -command { + InsertEnt $frm.frmCompiler.txtCompiler [tk_getOpenFile -initialdir $tclDir -parent .] + } + pack $frm_13.lblCompiler -side left + pack $frm_13.txtCompiler -side left -fill x -expand true + pack $frm_13.btnCompiler -side left + + set txtProjInterp [GetInterp $lang] + set frm_12 [frame $frm.frmProjInterp] + label $frm_12.lblProjInterp -text [::msgcat::mc "Interpetator"]\ + -width 20 -anchor w + entry $frm_12.txtProjInterp -textvariable txtProjInterp + button $frm_12.btnInterp -image imgFold -relief flat\ + -command { + InsertEnt $frm.frmProjInterp.txtProjInterp [tk_getOpenFile -initialdir $tclDir -parent .] + } + pack $frm_12.lblProjInterp -side left + pack $frm_12.txtProjInterp -side left -fill x -expand true + pack $frm_12.btnInterp -side left + bind $frm_12.txtProjInterp { + set txtProjInterp [GetInterp $lang] + } + + set frm_4 [frame $frm.frmVersion] + label $frm_4.lblProjVersion -text [::msgcat::mc "Version"] -width 20 -anchor w + entry $frm_4.txtProjVersion -textvariable txtProjVersion -bd 0 -relief flat + pack $frm_4.lblProjVersion -side left + pack $frm_4.txtProjVersion -side left -fill x -expand true + InsertEnt $frm_4.txtProjVersion "0.0.1" + + set frm_11 [frame $frm.frmRelease] + label $frm_11.lblProjRelease -text [::msgcat::mc "Release"] -width 20 -anchor w + entry $frm_11.txtProjRelease -textvariable txtProjRelease -bd 0 -relief flat + pack $frm_11.lblProjRelease -side left + pack $frm_11.txtProjRelease -side left -fill x -expand true + InsertEnt $frm_11.txtProjRelease "1" + + set frm_3 [frame $frm.frmProjAuthor] + label $frm_3.lblProjAuthor -text [::msgcat::mc "Author"] -width 20 -anchor w + entry $frm_3.txtProjAuthor -textvariable txtProjAuthor -bd 0 -relief flat + pack $frm_3.lblProjAuthor -side left + pack $frm_3.txtProjAuthor -side left -fill x -expand true + + set frm_9 [frame $frm.frmProjEmail] + label $frm_9.lblProjEmail -text [::msgcat::mc "E-mail"] -width 20 -anchor w + entry $frm_9.txtProjEmail -textvariable txtProjEmail -bd 0 -relief flat + pack $frm_9.lblProjEmail -side left + pack $frm_9.txtProjEmail -side left -fill x -expand true + + set frm_5 [frame $frm.frmProjCompany] + label $frm_5.lblProjCompany -text [::msgcat::mc "Company"] -width 20 -anchor w + entry $frm_5.txtProjCompany -textvariable txtProjCompany -bd 0 -relief flat + pack $frm_5.lblProjCompany -side left + pack $frm_5.txtProjCompany -side left -fill x -expand true + + set frm_10 [frame $frm.frmProjHome] + label $frm_10.lblProjHome -text [::msgcat::mc "Home page"] -width 20 -anchor w + entry $frm_10.txtProjHome -textvariable txtProjHome + pack $frm_10.lblProjHome -side left + pack $frm_10.txtProjHome -side left -fill x -expand true + + set frm_7 [frame $frm.frmWinTitle ] + label $frm_7.lblWinTitle -text [::msgcat::mc "Create new project"] -height 2 -font $fontBold + + + pack $frm_7.lblWinTitle -fill x -expand true + + set frm_6 [frame $frm.frmBtn ] + if {$operType == "edit" && $proj != ""} { + $noteBook itemconfigure newproj -text [::msgcat::mc "Project settings"] + button $frm_6.btnProjCreate -text [::msgcat::mc "Save"] -relief flat \ + -font $fontNormal -command { + regsub -all {\\} $txtProjInterp {\\\\} $txtProjInterp + SaveProj "$txtFileName" "$lang" "$txtProjName" "$txtFileName" "$txtDirName"\ + "$txtCompiler" "$txtProjInterp" "$txtProjVersion" "$txtProjRelease"\ + "$txtProjAuthor" "$txtProjEmail" "$txtProjCompany" "$txtProjHome" + $noteBook delete newproj + $noteBook raise [$noteBook page end] + } + } else { + button $frm_6.btnProjCreate -text [::msgcat::mc "Create"] -relief flat \ + -font $fontNormal -command { + CreateProj "$operType" "$lang" "$txtFileName" "$txtProjName" "$txtFileName" "$txtDirName"\ + "$txtCompiler" "$txtProjInterp" "$txtProjVersion" "$txtProjRelease"\ + "$txtProjAuthor" "$txtProjEmail" "$txtProjCompany" "$txtProjHome" + $noteBook delete newproj + $noteBook raise [$noteBook page end] + } + + } + button $frm_6.btnClose -text [::msgcat::mc "Cancel"] -relief flat -font $fontNormal -command { + $noteBook delete newproj + $noteBook raise [$noteBook page end] + } + pack $frm_6.btnProjCreate $frm_6.btnClose -padx 10 -pady 20 -side right + pack $frm_7 $frm_1 $frm_lang $frm_2 $frm_8 $frm_13 $frm_12 $frm_4 $frm_11 $frm_3 $frm_9 $frm_5 $frm_10 $frm_6\ + -side top -fill x -padx 10 -pady 5 + pack $frm_6 -side top -fill x -expand true -anchor n + bind $w "$noteBook delete newproj" + $noteBook raise newproj + + ## EDIT PROJECT SETTINGS ## + if {$operType == "edit" && $proj != ""} { + $frm.frmDirName.txtDirName configure -state normal + $frm_7.lblWinTitle configure -text [::msgcat::mc "Project settings"] + $frm_6.btnProjCreate configure -text "[::msgcat::mc "Save"]" + set file [open [file join $workDir $proj.proj] r] + while {[gets $file line]>=0} { + scan $line "%s" keyWord + set string [string range $line [string first "\"" $line] [string last "\"" $line]] + set string [string trim $string "\""] + # regsub -all " " $string "_" project + puts $string + switch $keyWord { + ProjectName {InsertEnt $frm_1.txtProjName "$string"} + ProjectFileName {InsertEnt $frm_2.txtFileName "$string"} + ProjectLanguage {set lang "$string"} + ProjectDirName {InsertEnt $frm_8.txtDirName "$string"} + ProjectCompiler {InsertEnt $frm_13.txtCompiler "$string"} + ProjectInterp {InsertEnt $frm_12.txtProjInterp "$string"} + ProjectVersion {InsertEnt $frm_4.txtProjVersion "$string"} + ProjectRelease {InsertEnt $frm_11.txtProjRelease "$string"} + ProjectAuthor {InsertEnt $frm_3.txtProjAuthor "$string"} + ProjectEmail {InsertEnt $frm_9.txtProjEmail "$string"} + ProjectCompany {InsertEnt $frm_5.txtProjCompany "$string"} + ProjectHome {InsertEnt $frm_10.txtProjHome "$string"} + } + } + close $file + } elseif {$operType == "open"} { + $frm_7.lblWinTitle configure -text [::msgcat::mc "Open project"] + InsertEnt $frm_1.txtProjName "$proj" + InsertEnt $frm_2.txtFileName "$proj" + #$combo setvalue $lang + InsertEnt $frm_8.txtDirName "$proj" + $frm_8.txtDirName configure -state normal + puts $prjDir + InsertEnt $frm_8.txtDirName "$prjDir" + InsertEnt $frm_13.txtCompiler "" + InsertEnt $frm_12.txtProjInterp "" + InsertEnt $frm_4.txtProjVersion "0.0.1" + InsertEnt $frm_11.txtProjRelease "1" + InsertEnt $frm_3.txtProjAuthor "" + InsertEnt $frm_9.txtProjEmail "" + InsertEnt $frm_5.txtProjCompany "" + InsertEnt $frm_10.txtProjHome "" + } else { + InsertEnt $frm_1.txtProjName "" + InsertEnt $frm_2.txtFileName "" + InsertEnt $frm_8.txtDirName "" + InsertEnt $frm_13.txtCompiler "" + InsertEnt $frm_12.txtProjInterp "" + InsertEnt $frm_4.txtProjVersion "0.0.1" + InsertEnt $frm_11.txtProjRelease "1" + InsertEnt $frm_3.txtProjAuthor "" + InsertEnt $frm_9.txtProjEmail "" + InsertEnt $frm_5.txtProjCompany "" + InsertEnt $frm_10.txtProjHome "" + } + # bind autocomlite dir only if new project + if {[$frm_8.txtDirName get ] eq ""} { + bind $frm_1.txtProjName { + regsub -all -- {\s} [string tolower [Translit [$frm_1.txtProjName get]]] "_" txtFileName + set txtDirName [file join $projDir $txtFileName] + } + } + +} + +proc GetExtentionProj {lang} { + if {$lang=="Tcl" || $lang=="Tcl/Tk"} { + set ext "tcl" + } elseif {$lang == "Perl"} { + set ext pl + } elseif {$lang=="Java"} { + set ext "java" + } elseif {$lang=="Fortran"} { + set ext "for" + } elseif {$lang=="O'Caml"} { + set ext ml + } elseif {$lang=="Ruby"} { + set ext rb + } elseif {$lang=="PHP"} { + set ext php + } elseif {$lang=="Erlang"} { + set ext erl + } + return $ext +} +proc GetInterp {lang} { + global tcl_platform + if {$tcl_platform(platform) == "unix"} { + set interp [GetInterp_unix $lang] + } elseif {$tcl_platform(platform) == "windows"} { + set interp [GetInterp_windows $lang] + } else { + set interp "" + } + return $interp +} + +proc GetInterp_unix {lang} { + set searchCommand "which" + switch $lang { + Tcl {set interp "tclsh"} + Tcl/Tk {set interp "wish"} + Perl {set interp "perl"} + Java {set interp "java"} + Fortran {set interp ""} + O'Caml {set interp ""} + Ruby {set interp "ruby"} + PHP {set interp "php"} + Perl {set interp "perl"} + Erlang {set interp ""} + } + try { + set result [exec $searchCommand $interp] + } trap {} {} { + puts "Error: don't find interp for $lang" + set result "" + } + return $result +} +proc GetInterp_windows {lang} { + set searchCommand "where" + switch $lang { + Tcl {set interp "tclsh"} + Tcl/Tk {set interp "wish"} + Perl {set interp "perl"} + Java {set interp "java"} + Fortran {set interp ""} + O'Caml {set interp ""} + Ruby {set interp "ruby"} + PHP {set interp "php"} + Perl {set interp "perl"} + Erlang {set interp ""} + } + try { + set result [exec $searchCommand $interp] + } trap {} {} { + puts "Error: don't find interp for $lang" + set result "" + } + return $result +} + +proc SaveProj {txtFileName lang txtProjName txtFileName txtDirName \ +txtCompiler txtProjInterp txtProjVersion txtProjRelease txtProjAuthor \ +txtProjEmail txtProjCompany txtProjHome} { + global projDir workDir dataDir + + set file [file tail $txtDirName] + set projFile [open [file join $workDir $file.proj] w] + puts $projFile "ProjectName \"$txtProjName\"" + puts $projFile "ProjectLanguage \"$lang\"" + puts $projFile "ProjectFileName \"$txtFileName\"" + puts $projFile "ProjectDirName \"$txtDirName\"" + puts $projFile "ProjectCompiler \"$txtCompiler\"" + puts $projFile "ProjectInterp \"$txtProjInterp\"" + puts $projFile "ProjectVersion \"$txtProjVersion\"" + puts $projFile "ProjectRelease \"$txtProjRelease\"" + puts $projFile "ProjectAuthor \"$txtProjAuthor\"" + puts $projFile "ProjectEmail \"$txtProjEmail\"" + puts $projFile "ProjectCompany \"$txtProjCompany\"" + puts $projFile "ProjectHome \"$txtProjHome\"" + close $projFile +} + + +## CREATING PROJECT PROCEDURE ## +proc CreateProj {type lang txtFileName txtProjName txtFileName txtDirName \ +txtCompiler txtProjInterp txtProjVersion txtProjRelease txtProjAuthor txtProjEmail \ +txtProjCompany txtProjHome} { + global projDir workDir tree fontNormal dataDir tcl_platform + puts "$type $lang";# "$txtFileName" "$txtProjName" "$txtFileName" "$txtDirName"\ + # "$txtCompiler" "$txtProjInterp" "$txtProjVersion" "$txtProjRelease"\ + # "$txtProjAuthor" "$txtProjEmail" "$txtProjCompany" "$txtProjHome" + ## SAVING PROJECT SETTINGS ## + set projShortName [file tail $txtDirName] + + set projFile [open [file join $workDir $projShortName.proj] w] + + puts $projFile "ProjectName \"$txtProjName\"" + puts $projFile "ProjectLanguage \"$lang\"" + puts $projFile "ProjectFileName \"$txtFileName\"" + puts $projFile "ProjectDirName \"$txtDirName\"" + puts $projFile "ProjectCompiler \"$txtCompiler\"" + puts $projFile "ProjectInterp \"$txtProjInterp\"" + puts $projFile "ProjectVersion \"$txtProjVersion\"" + puts $projFile "ProjectRelease \"$txtProjRelease\"" + puts $projFile "ProjectAuthor \"$txtProjAuthor\"" + puts $projFile "ProjectEmail \"$txtProjEmail\"" + puts $projFile "ProjectCompany \"$txtProjCompany\"" + puts $projFile "ProjectHome \"$txtProjHome\"" + close $projFile + if {$type != "open"} { + set dir [file join $projDir $txtDirName] + if {[file exists "$dir"] != 1} { + file mkdir "$dir" + } + # file header + if {$lang=="Tcl" || $lang == "Tcl/Tk"} { + set text "######################################################\n#\t$txtProjName\n#\tDistributed under GNU Public License\n# Author: $txtProjAuthor $txtProjEmail\n# Home page: $txtProjHome\n######################################################\n" + } elseif {$lang == "Perl"} { + set lang pl + set text "######################################################\n#\t$txtProjName\n#\tDistributed under GNU Public License\n# Author: $txtProjAuthor $txtProjEmail\n# Home page: $txtProjHome\n######################################################\n" + } elseif {$lang=="Java"} { + set text "/*\n*****************************************************\n*\t$txtProjName\n*\tDistributed under GNU Public License\n* Author: $txtProjAuthor $txtProjEmail\n* Home page: $txtProjHome\n*****************************************************\n*/\n" + } elseif {$lang=="Fortran"} { + set text "\nc*****************************************************\nc*\t$txtProjName\n*c\tDistributed under GNU Public License\nc* Author: $txtProjAuthor $txtProjEmail\nc* Home page: $txtProjHome\nc*****************************************************\n*/\n" + } elseif {$lang=="O'Caml"} { + set text "\(*****************************************************\n*\t$txtProjName\n*\tDistributed under GNU Public License\n* Author: $txtProjAuthor $txtProjEmail\n* Home page: $txtProjHome\n******************************************************\)\n" + set lang ml + } elseif {$lang=="Ruby"} { + set lang rb + set text "######################################################\n#\t$txtProjName\n#\tDistributed under GNU Public License\n# Author: $txtProjAuthor $txtProjEmail\n# Home page: $txtProjHome\n######################################################\n" + } elseif {$lang=="PHP"} { + set text "" + set lang php + } elseif {$lang=="Erlang"} { + set text "\%**************************************************\n%\t$txtProjName\n%\tDistributed under GNU Public License\n% Author: $txtProjAuthor $txtProjEmail\n* Home page: $txtProjHome\n%*****************************************************\)\n" + set lang erl + } + if {[file exists [file join $dir $txtFileName]] == 0} { + set file [open [file join $dir $txtFileName] w] + puts $file $text + close $file + } + # file attributes "$dir/$txtFileName.tcl" -permissions "777" + # catch {chmod 744 "$dir/$txtFileName.tcl"} mes + foreach f {README TODO CHANGELOG COPYING INSTALL} { + if {[file exists [file join $dir $f]] != 1} { + set file [open [file join $dir $f] w] + puts $file "$text" + if {$f == "CHANGELOG"} { + if {$tcl_platform(platform) == "windows"} { + set d [clock format [clock scan "now" -base [clock seconds]] -format %d/%m/%Y] + } elseif {$tcl_platform(platform) == "mac"} { + set d "Needed date command for this platform" + } elseif {$tcl_platform(platform) == "unix"} { + set d [clock format [clock scan "now" -base [clock seconds]] -format %d/%m/%Y] + } + + puts $file "$d\n\t- Beginning the project" + } + close $file + } + } + } else { + ## Insert new project into tree ## + # $tree insert end root $projShortName -text "$txtProjName" -font $fontNormal \ + # -data "prj_$projShortName" -open 0 -image [Bitmap::get folder] + # GetFiles $txtDirName $projShortName $tree + } + AddNewProjectIntoTree $projShortName.proj +} + +## OPEN EXISTING PROJECT AND ADDED INYO PROJMAN TREE ## +proc OpenProj {nbNode} { + global projDir workDir openProjDir prjDir prjName + #set prjDir [SelectDir $projDir] + # puts $nbNode + # what is a tree we clicked? + if {$nbNode eq "files"} { + set tree .frmBody.frmCat.noteBook.ffiles.frmTreeFiles.treeFiles + } elseif {$nbNode eq "projects"} { + set tree .frmBody.frmCat.noteBook.fprojects.frmTree.tree + } + set item [$tree itemcget [$tree selection get] -data] + puts $item + if {[file isdirectory $item]} { + set prjDir $item + } elseif {[file isfile $item]} { + tk_messageBox -type ok -icon error -message "File will not added like project!" + return + } + + if {$prjDir != ""} { + set prjName "[file tail $prjDir]" + NewProj open "" "" + #file copy $prjDir $projDir + } + return +} + + +proc AddNewProjectIntoTree {proj} { + global workDir tree imgDir fontNormal + lappend rList [list [file join $workDir $proj]] + set projFile [open [file join $workDir $proj] r] + set prjName [file rootname $proj] + while {[gets $projFile line]>=0} { + scan $line "%s" keyWord + set string [string range $line [string first "\"" $line] [string last "\"" $line]] + set string [string trim $string "\""] + if {$keyWord == "ProjectName"} { + regsub -all " " $string "_" project + set projName "$string" + } + if {$keyWord == "ProjectDirName"} { + set projList($prjName) [file dirname $string] + puts "$projList($prjName) - $string" + $tree insert end root $prjName -text "$projName" -font $fontNormal \ + -data "prj_$prjName" -open 0\ + -image [Bitmap::get [file join $imgDir folder.gif]] + GetFiles [file join $string] $prjName $tree + set dir $string + } + } +} + proc AddToProj {fileName mode} { global projDir workDir activeProject tree noteBook fontNormal imgDir tree set type [string trim [file extension $fileName] {.}] @@ -186,9 +680,13 @@ proc DelProj {} { } close $file - set answer [tk_messageBox -message "[::msgcat::mc "Delete project"] \"$activeProject\" ?"\ - -type yesno -icon question -default yes] - case $answer { + set answer [tk_messageBox \ + -message "[::msgcat::mc "Delete project"] \"$activeProject\" \ + [::msgcat::mc "with all files"]?\n\ + [::msgcat::mc "If press \"Yes\" will deleted all files!"]\n\ + [::msgcat::mc "If press \"No\" will deleted only proj-file"]" \ + -type yesnocancel -icon question -default yes] + switch $answer { yes { FileDialog $tree close_all file delete -force $projDir @@ -199,6 +697,14 @@ proc DelProj {} { set activeProject "" LabelUpdate .frmStatus.frmActive.lblActive "" } + no { + file delete -force [file join $workDir $activeProject.proj] + file delete -force [file join $workDir $activeProject.tags] + $tree delete [$tree selection get] + $tree configure -redraw 1 + set activeProject "" + LabelUpdate .frmStatus.frmActive.lblActive "" + } } } @@ -497,6 +1003,9 @@ proc InsertTitle {newFile type} { + + + diff --git a/lib/projects_new.tcl b/lib/projects_new.tcl deleted file mode 100644 index 911e3ed..0000000 --- a/lib/projects_new.tcl +++ /dev/null @@ -1,502 +0,0 @@ -####################################### -# 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 -####################################### - - -proc NewProj {type proj l} { - global fontNormal fontBold tree projDir workDir activeProject fileList noteBook imgDir prjDir - global openProjDir tclDir frm lang operType - set operType $type - if {$operType == "edit" && $proj == ""} { - set answer [tk_messageBox\ - -message "[::msgcat::mc "Not found active project"]"\ - -type ok -icon warning -title [::msgcat::mc "Warning"]] - case $answer { - ok {return 0} - } - } - set typeProjects "Tcl Tcl/Tk Java Perl Fortran O'Caml PHP Ruby Erlang" - - set node [$noteBook page [$noteBook index newproj]] - if {$node != ""} { - $noteBook raise newproj - return 0 - } else { - set w [$noteBook insert end newproj -text [::msgcat::mc "New project"]] - } - set frm [frame $w.frmProjSettings] - pack $frm -fill both -expand true - - image create photo imgFold -format gif -file [file join $imgDir folder.gif] - variable frm_1 - set frm_1 [frame $frm.frmProjName] - label $frm_1.lblProjName -text [::msgcat::mc "Project name"] -width 20 -anchor w - entry $frm_1.txtProjName -textvariable txtProjName -bd 0 -relief flat - pack $frm_1.lblProjName -side left - pack $frm_1.txtProjName -side left -fill x -expand true - - ### - set frm_lang [frame $frm.frmLanguage] - set lang "Tcl" - label $frm_lang.lblLanguage -text [::msgcat::mc "Project type"] -width 20 -anchor w - set combo [ - ComboBox $frm_lang.txtLocale \ - -textvariable lang -editable false \ - -autocomplete true -autopost true \ - -selectbackground "#55c4d1" -selectborderwidth 0 \ - -values $typeProjects - ] - #$combo setvalues $lang - pack $frm_lang.lblLanguage -side left - pack $combo -fill x -expand true - bind $combo { append txtFileName ".[GetExtentionProj $lang]"} - ### - - set frm_2 [frame $frm.frmFileName] - label $frm_2.lblFileName -text [::msgcat::mc "Project file"] -width 20 -anchor w - entry $frm_2.txtFileName -textvariable txtFileName -bd 0 -relief flat - pack $frm_2.lblFileName -side left - pack $frm_2.txtFileName -side left -fill x -expand true - bind $frm_2.txtFileName { - append txtFileName ".[GetExtentionProj $lang]" - } - #$frm_2.txtFileName insert end $txtProjName - - set frm_8 [frame $frm.frmDirName] - label $frm_8.lblDirName -text [::msgcat::mc "Project dir"] -width 20 -anchor w - entry $frm_8.txtDirName -textvariable txtDirName - button $frm_8.btnDirName -image imgFold -relief flat \ - -command { - $frm.frmDirName.txtDirName configure -state normal - InsertEnt $frm.frmDirName.txtDirName [tk_chooseDirectory -initialdir $projDir -title "[::msgcat::mc "Select directory"]" -parent .] - $frm.frmDirName.txtDirName configure -state disable - } - pack $frm_8.lblDirName -side left - pack $frm_8.txtDirName -side left -fill x -expand true - pack $frm_8.btnDirName -side left - bind $frm_8.txtDirName { - - } - - set frm_13 [frame $frm.frmCompiler] - label $frm_13.lblCompiler -text [::msgcat::mc "Compiler"]\ - -width 20 -anchor w - entry $frm_13.txtCompiler -textvariable txtCompiler - button $frm_13.btnCompiler -image imgFold -relief flat\ - -command { - InsertEnt $frm.frmCompiler.txtCompiler [tk_getOpenFile -initialdir $tclDir -parent .] - } - pack $frm_13.lblCompiler -side left - pack $frm_13.txtCompiler -side left -fill x -expand true - pack $frm_13.btnCompiler -side left - - set txtProjInterp [GetInterp $lang] - set frm_12 [frame $frm.frmProjInterp] - label $frm_12.lblProjInterp -text [::msgcat::mc "Interpetator"]\ - -width 20 -anchor w - entry $frm_12.txtProjInterp -textvariable txtProjInterp - button $frm_12.btnInterp -image imgFold -relief flat\ - -command { - InsertEnt $frm.frmProjInterp.txtProjInterp [tk_getOpenFile -initialdir $tclDir -parent .] - } - pack $frm_12.lblProjInterp -side left - pack $frm_12.txtProjInterp -side left -fill x -expand true - pack $frm_12.btnInterp -side left - bind $frm_12.txtProjInterp { - set txtProjInterp [GetInterp $lang] - } - - set frm_4 [frame $frm.frmVersion] - label $frm_4.lblProjVersion -text [::msgcat::mc "Version"] -width 20 -anchor w - entry $frm_4.txtProjVersion -textvariable txtProjVersion -bd 0 -relief flat - pack $frm_4.lblProjVersion -side left - pack $frm_4.txtProjVersion -side left -fill x -expand true - InsertEnt $frm_4.txtProjVersion "0.0.1" - - set frm_11 [frame $frm.frmRelease] - label $frm_11.lblProjRelease -text [::msgcat::mc "Release"] -width 20 -anchor w - entry $frm_11.txtProjRelease -textvariable txtProjRelease -bd 0 -relief flat - pack $frm_11.lblProjRelease -side left - pack $frm_11.txtProjRelease -side left -fill x -expand true - InsertEnt $frm_11.txtProjRelease "1" - - set frm_3 [frame $frm.frmProjAuthor] - label $frm_3.lblProjAuthor -text [::msgcat::mc "Author"] -width 20 -anchor w - entry $frm_3.txtProjAuthor -textvariable txtProjAuthor -bd 0 -relief flat - pack $frm_3.lblProjAuthor -side left - pack $frm_3.txtProjAuthor -side left -fill x -expand true - - set frm_9 [frame $frm.frmProjEmail] - label $frm_9.lblProjEmail -text [::msgcat::mc "E-mail"] -width 20 -anchor w - entry $frm_9.txtProjEmail -textvariable txtProjEmail -bd 0 -relief flat - pack $frm_9.lblProjEmail -side left - pack $frm_9.txtProjEmail -side left -fill x -expand true - - set frm_5 [frame $frm.frmProjCompany] - label $frm_5.lblProjCompany -text [::msgcat::mc "Company"] -width 20 -anchor w - entry $frm_5.txtProjCompany -textvariable txtProjCompany -bd 0 -relief flat - pack $frm_5.lblProjCompany -side left - pack $frm_5.txtProjCompany -side left -fill x -expand true - - set frm_10 [frame $frm.frmProjHome] - label $frm_10.lblProjHome -text [::msgcat::mc "Home page"] -width 20 -anchor w - entry $frm_10.txtProjHome -textvariable txtProjHome - pack $frm_10.lblProjHome -side left - pack $frm_10.txtProjHome -side left -fill x -expand true - - set frm_7 [frame $frm.frmWinTitle ] - label $frm_7.lblWinTitle -text [::msgcat::mc "Create new project"] -height 2 -font $fontBold - - - pack $frm_7.lblWinTitle -fill x -expand true - - set frm_6 [frame $frm.frmBtn ] - if {$operType == "edit" && $proj != ""} { - $noteBook itemconfigure newproj -text [::msgcat::mc "Project settings"] - button $frm_6.btnProjCreate -text [::msgcat::mc "Save"] -relief flat \ - -font $fontNormal -command { - regsub -all {\\} $txtProjInterp {\\\\} $txtProjInterp - SaveProj "$txtFileName" "$lang" "$txtProjName" "$txtFileName" "$txtDirName"\ - "$txtCompiler" "$txtProjInterp" "$txtProjVersion" "$txtProjRelease"\ - "$txtProjAuthor" "$txtProjEmail" "$txtProjCompany" "$txtProjHome" - $noteBook delete newproj - $noteBook raise [$noteBook page end] - } - } else { - button $frm_6.btnProjCreate -text [::msgcat::mc "Create"] -relief flat \ - -font $fontNormal -command { - CreateProj "$operType" "$lang" "$txtFileName" "$txtProjName" "$txtFileName" "$txtDirName"\ - "$txtCompiler" "$txtProjInterp" "$txtProjVersion" "$txtProjRelease"\ - "$txtProjAuthor" "$txtProjEmail" "$txtProjCompany" "$txtProjHome" - $noteBook delete newproj - $noteBook raise [$noteBook page end] - } - - } - button $frm_6.btnClose -text [::msgcat::mc "Cancel"] -relief flat -font $fontNormal -command { - $noteBook delete newproj - $noteBook raise [$noteBook page end] - } - pack $frm_6.btnProjCreate $frm_6.btnClose -padx 10 -pady 20 -side right - pack $frm_7 $frm_1 $frm_lang $frm_2 $frm_8 $frm_13 $frm_12 $frm_4 $frm_11 $frm_3 $frm_9 $frm_5 $frm_10 $frm_6\ - -side top -fill x -padx 10 -pady 5 - pack $frm_6 -side top -fill x -expand true -anchor n - bind $w "$noteBook delete newproj" - $noteBook raise newproj - - ## EDIT PROJECT SETTINGS ## - if {$operType == "edit" && $proj != ""} { - $frm.frmDirName.txtDirName configure -state normal - $frm_7.lblWinTitle configure -text [::msgcat::mc "Project settings"] - $frm_6.btnProjCreate configure -text "[::msgcat::mc "Save"]" - set file [open [file join $workDir $proj.proj] r] - while {[gets $file line]>=0} { - scan $line "%s" keyWord - set string [string range $line [string first "\"" $line] [string last "\"" $line]] - set string [string trim $string "\""] - # regsub -all " " $string "_" project - puts $string - switch $keyWord { - ProjectName {InsertEnt $frm_1.txtProjName "$string"} - ProjectFileName {InsertEnt $frm_2.txtFileName "$string"} - ProjectLanguage {set lang "$string"} - ProjectDirName {InsertEnt $frm_8.txtDirName "$string"} - ProjectCompiler {InsertEnt $frm_13.txtCompiler "$string"} - ProjectInterp {InsertEnt $frm_12.txtProjInterp "$string"} - ProjectVersion {InsertEnt $frm_4.txtProjVersion "$string"} - ProjectRelease {InsertEnt $frm_11.txtProjRelease "$string"} - ProjectAuthor {InsertEnt $frm_3.txtProjAuthor "$string"} - ProjectEmail {InsertEnt $frm_9.txtProjEmail "$string"} - ProjectCompany {InsertEnt $frm_5.txtProjCompany "$string"} - ProjectHome {InsertEnt $frm_10.txtProjHome "$string"} - } - } - close $file - } elseif {$operType == "open"} { - $frm_7.lblWinTitle configure -text [::msgcat::mc "Open project"] - InsertEnt $frm_1.txtProjName "$proj" - InsertEnt $frm_2.txtFileName "$proj" - #$combo setvalue $lang - InsertEnt $frm_8.txtDirName "$proj" - $frm_8.txtDirName configure -state normal - puts $prjDir - InsertEnt $frm_8.txtDirName "$prjDir" - InsertEnt $frm_13.txtCompiler "" - InsertEnt $frm_12.txtProjInterp "" - InsertEnt $frm_4.txtProjVersion "0.0.1" - InsertEnt $frm_11.txtProjRelease "1" - InsertEnt $frm_3.txtProjAuthor "" - InsertEnt $frm_9.txtProjEmail "" - InsertEnt $frm_5.txtProjCompany "" - InsertEnt $frm_10.txtProjHome "" - } else { - InsertEnt $frm_1.txtProjName "" - InsertEnt $frm_2.txtFileName "" - InsertEnt $frm_8.txtDirName "" - InsertEnt $frm_13.txtCompiler "" - InsertEnt $frm_12.txtProjInterp "" - InsertEnt $frm_4.txtProjVersion "0.0.1" - InsertEnt $frm_11.txtProjRelease "1" - InsertEnt $frm_3.txtProjAuthor "" - InsertEnt $frm_9.txtProjEmail "" - InsertEnt $frm_5.txtProjCompany "" - InsertEnt $frm_10.txtProjHome "" - } - # bind autocomlite dir only if new project - if {[$frm_8.txtDirName get ] eq ""} { - bind $frm_1.txtProjName { - regsub -all -- {\s} [string tolower [Translit [$frm_1.txtProjName get]]] "_" txtFileName - set txtDirName [file join $projDir $txtFileName] - } - } - -} - -proc GetExtentionProj {lang} { - if {$lang=="Tcl" || $lang=="Tcl/Tk"} { - set ext "tcl" - } elseif {$lang == "Perl"} { - set ext pl - } elseif {$lang=="Java"} { - set ext "java" - } elseif {$lang=="Fortran"} { - set ext "for" - } elseif {$lang=="O'Caml"} { - set ext ml - } elseif {$lang=="Ruby"} { - set ext rb - } elseif {$lang=="PHP"} { - set ext php - } elseif {$lang=="Erlang"} { - set ext erl - } - return $ext -} -proc GetInterp {lang} { - global tcl_platform - if {$tcl_platform(platform) == "unix"} { - set interp [GetInterp_unix $lang] - } elseif {$tcl_platform(platform) == "windows"} { - set interp [GetInterp_windows $lang] - } else { - set interp "" - } - return $interp -} - -proc GetInterp_unix {lang} { - set searchCommand "which" - switch $lang { - Tcl {set interp "tclsh"} - Tcl/Tk {set interp "wish"} - Perl {set interp "perl"} - Java {set interp "java"} - Fortran {set interp ""} - O'Caml {set interp ""} - Ruby {set interp "ruby"} - PHP {set interp "php"} - Perl {set interp "perl"} - Erlang {set interp ""} - } - try { - set result [exec $searchCommand $interp] - } trap {} {} { - puts "Error: don't find interp for $lang" - set result "" - } - return $result -} -proc GetInterp_windows {lang} { - set searchCommand "where" - switch $lang { - Tcl {set interp "tclsh"} - Tcl/Tk {set interp "wish"} - Perl {set interp "perl"} - Java {set interp "java"} - Fortran {set interp ""} - O'Caml {set interp ""} - Ruby {set interp "ruby"} - PHP {set interp "php"} - Perl {set interp "perl"} - Erlang {set interp ""} - } - try { - set result [exec $searchCommand $interp] - } trap {} {} { - puts "Error: don't find interp for $lang" - set result "" - } - return $result -} - -proc SaveProj {txtFileName lang txtProjName txtFileName txtDirName \ -txtCompiler txtProjInterp txtProjVersion txtProjRelease txtProjAuthor \ -txtProjEmail txtProjCompany txtProjHome} { - global projDir workDir dataDir - - set file [file tail $txtDirName] - set projFile [open [file join $workDir $file.proj] w] - puts $projFile "ProjectName \"$txtProjName\"" - puts $projFile "ProjectLanguage \"$lang\"" - puts $projFile "ProjectFileName \"$txtFileName\"" - puts $projFile "ProjectDirName \"$txtDirName\"" - puts $projFile "ProjectCompiler \"$txtCompiler\"" - puts $projFile "ProjectInterp \"$txtProjInterp\"" - puts $projFile "ProjectVersion \"$txtProjVersion\"" - puts $projFile "ProjectRelease \"$txtProjRelease\"" - puts $projFile "ProjectAuthor \"$txtProjAuthor\"" - puts $projFile "ProjectEmail \"$txtProjEmail\"" - puts $projFile "ProjectCompany \"$txtProjCompany\"" - puts $projFile "ProjectHome \"$txtProjHome\"" - close $projFile -} - - -## CREATING PROJECT PROCEDURE ## -proc CreateProj {type lang txtFileName txtProjName txtFileName txtDirName \ -txtCompiler txtProjInterp txtProjVersion txtProjRelease txtProjAuthor txtProjEmail \ -txtProjCompany txtProjHome} { - global projDir workDir tree fontNormal dataDir tcl_platform - puts "$type $lang";# "$txtFileName" "$txtProjName" "$txtFileName" "$txtDirName"\ - # "$txtCompiler" "$txtProjInterp" "$txtProjVersion" "$txtProjRelease"\ - # "$txtProjAuthor" "$txtProjEmail" "$txtProjCompany" "$txtProjHome" - ## SAVING PROJECT SETTINGS ## - set projShortName [file tail $txtDirName] - - set projFile [open [file join $workDir $projShortName.proj] w] - - puts $projFile "ProjectName \"$txtProjName\"" - puts $projFile "ProjectLanguage \"$lang\"" - puts $projFile "ProjectFileName \"$txtFileName\"" - puts $projFile "ProjectDirName \"$txtDirName\"" - puts $projFile "ProjectCompiler \"$txtCompiler\"" - puts $projFile "ProjectInterp \"$txtProjInterp\"" - puts $projFile "ProjectVersion \"$txtProjVersion\"" - puts $projFile "ProjectRelease \"$txtProjRelease\"" - puts $projFile "ProjectAuthor \"$txtProjAuthor\"" - puts $projFile "ProjectEmail \"$txtProjEmail\"" - puts $projFile "ProjectCompany \"$txtProjCompany\"" - puts $projFile "ProjectHome \"$txtProjHome\"" - close $projFile - if {$type != "open"} { - set dir [file join $projDir $txtDirName] - if {[file exists "$dir"] != 1} { - file mkdir "$dir" - } - # file header - if {$lang=="Tcl" || $lang == "Tcl/Tk"} { - set text "######################################################\n#\t$txtProjName\n#\tDistributed under GNU Public License\n# Author: $txtProjAuthor $txtProjEmail\n# Home page: $txtProjHome\n######################################################\n" - } elseif {$lang == "Perl"} { - set lang pl - set text "######################################################\n#\t$txtProjName\n#\tDistributed under GNU Public License\n# Author: $txtProjAuthor $txtProjEmail\n# Home page: $txtProjHome\n######################################################\n" - } elseif {$lang=="Java"} { - set text "/*\n*****************************************************\n*\t$txtProjName\n*\tDistributed under GNU Public License\n* Author: $txtProjAuthor $txtProjEmail\n* Home page: $txtProjHome\n*****************************************************\n*/\n" - } elseif {$lang=="Fortran"} { - set text "\nc*****************************************************\nc*\t$txtProjName\n*c\tDistributed under GNU Public License\nc* Author: $txtProjAuthor $txtProjEmail\nc* Home page: $txtProjHome\nc*****************************************************\n*/\n" - } elseif {$lang=="O'Caml"} { - set text "\(*****************************************************\n*\t$txtProjName\n*\tDistributed under GNU Public License\n* Author: $txtProjAuthor $txtProjEmail\n* Home page: $txtProjHome\n******************************************************\)\n" - set lang ml - } elseif {$lang=="Ruby"} { - set lang rb - set text "######################################################\n#\t$txtProjName\n#\tDistributed under GNU Public License\n# Author: $txtProjAuthor $txtProjEmail\n# Home page: $txtProjHome\n######################################################\n" - } elseif {$lang=="PHP"} { - set text "" - set lang php - } elseif {$lang=="Erlang"} { - set text "\%**************************************************\n%\t$txtProjName\n%\tDistributed under GNU Public License\n% Author: $txtProjAuthor $txtProjEmail\n* Home page: $txtProjHome\n%*****************************************************\)\n" - set lang erl - } - if {[file exists [file join $dir $txtFileName]] == 0} { - set file [open [file join $dir $txtFileName] w] - puts $file $text - close $file - } - # file attributes "$dir/$txtFileName.tcl" -permissions "777" - # catch {chmod 744 "$dir/$txtFileName.tcl"} mes - foreach f {README TODO CHANGELOG COPYING INSTALL} { - if {[file exists [file join $dir $f]] != 1} { - set file [open [file join $dir $f] w] - puts $file "$text" - if {$f == "CHANGELOG"} { - if {$tcl_platform(platform) == "windows"} { - set d [clock format [clock scan "now" -base [clock seconds]] -format %d/%m/%Y] - } elseif {$tcl_platform(platform) == "mac"} { - set d "Needed date command for this platform" - } elseif {$tcl_platform(platform) == "unix"} { - set d [clock format [clock scan "now" -base [clock seconds]] -format %d/%m/%Y] - } - - puts $file "$d\n\t- Beginning the project" - } - close $file - } - } - } else { - ## Insert new project into tree ## - # $tree insert end root $projShortName -text "$txtProjName" -font $fontNormal \ - # -data "prj_$projShortName" -open 0 -image [Bitmap::get folder] - # GetFiles $txtDirName $projShortName $tree - } - AddNewProjectIntoTree $projShortName.proj -} - -## OPEN EXISTING PROJECT AND ADDED INYO PROJMAN TREE ## -proc OpenProj {nbNode} { - global projDir workDir openProjDir prjDir prjName - #set prjDir [SelectDir $projDir] - # puts $nbNode - # what is a tree we clicked? - if {$nbNode eq "files"} { - set tree .frmBody.frmCat.noteBook.ffiles.frmTreeFiles.treeFiles - } elseif {$nbNode eq "projects"} { - set tree .frmBody.frmCat.noteBook.fprojects.frmTree.tree - } - set item [$tree itemcget [$tree selection get] -data] - puts $item - if {[file isdirectory $item]} { - set prjDir $item - } elseif {[file isfile $item]} { - tk_messageBox -type ok -icon error -message "File will not added like project!" - return - } - - if {$prjDir != ""} { - set prjName "[file tail $prjDir]" - NewProj open "" "" - #file copy $prjDir $projDir - } - return -} - - -proc AddNewProjectIntoTree {proj} { - global workDir tree imgDir fontNormal - lappend rList [list [file join $workDir $proj]] - set projFile [open [file join $workDir $proj] r] - set prjName [file rootname $proj] - while {[gets $projFile line]>=0} { - scan $line "%s" keyWord - set string [string range $line [string first "\"" $line] [string last "\"" $line]] - set string [string trim $string "\""] - if {$keyWord == "ProjectName"} { - regsub -all " " $string "_" project - set projName "$string" - } - if {$keyWord == "ProjectDirName"} { - set projList($prjName) [file dirname $string] - puts "$projList($prjName) - $string" - $tree insert end root $prjName -text "$projName" -font $fontNormal \ - -data "prj_$prjName" -open 0\ - -image [Bitmap::get [file join $imgDir folder.gif]] - GetFiles [file join $string] $prjName $tree - set dir $string - } - } -} - - - diff --git a/lib/settings.tcl b/lib/settings.tcl index 934cd78..c85a217 100644 --- a/lib/settings.tcl +++ b/lib/settings.tcl @@ -23,9 +23,11 @@ proc 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 -bg $editor(bg) + 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 -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)] @@ -876,3 +878,4 @@ proc SaveSettings {} { $noteBook raise [$noteBook page end] } + diff --git a/lib/tree.tcl b/lib/tree.tcl index 12e45da..76b702c 100644 --- a/lib/tree.tcl +++ b/lib/tree.tcl @@ -17,7 +17,7 @@ namespace eval FileTree { proc FileTree::create {nb} { global editor global treeFiles - set frmTreeFiles [ScrolledWindow $nb.frmTreeFiles -bg $editor(bg)] + set frmTreeFiles [ScrolledWindow $nb.frmTreeFiles -bg $editor(bg) -background $editor(bg) ] set treeFiles [ Tree $frmTreeFiles.treeFiles \ @@ -195,11 +195,14 @@ proc FileTree::GetAllDirs {treeFiles} { if {[catch {cd $rootDir}] != 0} { return "" } + set rootNode [$treeFiles insert end root $rootDir -text "$rootDir" -font $fontNormal \ + -data "dir_root" -open 1\ + -image [Bitmap::get [file join $imgDir folder.gif]]] - $treeFiles insert end root $rootDir -text "$rootDir" -font $fontNormal \ - -data "dir_root" -open 0\ - -image [Bitmap::get [file join $imgDir folder.gif]] - GetFiles [file join $rootDir] root $treeFiles +# $treeFiles insert end root $rootDir -text "$rootDir" -font $fontNormal \ +# -data "dir_root" -open 0\ +# -image [Bitmap::get [file join $imgDir folder.gif]] + GetFiles [file join $rootDir] $rootNode $treeFiles #set dir $string $treeFiles configure -redraw 1 @@ -580,3 +583,6 @@ proc GetTreeForNode {node} { } + + + diff --git a/msgs/en.msg b/msgs/en.msg index b7045fc..766bf1b 100644 --- a/msgs/en.msg +++ b/msgs/en.msg @@ -42,6 +42,9 @@ ::msgcat::mcset en "Delete" ::msgcat::mcset en "Delete backup files" ::msgcat::mcset en "Delete project" +::msgcat::mc "with all files" +::msgcat::mc "If press \"Yes\" will deleted all files!" +::msgcat::mc "If press \"No\" will deleted only proj-file" ::msgcat::mcset en "Delete from project" ::msgcat::mcset en "Docs dir" ::msgcat::mcset en "Don't selected file" @@ -168,3 +171,4 @@ ::msgcat::mcset en "Word wrapping" ::msgcat::mcset en "Work dir" + diff --git a/msgs/ru.msg b/msgs/ru.msg index b91ab3f..b2d9da9 100644 --- a/msgs/ru.msg +++ b/msgs/ru.msg @@ -45,6 +45,9 @@ ::msgcat::mcset ru "Delete file" "Удалить файл" ::msgcat::mcset ru "Delete backup files" "Удалять временные файлы" ::msgcat::mcset ru "Delete project" "Удалить проект" +::msgcat::mcset ru "with all files" "вместе с файлами" +::msgcat::mcset ru "If press \"Yes\" will deleted all files!" "Если нажать \"Да\" будут удалены все файлы" +::msgcat::mcset ru "If press \"No\" will deleted only proj-file" "Если нажать \"Нет\" будет удалён только файл проекта" ::msgcat::mcset ru "Delete from project" "Удалить из проекта" ::msgcat::mcset ru "Docs dir" "Каталог документации" ::msgcat::mcset ru "Don't selected file" "Не определен файл" @@ -173,3 +176,4 @@ ::msgcat::mcset ru "Work dir" "Рабочий каталог" + diff --git a/projman.tcl b/projman.tcl index b5bb4b4..212fd7f 100755 --- a/projman.tcl +++ b/projman.tcl @@ -112,33 +112,67 @@ source [file join $dataDir main.tcl] #option add *tree.foreground red widgetDefault # Set colors for widgets -option add *Frame.background $editor(bg) startupFile -option add *Scrollableframe.background $editor(bg) startupFile -option add *Scrolledwindow.background $editor(bg) startupFile -option add *Button.foreground $editor(fg) startupFile -option add *Button.background $editor(bg) startupFile -option add *Entry.foreground $editor(fg) startupFile -option add *Entry.background $editor(bg) startupFile -option add *Label.foreground $editor(fg) startupFile -option add *Label.background $editor(bg) interactive -option add *Checkbox.foreground $editor(fg) startupFile -option add *Checkbox.background $editor(bg) startupFile -option add *Checkbutton.foreground $editor(fg) startupFile -option add *Checkbutton.background $editor(bg) startupFile -option add *Combobox.foreground $editor(fg) startupFile -option add *Combobox.background $editor(bg) startupFile -option add *Text.foreground $editor(fg) startupFile -option add *Text.background $editor(bg) startupFile -option add *Tree.background $editor(bg) startupFile -option add *Tree.foreground $editor(fg) startupFile -option add *scrollbar.background $editor(bg) startupFile -option add *Canvas.background $editor(bg) startupFile -option add *Canvas.foreground $editor(fg) startupFile -option add *Node.foreground $editor(fg) startupFile +option add *Frame.Background $editor(bg) startupFile +option add *ScrollableFrame.Background $editor(bg) startupFile +option add *ScrolledWindow.Background $editor(bg) startupFile +option add *Button.Foreground $editor(fg) startupFile +option add *Button.Background $editor(bg) startupFile +option add *Button.activeBackground $editor(bg) userDefault +option add *Button.activeForeground $editor(fg) userDefault + +option add *Entry.Foreground $editor(fg) startupFile +option add *Entry.Background $editor(bg) startupFile +option add *Label.Foreground $editor(fg) startupFile +option add *Label.Background $editor(bg) interactive +option add *Checkbox.Foreground $editor(fg) startupFile +option add *Checkbox.Background $editor(bg) startupFile +option add *Checkbutton.Foreground $editor(fg) startupFile +option add *Checkbutton.Background $editor(bg) startupFile +option add *Combobox.Foreground $editor(fg) startupFile +option add *Combobox.Background $editor(bg) startupFile +option add *Text.Foreground $editor(fg) startupFile +option add *Text.Background $editor(bg) startupFile +option add *Tree.Background $editor(bg) startupFile +option add *Tree.Foreground $editor(fg) startupFile +option add *Scrollbar.Background $editor(bg) startupFile +option add *Canvas.Background $editor(bg) startupFile +option add *Canvas.Foreground $editor(fg) startupFile +option add *Node.Foreground $editor(fg) startupFile option add *NoteBook.bg $editor(bg) startupFile option add *NoteBook.fg $editor(fg) startupFile -option add *Listbox.foreground $editor(fg) startupFile -option add *Listbox.background $editor(bg) startupFile -option add *Scrollbar.background $editor(bg) startupFile -option add *Widget.color red startupFile +option add *Listbox.Foreground $editor(fg) startupFile +option add *Listbox.Background $editor(bg) startupFile + +#option add *Button.font $guifont userDefault +#option add *Label.font $guifont userDefault +#option add *Menu.font $guifont userDefault +#option add *Menubutton.font $guifont userDefault +option add *Dialog.msg.background $editor(bg) + +# option add *Text.Background $textbg userDefault +# option add *Entry.Background $textbg userDefault +# option add *Text.Foreground $textfg userDefault +# option add *Entry.Foreground $textfg userDefault +# option add *Button.activeBackground $bg userDefault +# option add *Button.activeForeground $fg userDefault +# option add *Scrollbar.activeBackground $bg userDefault +# option add *Scrollbar.troughColor $shadow userDefault +# option add *Canvas.Background $shadow userDefault +# +# # These menu configs work if you use native menus. +# option add *Menu.borderWidth 1 userDefault +# option add *Menu.activeForeground $fg userDefault +# option add *Menubutton.activeForeground $fg userDefault +# +# # This draws a thin border around buttons +# #option add *highlightBackground $bg userDefault +# # Suppress the border +# option add *HighlightThickness 0 userDefault +# # Add it back for text and entry widgets +# option add *Text.highlightBackground $bg userDefault +# option add *Entry.highlightBackground $bg userDefault +# option add *Text.HighlightThickness 2 userDefault +# option add *Entry.HighlightThickness 1 userDefault +# +#