Исправлено комментирование выделенного фрагмента (последняя строка)
Исправлено закрытие untitled вкладок
This commit is contained in:
		@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -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]
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -73,4 +73,3 @@ proc SetModifiedFlag {w} {
 | 
			
		||||
    }
 | 
			
		||||
    $nbEditor tab $w -text $lbl
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user