diff --git a/CHANGELOG b/CHANGELOG index a120f43..5e4c4f7 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -38,3 +38,7 @@ 22/07/2022 - Added GO highlight + +27/07/2022 + - Fixed comment/uncomment procedure (last line in selected text) + - Fixed error with save new (untitled) file diff --git a/lib/editor.tcl b/lib/editor.tcl index cd16c9d..7fd2808 100644 --- a/lib/editor.tcl +++ b/lib/editor.tcl @@ -47,7 +47,7 @@ namespace eval Editor { set lineEnd [lindex [split [lindex $selIndex 1] "."] 0] set posBegin [lindex [split [lindex $selIndex 1] "."] 0] set posEnd [lindex [split [lindex $selIndex 1] "."] 1] - if {$lineEnd == $lineNum || $posEnd == 0} { + if {$lineEnd == $lineNum && $posEnd == 0} { set lineEnd [expr $lineEnd - 1] } for {set i $lineBegin} {$i <=$lineEnd} {incr i} { @@ -394,24 +394,29 @@ namespace eval Editor { } else { set untitledNumber 0 } - set filePath untitled-$untitledNumber - set fileName untitled-$untitledNumber + # set filePath untitled-$untitledNumber + # set fileName untitled-$untitledNumber set fileFullPath untitled-$untitledNumber #puts [Tree::InsertItem $tree {} $fileFullPath "file" $fileName] set nbEditorItem [NB::InsertItem $nbEditor $fileFullPath "file"] - puts "$nbEditorItem, $nbEditor" + # puts "$nbEditorItem, $nbEditor" Editor $fileFullPath $nbEditor $nbEditorItem SetModifiedFlag $nbEditorItem } + proc Editor {fileFullPath nb itemName} { global cfgVariables set fr $itemName if ![string match "*untitled*" $itemName] { - set lblName "lbl[string range $itemName [expr [string last "." $itemName] +1] end]" - ttk::label $fr.$lblName -text $fileFullPath - pack $fr.$lblName -side top -anchor w -fill x + set lblText $fileFullPath + } else { + set lblText "" } + set lblName "lbl[string range $itemName [expr [string last "." $itemName] +1] end]" + ttk::label $fr.$lblName -text $lblText + pack $fr.$lblName -side top -anchor w -fill x + set frmText [ttk::frame $fr.frmText -border 1] set txt $frmText.t @@ -420,7 +425,7 @@ namespace eval Editor { ctext $txt -yscrollcommand "$frmText.s set" -font $cfgVariables(font) -linemapfg $cfgVariables(lineNumberFG) \ -tabs "[expr {4 * [font measure $cfgVariables(font) 0]}] left" -tabstyle tabular -undo true pack $txt -fill both -expand 1 - puts ">>>>>>> [bindtags $txt]" + # puts ">>>>>>> [bindtags $txt]" if {$cfgVariables(lineNumberShow) eq "false"} { $txt configure -linemap 0 } diff --git a/lib/files.tcl b/lib/files.tcl index 04efacc..b6a7559 100644 --- a/lib/files.tcl +++ b/lib/files.tcl @@ -77,8 +77,10 @@ namespace eval FileOper { $nbEditor forget $nbItem destroy $nbItem set treeItem "file::[string range $nbItem [expr [string last "." $nbItem] +1] end ]" - if {[$tree parent $treeItem] eq "" } { - $tree delete $treeItem + if [$tree exists $treeItem] { + if {[$tree parent $treeItem] eq ""} { + $tree delete $treeItem + } } unset modified($nbItem) } @@ -92,11 +94,12 @@ namespace eval FileOper { if {$filePath eq ""} { return } - set fileName [string range $filePath [expr [string last "/" $filePath]+1] end] - puts ">>>>>$filePath, $fileName" + # set fileName [string range $filePath [expr [string last "/" $filePath]+1] end] + set fileName [file tail $filePath] + $nbEditor tab $nbEditorItem -text $fileName # set treeitem [Tree::InsertItem $tree {} $filePath "file" $fileName] - # Close - # Edit $filePath + set lblName "lbl[string range $nbEditorItem [expr [string last "." $nbEditorItem] +1] end]" + $nbEditorItem.$lblName configure -text $filePath } else { set treeItem "file::[string range $nbEditorItem [expr [string last "." $nbEditorItem] +1] end ]" set filePath [Tree::GetItemID $tree $treeItem] diff --git a/lib/notebook.tcl b/lib/notebook.tcl index 18ddfb0..14f2fa0 100644 --- a/lib/notebook.tcl +++ b/lib/notebook.tcl @@ -28,11 +28,10 @@ namespace eval NB { puts "NB item - $fm" return $fm } + proc CloseTab {w x y} { if {[$w identify $x $y] == "close_button"} { - puts "Hurrah! Close tab [$w index @$x,$y] plz." FileOper::Close } } } - diff --git a/lib/procedure.tcl b/lib/procedure.tcl index 0d3de49..63bf78c 100644 --- a/lib/procedure.tcl +++ b/lib/procedure.tcl @@ -73,4 +73,3 @@ proc SetModifiedFlag {w} { } $nbEditor tab $w -text $lbl } -