diff --git a/CHANGELOG b/CHANGELOG index 5e4c4f7..f2b412a 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -42,3 +42,10 @@ 27/07/2022 - Fixed comment/uncomment procedure (last line in selected text) - Fixed error with save new (untitled) file + +01/08/2022 + - Added inserting base64 encoded image + - Added read the file structure and inserting into tree + - Added GUI font, and GUI foreground color setting + - Added tcl and go files images + - Added image for file type (extention) diff --git a/lib/editor.tcl b/lib/editor.tcl index 7fd2808..9a79332 100644 --- a/lib/editor.tcl +++ b/lib/editor.tcl @@ -351,6 +351,7 @@ namespace eval Editor { #bind $txt "%W xview scroll 2 units" bind $txt <> "SetModifiedFlag $w" bind $txt <> "Editor::SelectionGet $txt" + bind $txt ImageBase64Encode } proc QuotSelection {txt symbol} { @@ -403,6 +404,39 @@ namespace eval Editor { Editor $fileFullPath $nbEditor $nbEditorItem SetModifiedFlag $nbEditorItem } + + proc ReadStructure {txt treeItemName} { + global tree nbEditor + for {set lineNumber 0} {$lineNumber <= [$txt count -lines 0.0 end]} {incr lineNumber} { + set line [$txt get $lineNumber.0 $lineNumber.end] + # TCL procedure + 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" + # tree parent item type text + puts [Tree::InsertItem $tree $treeItemName $procName "func" "$procName ($params)"] + } + # GO function + if {[regexp -nocase -all -- {^\s*?func\s*?\((\w+\s*?\*\w+)\)\s*?(\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" + } + puts "$treeItemName proc $funcName $params" + # tree parent item type text + puts [Tree::InsertItem $tree $treeItemName $funcName "func" "$funcName ($params)"] + } + if {[regexp -nocase -all -- {^\s*?func\s*?(\w+)\((.*?)\) (\(\w+\)|\w+|)\s*?\{} $line match funcName params returns]} { + puts "$treeItemName proc $funcName $params" + # tree parent item type text + puts [Tree::InsertItem $tree $treeItemName $funcName "func" "$funcName ($params)"] + } + + } + } proc Editor {fileFullPath nb itemName} { global cfgVariables @@ -411,6 +445,7 @@ namespace eval Editor { set lblText $fileFullPath } else { set lblText "" + } set lblName "lbl[string range $itemName [expr [string last "." $itemName] +1] end]" diff --git a/lib/files.tcl b/lib/files.tcl index b6a7559..b95894f 100644 --- a/lib/files.tcl +++ b/lib/files.tcl @@ -189,7 +189,7 @@ namespace eval FileOper { set fileName [file tail $fileFullPath] regsub -all {\.|/|\\|\s} $fileFullPath "_" itemName set itemName "$nbEditor.$itemName" - puts [Tree::InsertItem $tree {} $fileFullPath "file" $fileName] + set treeItemName [Tree::InsertItem $tree {} $fileFullPath "file" $fileName] if {[winfo exists $itemName] == 0} { NB::InsertItem $nbEditor $fileFullPath "file" Editor::Editor $fileFullPath $nbEditor $itemName @@ -198,6 +198,7 @@ namespace eval FileOper { ResetModifiedFlag $itemName } $nbEditor select $itemName + Editor::ReadStructure $itemName.frmText.t $treeItemName focus -force $itemName.frmText.t return $itemName diff --git a/lib/gui.tcl b/lib/gui.tcl index ff61e87..41a134f 100644 --- a/lib/gui.tcl +++ b/lib/gui.tcl @@ -160,4 +160,8 @@ if {$cfgVariables(toolBarShow) eq "true"} { .frmBody.panel add $frmTree -weight 0 } .frmBody.panel add $frm_work -weight 1 -# # + +ttk::style configure . \ + -foreground $::cfgVariables(guiFG) \ + -font $::cfgVariables(guiFont) + diff --git a/lib/menu.tcl b/lib/menu.tcl index 527376c..b71910c 100644 --- a/lib/menu.tcl +++ b/lib/menu.tcl @@ -54,6 +54,9 @@ proc GetEditMenu {m} { -accelerator "Ctrl+Shift+F" $m add command -label [::msgcat::mc "Replace in files"] -command File::Replace\ -accelerator "Ctrl+Shift+RV" + $m add separator + $m add command -label [::msgcat::mc "Insert image"] -accelerator "Ctrl+I"\ + -command ImageBase64Encode } @@ -61,4 +64,3 @@ proc GetViewMenu {m} { $m add command -label [::msgcat::mc "View files tree"] -command ViewFilesTree $m add command -label [::msgcat::mc "View line numbers"] -command ViewLineNumbers } - diff --git a/lib/procedure.tcl b/lib/procedure.tcl index 63bf78c..1646c7f 100644 --- a/lib/procedure.tcl +++ b/lib/procedure.tcl @@ -73,3 +73,34 @@ proc SetModifiedFlag {w} { } $nbEditor tab $w -text $lbl } + +proc ImageBase64Encode {} { + global env nbEditor + set types { + {"PNG" {.png}} + {"GIF" {.gif}} + {"JPEG" {.jpg}} + {"BMP" {.bmp}} + {"All files" *} + } + set txt "[$nbEditor select].frmText.t" + set img [tk_getOpenFile -initialdir $env(HOME) -filetypes $types -parent .] + if {$img ne ""} { + set f [open $img] + fconfigure $f -translation binary + set data [base64::encode [read $f]] + close $f + # base name on root name of the image file + set name [file root [file tail $img]] + $txt insert insert "image create photo $name -data {\n$data\n}" + } +} +proc FindImage {ext} { + foreach img [image names] { + if [regexp -nocase -all -- "^($ext)(_)" $img match v1 v2] { + puts "\nFindinig images: $img \n" + return $img + } + } +} + diff --git a/lib/tree.tcl b/lib/tree.tcl index 6dcaf51..b00282e 100644 --- a/lib/tree.tcl +++ b/lib/tree.tcl @@ -19,21 +19,33 @@ namespace eval Tree { switch $type { file { regsub -all {\.|/|\\|\s} $item "_" subNode - puts $subNode - set image imgFile + puts "Inserted tree node: $subNode" + set fileExt [string trimleft [file extension $text] "."] + set findImg [::FindImage $fileExt] + puts "Extention $fileExt, find image: $findImg" + if {$fileExt ne "" && $findImg ne ""} { + set image $findImg + } else { + set image imgFile + } } directory { regsub -all {\.|/|\\|\s} $item "_" subNode puts $subNode set image folder } + func { + regsub -all {:} $item "_" subNode + puts $subNode + set image proc_10x10 + } } append id $type "::" $subNode - puts $id + puts "Tree ID: $id, tree item: $item" if ![$tree exists $id] { - $tree insert $parent end -id "$id" -text $text -values "$item" -image $image + $tree insert $parent end -id "$id" -text " $text" -values "$item" -image $image } - return "$id" + return "$id" } proc DoublePressItem {tree} { set id [$tree selection] diff --git a/projman.tcl b/projman.tcl index 303561e..ce58884 100755 --- a/projman.tcl +++ b/projman.tcl @@ -35,9 +35,11 @@ if { $::argc > 0 } { } puts $opened } + package require msgcat package require inifile package require ctext +package require base64 # Устанавливаем текущий каталог set dir(root) [pwd] diff --git a/theme/ttk_theme_dark.tcl b/theme/ttk_theme_dark.tcl index 4342a93..546e767 100644 --- a/theme/ttk_theme_dark.tcl +++ b/theme/ttk_theme_dark.tcl @@ -11,7 +11,7 @@ package require Tk namespace eval ttk::theme::dark { variable version 0.0.1 variable dir [file dirname [info script]] - + global cfgVariables package provide ttk::theme::dark $version # NB: These colors must be in sync with the ones in black.rdb @@ -46,7 +46,7 @@ namespace eval ttk::theme::dark { -selectbackground $colors(-selectbg) \ -selectforeground $colors(-selectfg) \ -selectborderwidth 0 \ - -font "{Droid Sans Mono} 10" + -font "{Droid Sans Mono} 9" ttk::style map "." \ -background [list disabled $colors(-frame) \ @@ -121,46 +121,3 @@ namespace eval ttk::theme::dark { # option add *Entry.Background $colors(-frame) interactive # option add *Entry.Foreground $colors(-foreground) interactive } - -# A few tricks for Tablelist. - -namespace eval ::tablelist:: { - proc blackTheme {} { - variable themeDefaults - - array set colors [array get ttk::theme::dark::colors] - - array set themeDefaults [list \ - -background "#000000" \ - -foreground "#ffffff" \ - -disabledforeground $colors(-disabledfg) \ - -stripebackground "#191919" \ - -selectbackground "#4a6984" \ - -selectforeground "#8b8b00" \ - -selectborderwidth 0 \ - -font TkTextFont \ - -labelbackground $colors(-frame) \ - -labeldisabledBg "#dcdad5" \ - -labelactiveBg "#eeebe7" \ - -labelpressedBg "#eeebe7" \ - -labelforeground #ffffff \ - -labeldisabledFg "#999999" \ - -labelactiveFg #ffffff \ - -labelpressedFg #ffffff \ - -labelfont TkDefaultFont \ - -labelborderwidth 2 \ - -labelpady 1 \ - -arrowcolor "" \ - -arrowstyle sunken10x9 ] - } -} - - - - - - - - - -