From 70a731d40230725f294c841d6b3537d48a96bd5f Mon Sep 17 00:00:00 2001 From: svkalinin Date: Wed, 3 Aug 2022 12:21:28 +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=20=D0=BF=D0=BE=D0=B8=D1=81=D0=BA=20=D0=BF=D1=80?= =?UTF-8?q?=D0=BE=D1=86=D0=B5=D0=B4=D1=83=D1=80=D1=8B=20=D0=B2=20=D1=82?= =?UTF-8?q?=D0=B5=D0=BA=D1=81=D1=82=D0=B5=20=D0=BF=D0=BE=20=D0=BA=D0=BB?= =?UTF-8?q?=D0=B8=D0=BA=D1=83=20=D0=B2=20=D0=B4=D0=B5=D1=80=D0=B5=D0=B2?= =?UTF-8?q?=D0=B5.=20=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=BE=20=D0=BE=D1=82=D0=BE=D0=B1=D1=80=D0=B0=D0=B6=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D0=BF=D0=BE=D0=B7=D0=B8=D1=86=D0=B8=D0=B8?= =?UTF-8?q?=20=D0=BA=D1=83=D1=80=D1=81=D0=BE=D1=80=D0=B0=20=D0=B2=20=D1=81?= =?UTF-8?q?=D1=82=D1=80=D0=BE=D0=BA=D0=B5=20=D1=81=D1=82=D0=B0=D1=82=D1=83?= =?UTF-8?q?=D1=81=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG | 6 +++++ lib/editor.tcl | 49 ++++++++++++++++++++++++++++++++-------- lib/gui.tcl | 19 +++++++++------- lib/msgs/ru.msg | 5 ++-- lib/notebook.tcl | 1 - lib/procedure.tcl | 2 +- lib/tree.tcl | 33 +++++++++++++++++++-------- theme/ttk_theme_dark.tcl | 24 ++++++++++---------- 8 files changed, 97 insertions(+), 42 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index f2b412a..377eac8 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -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 + diff --git a/lib/editor.tcl b/lib/editor.tcl index 9a79332..329ce25 100644 --- a/lib/editor.tcl +++ b/lib/editor.tcl @@ -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"} { diff --git a/lib/gui.tcl b/lib/gui.tcl index 41a134f..d72e064 100644 --- a/lib/gui.tcl +++ b/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 {Tree::DoublePressItem $tree} bind $tree {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 diff --git a/lib/msgs/ru.msg b/lib/msgs/ru.msg index 63effe2..fe8bebf 100644 --- a/lib/msgs/ru.msg +++ b/lib/msgs/ru.msg @@ -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" "Да" - diff --git a/lib/notebook.tcl b/lib/notebook.tcl index 14f2fa0..32175c6 100644 --- a/lib/notebook.tcl +++ b/lib/notebook.tcl @@ -10,7 +10,6 @@ ###################################################### namespace eval NB { - proc InsertItem {nb item type} { switch $type { file { diff --git a/lib/procedure.tcl b/lib/procedure.tcl index 1646c7f..60d86ba 100644 --- a/lib/procedure.tcl +++ b/lib/procedure.tcl @@ -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 } } diff --git a/lib/tree.tcl b/lib/tree.tcl index b00282e..510f8fc 100644 --- a/lib/tree.tcl +++ b/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] { diff --git a/theme/ttk_theme_dark.tcl b/theme/ttk_theme_dark.tcl index 546e767..f0fcdeb 100644 --- a/theme/ttk_theme_dark.tcl +++ b/theme/ttk_theme_dark.tcl @@ -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 }