From 39aa7ecafe89e7cb80d1bce6a4217fd891756761 Mon Sep 17 00:00:00 2001 From: svkalinin Date: Wed, 27 Jul 2022 16:55:04 +0300 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=BE=20=D0=BA=D0=BE=D0=BC=D0=BC=D0=B5=D0=BD=D1=82?= =?UTF-8?q?=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5=20=D0=B2=D1=8B?= =?UTF-8?q?=D0=B4=D0=B5=D0=BB=D0=B5=D0=BD=D0=BD=D0=BE=D0=B3=D0=BE=20=D1=84?= =?UTF-8?q?=D1=80=D0=B0=D0=B3=D0=BC=D0=B5=D0=BD=D1=82=D0=B0=20(=D0=BF?= =?UTF-8?q?=D0=BE=D1=81=D0=BB=D0=B5=D0=B4=D0=BD=D1=8F=D1=8F=20=D1=81=D1=82?= =?UTF-8?q?=D1=80=D0=BE=D0=BA=D0=B0)=20=D0=98=D1=81=D0=BF=D1=80=D0=B0?= =?UTF-8?q?=D0=B2=D0=BB=D0=B5=D0=BD=D0=BE=20=D0=B7=D0=B0=D0=BA=D1=80=D1=8B?= =?UTF-8?q?=D1=82=D0=B8=D0=B5=20untitled=20=D0=B2=D0=BA=D0=BB=D0=B0=D0=B4?= =?UTF-8?q?=D0=BE=D0=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG | 4 ++++ lib/editor.tcl | 21 +++++++++++++-------- lib/files.tcl | 15 +++++++++------ lib/notebook.tcl | 3 +-- lib/procedure.tcl | 1 - 5 files changed, 27 insertions(+), 17 deletions(-) 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 } -