Исправлен поиск процедуры в тексте по клику в дереве. Исправлено отображение позиции курсора в строке статуса
This commit is contained in:
		@@ -49,3 +49,9 @@
 | 
			
		||||
    - Added GUI font, and GUI foreground color setting
 | 
			
		||||
    - Added tcl and go files images
 | 
			
		||||
    - Added image for file type (extention)
 | 
			
		||||
 | 
			
		||||
03/08/2022
 | 
			
		||||
    - Added some files icon
 | 
			
		||||
    - Fix finded procedure (function) (tree click)
 | 
			
		||||
    - Fix showing position in statusbar 
 | 
			
		||||
    
 | 
			
		||||
 
 | 
			
		||||
@@ -252,9 +252,9 @@ namespace eval Editor {
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    proc ReleaseKey {k txt} {
 | 
			
		||||
        set pos [$txt index insert]
 | 
			
		||||
        switch $k {
 | 
			
		||||
            Return {
 | 
			
		||||
                set pos [$txt index insert]
 | 
			
		||||
                set lineNum [lindex [split $pos "."] 0]
 | 
			
		||||
                set posNum [lindex [split $pos "."] 1]
 | 
			
		||||
                regexp {^(\s*)} [$txt get [expr $lineNum - 1].0 [expr $lineNum - 1].end] -> spaceStart
 | 
			
		||||
@@ -263,6 +263,10 @@ namespace eval Editor {
 | 
			
		||||
                Editor::Indent $txt
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        set lpos [split $pos "."]
 | 
			
		||||
        set lblText "[::msgcat::mc "Row"]: [lindex $lpos 0], [::msgcat::mc "Column"]: [lindex $lpos 1]"
 | 
			
		||||
        .frmStatus.lblPosition configure -text $lblText
 | 
			
		||||
        unset lpos
 | 
			
		||||
    }
 | 
			
		||||
    proc PressKey {k txt} {
 | 
			
		||||
        # puts [Editor::Key $k]
 | 
			
		||||
@@ -413,24 +417,24 @@ namespace eval Editor {
 | 
			
		||||
            if {[regexp -nocase -all -- {^\s*?(proc) (::|)(\w+)(::|)(\w+)\s*?(\{|\()(.*)(\}|\)) \{} $line match v1 v2 v3 v4 v5 v6 params v8]} {
 | 
			
		||||
                set procName "$v2$v3$v4$v5"
 | 
			
		||||
                # lappend procList($activeProject) [list $procName [string trim $params]]
 | 
			
		||||
                puts "$treeItemName proc $procName $params"
 | 
			
		||||
                # puts "$treeItemName proc $procName $params"
 | 
			
		||||
                # tree parent item type text
 | 
			
		||||
                puts [Tree::InsertItem $tree $treeItemName $procName  "func" "$procName ($params)"]
 | 
			
		||||
                puts [Tree::InsertItem $tree $treeItemName $procName  "procedure" "$procName ($params)"]
 | 
			
		||||
            }
 | 
			
		||||
            # GO function
 | 
			
		||||
            if {[regexp -nocase -all -- {^\s*?func\s*?\((\w+\s*?\*\w+)\)\s*?(\w+)\((.*?)\)\s*?\((.*?)\)} $line match v1 funcName params returns]} {
 | 
			
		||||
            if {[regexp -nocase -all -- {^\s*?func\s*?\((\w+\s*?\*\w+)\)\s*?(\w+)\((.*?)\)\s*?(\(\w+\)|\w+|)\s*?\{} $line match v1 funcName params returns]} {
 | 
			
		||||
                # set procName "$v2$v3$v4$v5"
 | 
			
		||||
                # lappend procList($activeProject) [list $procName [string trim $params]]
 | 
			
		||||
                if {$v1 ne ""} {
 | 
			
		||||
                    set linkName [lindex [split $v1 " "] 1]
 | 
			
		||||
                    set funcName "\($linkName\).$funcName"
 | 
			
		||||
                    set functionName "\($linkName\).$funcName"
 | 
			
		||||
                }
 | 
			
		||||
                puts "$treeItemName proc $funcName $params"
 | 
			
		||||
                # puts "$treeItemName func $funcName $params"
 | 
			
		||||
                # tree parent item type text
 | 
			
		||||
                puts [Tree::InsertItem $tree $treeItemName $funcName  "func" "$funcName ($params)"]
 | 
			
		||||
                puts [Tree::InsertItem $tree $treeItemName $funcName  "func" "$functionName ($params)"]
 | 
			
		||||
            }
 | 
			
		||||
            if {[regexp -nocase -all -- {^\s*?func\s*?(\w+)\((.*?)\) (\(\w+\)|\w+|)\s*?\{} $line match funcName params returns]} {
 | 
			
		||||
                puts "$treeItemName proc $funcName $params"
 | 
			
		||||
                # puts "$treeItemName func $funcName $params"
 | 
			
		||||
                # tree parent item type text
 | 
			
		||||
                puts [Tree::InsertItem $tree $treeItemName $funcName  "func" "$funcName ($params)"]
 | 
			
		||||
            }
 | 
			
		||||
@@ -438,6 +442,32 @@ namespace eval Editor {
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    proc FindFunction {findString} {
 | 
			
		||||
        global nbEditor
 | 
			
		||||
        puts $findString
 | 
			
		||||
        set pos "0.0"
 | 
			
		||||
        set txt [$nbEditor select].frmText.t
 | 
			
		||||
        $txt see $pos
 | 
			
		||||
        set line [lindex [split $pos "."] 0]
 | 
			
		||||
        set x [lindex [split $pos "."] 1]
 | 
			
		||||
        # set pos [$txt search -nocase $findString $line.$x end]
 | 
			
		||||
        set pos [$txt search -nocase -regexp $findString $line.$x end]
 | 
			
		||||
        $txt mark set insert $pos
 | 
			
		||||
        $txt see $pos
 | 
			
		||||
        puts $pos
 | 
			
		||||
        # highlight the found word
 | 
			
		||||
        set line [lindex [split $pos "."] 0]
 | 
			
		||||
        # set x [lindex [split $pos "."] 1]
 | 
			
		||||
        # set x [expr {$x + [string length $findString]}]
 | 
			
		||||
        $txt tag remove sel 1.0 end
 | 
			
		||||
        $txt tag add sel $pos $line.end
 | 
			
		||||
        # #$text tag configure sel -background $editor(selectbg) -foreground $editor(fg)
 | 
			
		||||
        $txt tag raise sel
 | 
			
		||||
        focus -force $txt
 | 
			
		||||
        # Position
 | 
			
		||||
        return 1
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    proc Editor {fileFullPath nb itemName} {
 | 
			
		||||
        global cfgVariables
 | 
			
		||||
        set fr $itemName
 | 
			
		||||
@@ -458,7 +488,8 @@ namespace eval Editor {
 | 
			
		||||
        pack $frmText  -side top -expand true -fill both 
 | 
			
		||||
        pack [ttk::scrollbar $frmText.s -command "$frmText.t yview"] -side right -fill y
 | 
			
		||||
        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
 | 
			
		||||
            -tabs "[expr {4 * [font measure $cfgVariables(font) 0]}] left" -tabstyle tabular -undo true 
 | 
			
		||||
            
 | 
			
		||||
        pack $txt -fill both -expand 1
 | 
			
		||||
        # puts ">>>>>>> [bindtags $txt]"
 | 
			
		||||
        if {$cfgVariables(lineNumberShow) eq "false"} {
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										19
									
								
								lib/gui.tcl
									
									
									
									
									
								
							
							
						
						
									
										19
									
								
								lib/gui.tcl
									
									
									
									
									
								
							@@ -68,7 +68,7 @@ if [info exists cfgVariables(theme)] {
 | 
			
		||||
 | 
			
		||||
frame .frmMenu -border 1 -relief raised  -highlightthickness 0
 | 
			
		||||
frame .frmBody -border 1 -relief raised -highlightthickness 0
 | 
			
		||||
frame .frmStatus -border 1 -relief sunken 
 | 
			
		||||
ttk::frame .frmStatus -border 0 -relief sunken 
 | 
			
		||||
pack .frmMenu -side top -padx 1 -fill x
 | 
			
		||||
pack .frmBody -side top -padx 1 -fill both -expand true
 | 
			
		||||
pack .frmStatus -side top -padx 1 -fill x
 | 
			
		||||
@@ -76,7 +76,7 @@ pack .frmStatus -side top -padx 1 -fill x
 | 
			
		||||
# pack .panel -expand true -fill both
 | 
			
		||||
# pack propagate .panel false
 | 
			
		||||
#pack [label .frmMenu.lbl -text "ddd"]
 | 
			
		||||
pack [label .frmStatus.lbl2 -text "ddd"]
 | 
			
		||||
pack [ttk::label .frmStatus.lblPosition -justify right] -side right
 | 
			
		||||
 | 
			
		||||
menubutton .frmMenu.mnuFile -text [::msgcat::mc "File"] -menu .frmMenu.mnuFile.m
 | 
			
		||||
GetFileMenu [menu .frmMenu.mnuFile.m]
 | 
			
		||||
@@ -100,7 +100,7 @@ pack propagate .frmBody.panel false
 | 
			
		||||
pack .frmBody.frmTool -side left -fill y
 | 
			
		||||
pack .frmBody.panel -side left -fill both -expand true
 | 
			
		||||
 | 
			
		||||
ttk::button $frmTool.btn_tree  -command  ViewFilesTree  -image tree_32x32
 | 
			
		||||
ttk::button $frmTool.btn_tree  -command  ViewFilesTree  -image tree_24x24
 | 
			
		||||
 | 
			
		||||
pack $frmTool.btn_tree -side top -padx 1 -pady 1
 | 
			
		||||
# #label $frmTool.lbl_logo -image tcl
 | 
			
		||||
@@ -110,17 +110,20 @@ pack $frmTool.btn_tree -side top -padx 1 -pady 1
 | 
			
		||||
# # Дерево с полосами прокрутки
 | 
			
		||||
set frmTree [ttk::frame .frmBody.frmTree]
 | 
			
		||||
 | 
			
		||||
ttk::scrollbar $frmTree.hsb1 -orient horizontal -command {$frmTree.tree xview}
 | 
			
		||||
ttk::scrollbar $frmTree.vsb1 -orient vertical -command [list $frmTree.tree yview]
 | 
			
		||||
set tree [ttk::treeview $frmTree.tree -show tree \
 | 
			
		||||
-xscrollcommand {$frmTree.hsb1 set} -yscrollcommand [list $frmTree.vsb1 set]]
 | 
			
		||||
    -xscrollcommand [list .frmBody.frmTree.h set] -yscrollcommand [list .frmBody.frmTree.v set]]
 | 
			
		||||
    
 | 
			
		||||
ttk::scrollbar $frmTree.h -orient horizontal -command [list $frmTree.tree xview]
 | 
			
		||||
ttk::scrollbar $frmTree.v -orient vertical -command [list $frmTree.tree yview]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
bind $tree <Double-ButtonPress-1> {Tree::DoublePressItem $tree}
 | 
			
		||||
bind $tree  <ButtonRelease> {Tree::PressItem $tree}
 | 
			
		||||
 | 
			
		||||
grid $tree -row 0 -column 0 -sticky nsew
 | 
			
		||||
grid $frmTree.vsb1 -row 0 -column 1 -sticky nsew
 | 
			
		||||
grid $frmTree.hsb1 -row 1 -column 0 -sticky nsew
 | 
			
		||||
grid $frmTree.v -row 0 -column 1 -sticky nsew
 | 
			
		||||
# grid $frmTree.h -row 1 -column 0 -sticky nsew
 | 
			
		||||
grid columnconfigure $frmTree 0 -weight 1
 | 
			
		||||
grid rowconfigure $frmTree 0 -weight 1
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -25,6 +25,7 @@
 | 
			
		||||
::msgcat::mcset ru "Comments" "Коментарии"
 | 
			
		||||
::msgcat::mcset ru "Comment selected" "Закоментировать"
 | 
			
		||||
::msgcat::mcset ru "Uncomment selected" "Раскоментировать"
 | 
			
		||||
::msgcat::mcset ru "Column" "Столбец"
 | 
			
		||||
::msgcat::mcset ru "Company" "Компания"
 | 
			
		||||
::msgcat::mcset ru "Compiler" "Компилятор"
 | 
			
		||||
::msgcat::mcset ru "Compile" "Компиляция"
 | 
			
		||||
@@ -153,6 +154,7 @@
 | 
			
		||||
::msgcat::mcset ru "Release" "Выпуск"
 | 
			
		||||
::msgcat::mcset ru "RPM directory" "Каталог RPM"
 | 
			
		||||
::msgcat::mcset ru "RPM file mask" "Маска RPM"
 | 
			
		||||
::msgcat::mcset ru "Row" "Строка"
 | 
			
		||||
::msgcat::mcset ru "Run" "Выполнить"
 | 
			
		||||
::msgcat::mcset ru "Run file" "Запустить файл"
 | 
			
		||||
::msgcat::mcset ru "Running project" "Выполнение проекта"
 | 
			
		||||
@@ -185,10 +187,9 @@
 | 
			
		||||
::msgcat::mcset ru "Version" "Версия"
 | 
			
		||||
::msgcat::mcset ru "View" "Вид"
 | 
			
		||||
::msgcat::mcset ru "View files tree" "Показывать дерево файлов"
 | 
			
		||||
::msgcat::mcset ru "View line numers" "Показывать номера строк"
 | 
			
		||||
::msgcat::mcset ru "View line numbers" "Показывать номера строк"
 | 
			
		||||
::msgcat::mcset ru "Warning" "Внимание"
 | 
			
		||||
::msgcat::mcset ru "Was replacement" "Было заменено"
 | 
			
		||||
::msgcat::mcset ru "Word wrapping" "Перенос слов"
 | 
			
		||||
::msgcat::mcset ru "Work dir" "Рабочий каталог"
 | 
			
		||||
::msgcat::mcset ru "Yes" "Да"
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -10,7 +10,6 @@
 | 
			
		||||
######################################################
 | 
			
		||||
 | 
			
		||||
namespace eval NB {
 | 
			
		||||
    
 | 
			
		||||
    proc InsertItem {nb item type} {
 | 
			
		||||
        switch $type {
 | 
			
		||||
            file {
 | 
			
		||||
 
 | 
			
		||||
@@ -98,7 +98,7 @@ proc ImageBase64Encode {} {
 | 
			
		||||
proc FindImage {ext} {
 | 
			
		||||
    foreach img [image names] {
 | 
			
		||||
        if [regexp -nocase -all -- "^($ext)(_)" $img match v1 v2] {
 | 
			
		||||
            puts "\nFindinig images: $img \n"
 | 
			
		||||
            # puts "\nFindinig images: $img \n"
 | 
			
		||||
            return $img
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										33
									
								
								lib/tree.tcl
									
									
									
									
									
								
							
							
						
						
									
										33
									
								
								lib/tree.tcl
									
									
									
									
									
								
							@@ -15,14 +15,14 @@ namespace eval Tree {
 | 
			
		||||
    proc InsertItem {tree parent item type text} {
 | 
			
		||||
        # set img [GetImage $fileName]
 | 
			
		||||
        set dot "_"
 | 
			
		||||
        puts "$tree $parent $item $type $text"
 | 
			
		||||
        # puts "$tree $parent $item $type $text"
 | 
			
		||||
        switch $type  {
 | 
			
		||||
            file {
 | 
			
		||||
                regsub -all {\.|/|\\|\s} $item "_" subNode
 | 
			
		||||
                puts "Inserted tree node: $subNode"
 | 
			
		||||
                # puts "Inserted tree node: $subNode"
 | 
			
		||||
                set fileExt [string trimleft [file extension $text] "."]
 | 
			
		||||
                set findImg [::FindImage $fileExt]
 | 
			
		||||
                puts "Extention $fileExt, find image: $findImg"
 | 
			
		||||
                # puts "Extention $fileExt, find image: $findImg"
 | 
			
		||||
                if {$fileExt ne "" && $findImg ne ""} {
 | 
			
		||||
                    set image $findImg
 | 
			
		||||
                } else {
 | 
			
		||||
@@ -31,12 +31,17 @@ namespace eval Tree {
 | 
			
		||||
            }
 | 
			
		||||
            directory {
 | 
			
		||||
                regsub -all {\.|/|\\|\s} $item "_" subNode
 | 
			
		||||
                puts $subNode
 | 
			
		||||
                set image folder
 | 
			
		||||
                # puts $subNode
 | 
			
		||||
                set image pixel
 | 
			
		||||
            }
 | 
			
		||||
            func {
 | 
			
		||||
                regsub -all {:} $item "_" subNode
 | 
			
		||||
                puts $subNode
 | 
			
		||||
                # puts $subNode
 | 
			
		||||
                set image proc_10x10                
 | 
			
		||||
            }
 | 
			
		||||
            procedure {
 | 
			
		||||
                regsub -all {:} $item "_" subNode
 | 
			
		||||
                # puts $subNode
 | 
			
		||||
                set image proc_10x10                
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
@@ -69,6 +74,7 @@ namespace eval Tree {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    proc PressItem {tree} {
 | 
			
		||||
        global nbEditor
 | 
			
		||||
        set id [$tree selection]
 | 
			
		||||
        $tree tag remove selected
 | 
			
		||||
        $tree item $id -tags selected
 | 
			
		||||
@@ -77,7 +83,7 @@ namespace eval Tree {
 | 
			
		||||
        set key [lindex [split $id "::"] 0]
 | 
			
		||||
        if {$values eq "" || $key eq ""} {return}
 | 
			
		||||
        
 | 
			
		||||
        puts "$key $tree $values"
 | 
			
		||||
        # puts "$key $tree $values"
 | 
			
		||||
        switch $key {
 | 
			
		||||
            directory {
 | 
			
		||||
                FileOper::ReadFolder  $values
 | 
			
		||||
@@ -86,9 +92,18 @@ namespace eval Tree {
 | 
			
		||||
            file {
 | 
			
		||||
                FileOper::Edit $values
 | 
			
		||||
            }
 | 
			
		||||
            func {
 | 
			
		||||
                set parentItem [$tree parent $id]
 | 
			
		||||
                $nbEditor select $nbEditor.[string range $parentItem [expr [string last "::" $parentItem] + 2] end]
 | 
			
		||||
                Editor::FindFunction "func $values"
 | 
			
		||||
            }
 | 
			
		||||
            procedure {
 | 
			
		||||
                set parentItem [$tree parent $id]
 | 
			
		||||
                $nbEditor select $nbEditor.[string range $parentItem [expr [string last "::" $parentItem] + 2] end]
 | 
			
		||||
                Editor::FindFunction "proc $values"
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        # 
 | 
			
		||||
}
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    proc GetItemID {tree item} {
 | 
			
		||||
        if [$tree exists $item] {
 | 
			
		||||
 
 | 
			
		||||
@@ -93,31 +93,31 @@ namespace eval ttk::theme::dark {
 | 
			
		||||
        -fieldbackground $colors(-lightframe)
 | 
			
		||||
        
 | 
			
		||||
        ttk::style configure Text \
 | 
			
		||||
        -linemapbg [list active $colors(-frame)]\
 | 
			
		||||
        -linemapbg [list active $colors(-lightframe)]\
 | 
			
		||||
        -linemapbg [list active $colors(-disabledfg)]\
 | 
			
		||||
        -background [list active $colors(-lighter)] \
 | 
			
		||||
        -foreground [list disabled $colors(-disabledfg)]
 | 
			
		||||
        
 | 
			
		||||
        ttk::style configure TLabel -foreground  $colors(-disabledfg)  -padding {2 0}
 | 
			
		||||
       
 | 
			
		||||
        #         ttk::style configure TreeCtrl \
 | 
			
		||||
        #         -background gray30 -itembackground {gray60 gray50} \
 | 
			
		||||
        #         -itemfill #ffffff -itemaccentfill yellow
 | 
			
		||||
        # ttk::style configure TreeCtrl \
 | 
			
		||||
        # -background gray30 -itembackground {gray60 gray50} \
 | 
			
		||||
        # -itemfill #ffffff -itemaccentfill yellow
 | 
			
		||||
        option add *Toplevel.Background $colors(-dark) interactive
 | 
			
		||||
        option add *Text.Foreground $colors(-foreground) interactive
 | 
			
		||||
        option add *Text.Background $colors(-frame) interactive
 | 
			
		||||
        
 | 
			
		||||
        # option add *Text.Insertbackground yellow interactive
 | 
			
		||||
        option add *Text.Insertbackground yellow interactive
 | 
			
		||||
        # option add *Text.BorderWidth -2 interactive
 | 
			
		||||
        # option add *Text.selectBorderWidth -2 interactive
 | 
			
		||||
        # option add *Text.Relief flat interactive
 | 
			
		||||
        option add *Text.Font "{Noto Sans Mono} 10" interactive
 | 
			
		||||
        # option add *Text.Font "{Noto Sans Mono} 10" interactive
 | 
			
		||||
        #option add *BorderWidth -2 interactive
 | 
			
		||||
    }
 | 
			
		||||
    #option add *Treeview.Background red interactive
 | 
			
		||||
    #     option add *Frame.Background $colors(-frame) interactive
 | 
			
		||||
    #     option add *Label.Background $colors(-frame) interactive
 | 
			
		||||
    #     option add *Label.Foreground $colors(-foreground) interactive
 | 
			
		||||
    #     option add *Entry.Background $colors(-frame) interactive
 | 
			
		||||
    #     option add *Entry.Foreground $colors(-foreground) interactive
 | 
			
		||||
    # option add *Treeview.Background red interactive
 | 
			
		||||
    # option add *Frame.Background $colors(-frame) interactive
 | 
			
		||||
    # option add *Label.Background $colors(-frame) interactive
 | 
			
		||||
    # option add *Label.Foreground $colors(-foreground) interactive
 | 
			
		||||
    # option add *Entry.Background $colors(-frame) interactive
 | 
			
		||||
    # option add *Entry.Foreground $colors(-foreground) interactive
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user