Added insert base64 encoded image into source code

This commit is contained in:
Sergey Kalinin 2018-03-12 16:59:32 +03:00
parent a985948feb
commit ace5dc22f4
9 changed files with 50 additions and 11 deletions

View File

@ -6,6 +6,9 @@
##########################################################
0.4.5
12.03.2018
- Added insert base64 encoded image into source code (press "Control+I" or popup menu)
06.03.2018
- Added procedure arguments into tree
- Change read config procedure (error fixed)
@ -427,3 +430,5 @@ characters to the right of the insertion cursor.

View File

@ -694,6 +694,7 @@ proc EditFile {tree node fileName} {
bind $text <Control-icircumflex> "auto_completition_proc $text"
bind $text <Control-j> "auto_completition_proc $text"
#bind $text <Control-Tab> "auto_completition_proc $text"
bind $text <Control-i> "ImageBase64Encode $text"
bind $text <Control-q> Find
bind $text <Control-comma> {TextOperation comment}
@ -933,7 +934,7 @@ proc ReadFileStructure {mod line lineNumber tree node} {
global backUpFileCreate fileExt progress editor braceHighLightBG braceHighLightFG activeProject
global varList
set dot "_"
# Insert procedure names into tree #
regsub -all {\t} $line " " line
set w $noteBook.f$node
@ -1001,3 +1002,5 @@ proc EditorFileNavigateMenu {w fullPathFile} {
GetOp

View File

@ -622,5 +622,3 @@ proc FileOperation::FileDialog {tree operation} {
return 0
}
}

View File

@ -1,6 +1,3 @@
package require Img
proc ImageViewer {f w node} {
global tab_label noteBook factor im1 im2 editor
set factor($node) 1.0
@ -22,7 +19,7 @@ proc ImageViewer {f w node} {
#$w.scrwin setwidget $w.scrwin.f
openImg $f $w.f.c $node
set tab_label [$noteBook itemcget $node -text]
balloon $w.f.c set "Mouse wheel up/down - vertiÓal scrolling the image\n\
balloon $w.f.c set "Mouse wheel up/down - vertiÓal scrolling the image\n\
Shift + mouse wheel up/down - horizontal image scrolling\n\
Control + mouse wheel up/down is a scale image -/+"
}
@ -53,8 +50,23 @@ proc scale {w {n 1} node} {
$w config -scrollregion [$w bbox all]
}
proc ImageBase64Encode {text} {
global env
set types {
{"GIF" {.gif}}
{"JPEG" {.jpg}}
{"PNG" {.png}}
{"BMP" {.bmp}}
{"All files" *}
}
set img [tk_getOpenFile -initialdir $env(HOME) -filetypes $types -parent .]
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]]
$text insert [Position] "image create photo $name -data {\n$data\n}"
}

View File

@ -367,3 +367,4 @@ if {[info exists workingProject]} {
}
}

View File

@ -90,8 +90,18 @@ proc GetMenu {m} {
$me add command -label [::msgcat::mc "KOI8-R"] -command {TextEncode koi8-r} -font $fontNormal
$me add command -label [::msgcat::mc "CP1251"] -command {TextEncode cp1251} -font $fontNormal
$me add command -label [::msgcat::mc "CP866"] -command {TextEncode cp866} -font $fontNormal
$m add separator
$m add command -label [::msgcat::mc "Insert image"] -font $fontNormal -accelerator "Ctrl+I" \
-command {
set nb [$noteBook raise]
if {$nb == "" || $nb == "newproj" || $nb == "about" || $nb == "debug"} {
return
}
set nb "$noteBook.f$nb"
ImageBase64Encode $nb.text
unset nb
}
}
proc GetViewMenu {m} {
global fontNormal fontBold imgDir editor
$m add checkbutton -label [::msgcat::mc "Show the Menu"] -font $fontNormal -state normal\
@ -168,3 +178,5 @@ proc GetFileMenu {m} {
}

View File

@ -81,6 +81,7 @@
::msgcat::mcset en "Indent foreground"
::msgcat::mcset en "Indent background"
::msgcat::mcset en "Interface language"
::msgcat::mcset en "Insert image"
::msgcat::mcset en "Install Tcl/Tk Project Manager"
::msgcat::mcset en "Input file name"
::msgcat::mcset en "Key bindings"
@ -184,3 +185,4 @@

View File

@ -85,6 +85,7 @@
::msgcat::mcset ru "Indent foreground" "Подсветка отступа"
::msgcat::mcset ru "Indent background" "Подсветка отступа"
::msgcat::mcset ru "Insert" "Вставка"
::msgcat::mcset ru "Insert image" "Вставить изображение"
::msgcat::mcset ru "Interface language" "Язык интерфейса"
::msgcat::mcset ru "Interpetator" "Интерпретатор"
::msgcat::mcset ru "Install Tcl/Tk Project Manager" "Установка Tcl/Tk Project Manager"
@ -182,3 +183,4 @@
::msgcat::mcset ru "Was replacement" "Было заменено"
::msgcat::mcset ru "Word wrapping" "Перенос слов"
::msgcat::mcset ru "Work dir" "Рабочий каталог"

View File

@ -15,6 +15,8 @@ set ver "0.4.5"
package require BWidget
package require msgcat
package require base64
package require Img
set wishOpList [info commands]
## DO NOT EDIT THIS LINE! USE install.tcl SCRIPT ##
@ -172,3 +174,5 @@ option add *Dialog.msg.background $editor(bg)
# option add *Text.HighlightThickness 2 userDefault
# option add *Entry.HighlightThickness 1 userDefault