Compare commits
8 Commits
82b94e5b4e
...
beta6
| Author | SHA1 | Date | |
|---|---|---|---|
| 7d0db9f2ea | |||
| 751b334963 | |||
| a437aa5ff3 | |||
| 52ad7be0de | |||
| 7356fe4a3b | |||
| 95894f19f6 | |||
| 6b21f83d03 | |||
| 4a967c6b6c |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -7,4 +7,5 @@ debian/projman.debhelper.log
|
||||
debian/*.tmp
|
||||
debian/errors
|
||||
*.tmp
|
||||
errors
|
||||
errors
|
||||
test.*
|
||||
|
||||
7
debian/changelog
vendored
7
debian/changelog
vendored
@@ -1,5 +1,8 @@
|
||||
projman (2.0.0-beta6) stable; urgency=medium
|
||||
|
||||
* Добавлена логика для работы с troff/groff файлами
|
||||
* Добавил настройку команды для troff файлов (по умолчанию groff)
|
||||
* Добавлена иконка для troff файлов
|
||||
* Добавлены настройки для просмотрщика MD в части касаемой ссылок и выделения текста.
|
||||
* Добавлена обработка тэгов выдеоления текста курсивом или тодщиной. Релизована обработка показа ссылок и вызова брузера при щелчке на ссылке.
|
||||
* Добавлены процедуры отображение подсказок и запуска броузера для ссылок.
|
||||
@@ -544,5 +547,9 @@ projman (2.0.0-alfa0) stable; urgency=medium
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -75,6 +75,7 @@ RB=ruby
|
||||
HTM=firefox
|
||||
HTML=firefox
|
||||
LUA=lua
|
||||
TROFF=groff
|
||||
\[Debug\]
|
||||
debug=false
|
||||
debugOut=stdout
|
||||
@@ -97,6 +98,7 @@ codeBlockFont=Monospace 10 italic
|
||||
textBG=#333333
|
||||
linkFont={Droid Sans Mono} 10 bold
|
||||
linkFG=#54bcff
|
||||
runViewer=true
|
||||
"
|
||||
proc Config::create {dir} {
|
||||
set cfgFile [open [file join $dir projman.ini] "w+"]
|
||||
|
||||
@@ -1462,7 +1462,25 @@ namespace eval Editor {
|
||||
|
||||
}
|
||||
set fileType [string toupper [string trimleft [file extension $fileFullPath] "."]]
|
||||
if {$fileType eq ""} {set fileType "Unknown"}
|
||||
# Set file type if file extention is digits
|
||||
switch -regexp -- $fileType {
|
||||
[[:digit:]]+ {
|
||||
if {[FileOper::GetFileMimeType $fileFullPath] eq "troff"} {
|
||||
set fileType TROFF
|
||||
} else {
|
||||
set fileType "Unknow"
|
||||
}
|
||||
}
|
||||
^$ {
|
||||
if {[FileOper::GetFileMimeType $fileFullPath] eq "troff"} {
|
||||
set fileType TROFF
|
||||
} else {
|
||||
set fileType "Unknow"
|
||||
}
|
||||
}
|
||||
}
|
||||
DebugPuts "Editor::Editor: file type is \"$fileType\""
|
||||
# if {$fileType eq ""} {set fileType "Unknown"}
|
||||
|
||||
ExecutorCommandPathSetting $fileType
|
||||
|
||||
@@ -1510,7 +1528,16 @@ namespace eval Editor {
|
||||
puts $fileFullPath
|
||||
}
|
||||
# puts [$w.panelTxt panes]
|
||||
DebugPuts "$w $fileType $nb $fileFullPath"
|
||||
DebugPuts "Editor::SplitEditorForExecute: $w $fileType $nb $fileFullPath"
|
||||
|
||||
# set fileType [string toupper [string trimleft [file extension $filePath] "."]]
|
||||
|
||||
# Execute the MD-file viewer
|
||||
if {$fileType eq "MD" && $cfgVariables(runViewer) eq "true"} {
|
||||
ShowMD $fileFullPath
|
||||
return
|
||||
}
|
||||
|
||||
if [winfo exists $w.frmText2] {
|
||||
$w.panelTxt forget $w.frmText2
|
||||
destroy $w.frmText2
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
# Working with files module
|
||||
######################################################
|
||||
|
||||
|
||||
namespace eval FileOper {
|
||||
global packages
|
||||
variable types
|
||||
@@ -47,6 +46,9 @@ namespace eval FileOper {
|
||||
|
||||
proc GetFileMimeType {fileFullPath {opt ""}} {
|
||||
global cfgVariables
|
||||
if [regexp -nocase -- {untitled} $fileFullPath mattch] {
|
||||
return text
|
||||
}
|
||||
# Проверям наличие программы в системе, если есть то добавляем опции
|
||||
# если нет то используем тиклевый пакет
|
||||
if [file exists $cfgVariables(fileTypeCommand)] {
|
||||
@@ -67,6 +69,7 @@ namespace eval FileOper {
|
||||
if [regexp -nocase -- {(\w+)/([\w\-_\.]+); charset=([[:alnum:]-]+)} $pipe m fType fExt fCharset] {
|
||||
DebugPuts "$fType $fExt $fCharset"
|
||||
}
|
||||
|
||||
switch $opt {
|
||||
"charset" {
|
||||
if [info exists fCharset] {
|
||||
@@ -76,7 +79,13 @@ namespace eval FileOper {
|
||||
}
|
||||
# линуксовый file не всегда корректно определяет тип файла
|
||||
# используем пакет из tcl
|
||||
lassign [::fileutil::fileType $fileFullPath] fType fBinaryType fBinaryInterp
|
||||
if { $fType eq "text" && $fExt eq "troff"} {
|
||||
set fType $fExt
|
||||
set fBinaryType "text"
|
||||
set fBinaryInterp "groff"
|
||||
} else {
|
||||
lassign [::fileutil::fileType $fileFullPath] fType fBinaryType fBinaryInterp
|
||||
}
|
||||
DebugPuts "File type is $fType, $fBinaryType, $fBinaryInterp"
|
||||
set ext [string tolower [file extension $fileFullPath]]
|
||||
|
||||
@@ -140,6 +149,9 @@ namespace eval FileOper {
|
||||
}
|
||||
}
|
||||
}
|
||||
"troff" {
|
||||
return troff
|
||||
}
|
||||
"empty" {
|
||||
return text
|
||||
}
|
||||
@@ -395,6 +407,14 @@ namespace eval FileOper {
|
||||
# puts "$f was saved"
|
||||
close $f
|
||||
ResetModifiedFlag $nbEditorItem $nbEditorWindow
|
||||
|
||||
# Проверяем если в редакторе открыт MD-файл и запущен его просмотрщик
|
||||
if {[string toupper [string trimleft [file extension $filePath] "."]] eq "MD" && [winfo exists .viewer]} {
|
||||
if {[wm title .viewer] eq $filePath} {
|
||||
ShowMD $filePath true
|
||||
}
|
||||
}
|
||||
|
||||
if {[file tail $filePath] eq "projman.ini"} {
|
||||
Config::read $dir(cfg)
|
||||
}
|
||||
@@ -528,7 +548,7 @@ namespace eval FileOper {
|
||||
set fileType [FileOper::GetFileMimeType $fileFullPath]
|
||||
}
|
||||
|
||||
# puts "$fileType <<<<<<<<<<<"
|
||||
DebugPuts "FileOper::Edit: file type is \"$fileType\""
|
||||
|
||||
switch $fileType {
|
||||
"text" {
|
||||
|
||||
@@ -1968,3 +1968,14 @@ image create photo cpp_16x12 -data {
|
||||
AAALEwEAmpwYAAAAB3RJTUUH6gIGDxU21/OqSAAAADVJREFUCNd9jUEOACAIw7D7/58VmNF4sAco
|
||||
CbCIm5FsBTwsd+kmgVQu87p3OLfg/9AJJPFhAjDkAJmwKBolAAAAAElFTkSuQmCC
|
||||
}
|
||||
image create photo troff_16x12 -data {
|
||||
iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAAAXNSR0IB2cksfwAAAARnQU1BAACx
|
||||
jwv8YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAAZiS0dE
|
||||
AAAAAAAA+UO7fwAAAAlwSFlzAAAAWAAAAFgBeNpLYgAAAAd0SU1FB+oEDw0yFseUVqEAAAEXSURB
|
||||
VCjPfZE/S4JxEMc/p4/EU489Bg5BSDgECdZQU7QF0hYUuLm1+yJqj15AS2+gRWhraWvIQcEKwnIw
|
||||
bIt80OcPT9fSY49pfuE47nf34X53J0xRuaxJd/G1ilCpXeS34znjx2v0sLx6SHdwRcZcB0lEOfkL
|
||||
oKqEoXJz+0Hz0eO+5VHaMbm+HO+eiAf1hsNbzyefS+EMlWLBnPjuCBgMQ3rvPhnboPHgMpeCwtoM
|
||||
4Lnt0ndC0gtJ6k8BRyULyzL+B0QUz4eT8zssU9jfs6ct8Hfol47P1uY8nW4RP1AytjEbyK2ksG2D
|
||||
LxWqx1kSIsySfvYDPT3rarPlaFzxG40BgO4e1BTSUVHcJoYWQJayGxXoSxTHbKRvV5VqA9sEagYA
|
||||
AAAASUVORK5CYII=
|
||||
}
|
||||
|
||||
118
lib/mdviewer.tcl
118
lib/mdviewer.tcl
@@ -9,61 +9,66 @@
|
||||
#
|
||||
######################################################
|
||||
|
||||
proc ShowMD {fileFullPath} {
|
||||
proc ShowMD {fileFullPath {reload "false"}} {
|
||||
global cfgVariables
|
||||
|
||||
set win .viewer
|
||||
|
||||
set parentGeometry [wm geometry .]
|
||||
set parentWidth [winfo width .]
|
||||
set parentHeight [winfo height .]
|
||||
set parentX [winfo x .]
|
||||
set parentY [winfo y .]
|
||||
if {$reload eq "false"} {
|
||||
set parentGeometry [wm geometry .]
|
||||
set parentWidth [winfo width .]
|
||||
set parentHeight [winfo height .]
|
||||
set parentX [winfo x .]
|
||||
set parentY [winfo y .]
|
||||
|
||||
# Устанавливаем размеры нового окна (меньше на 200)
|
||||
set newWidth [expr {$parentWidth - 200}]
|
||||
set newHeight [expr {$parentHeight - 200}]
|
||||
|
||||
# Вычисляем позицию для центрирования относительно родительского окна
|
||||
set x [expr {$parentX + ($parentWidth - $newWidth) / 2}]
|
||||
set y [expr {$parentY + ($parentHeight - $newHeight) / 2}]
|
||||
|
||||
# Применяем геометрию
|
||||
|
||||
# Устанавливаем размеры нового окна (меньше на 200)
|
||||
set newWidth [expr {$parentWidth - 200}]
|
||||
set newHeight [expr {$parentHeight - 200}]
|
||||
if { [winfo exists $win] } { destroy $win; return false }
|
||||
toplevel $win
|
||||
# wm title $win "[::msgcat::mc "Help"]"
|
||||
wm title $win $fileFullPath
|
||||
wm geometry $win ${newWidth}x${newHeight}+${x}+${y}
|
||||
wm overrideredirect $win 0
|
||||
|
||||
set frm [ttk::frame $win.frmHelp]
|
||||
pack $frm -expand 1 -fill both
|
||||
|
||||
set txt [text $frm.txt -wrap $cfgVariables(editorWrap) -background $cfgVariables(textBG) \
|
||||
-xscrollcommand "$win.h set" -yscrollcommand "$frm.v set" -font $cfgVariables(viewerFont)]
|
||||
pack $txt -side left -expand 1 -fill both
|
||||
pack [ttk::scrollbar $frm.v -command "$frm.txt yview"] -side right -fill y
|
||||
ttk::scrollbar $win.h -orient horizontal -command "$frm.txt xview"
|
||||
if {$cfgVariables(editorWrap) eq "none"} {
|
||||
pack $win.h -side bottom -fill x
|
||||
|
||||
# Вычисляем позицию для центрирования относительно родительского окна
|
||||
set x [expr {$parentX + ($parentWidth - $newWidth) / 2}]
|
||||
set y [expr {$parentY + ($parentHeight - $newHeight) / 2}]
|
||||
|
||||
# Применяем геометрию
|
||||
|
||||
if { [winfo exists $win] } { destroy $win; return false }
|
||||
toplevel $win
|
||||
wm title $win "[::msgcat::mc "Help"]"
|
||||
wm geometry $win ${newWidth}x${newHeight}+${x}+${y}
|
||||
wm overrideredirect $win 0
|
||||
|
||||
set frm [ttk::frame $win.frmHelp]
|
||||
pack $frm -expand 1 -fill both
|
||||
|
||||
set txt [text $frm.txt -wrap $cfgVariables(editorWrap) -background $cfgVariables(textBG) \
|
||||
-xscrollcommand "$win.h set" -yscrollcommand "$frm.v set" -font $cfgVariables(viewerFont)]
|
||||
pack $txt -side left -expand 1 -fill both
|
||||
pack [ttk::scrollbar $frm.v -command "$frm.txt yview"] -side right -fill y
|
||||
ttk::scrollbar $win.h -orient horizontal -command "$frm.txt xview"
|
||||
if {$cfgVariables(editorWrap) eq "none"} {
|
||||
pack $win.h -side bottom -fill x
|
||||
|
||||
}
|
||||
bind .viewer <Escape> {destroy .viewer}
|
||||
|
||||
$txt tag configure h1 -font $cfgVariables(h1Font)
|
||||
$txt tag configure h2 -font $cfgVariables(h2Font)
|
||||
$txt tag configure h3 -font $cfgVariables(h3Font)
|
||||
$txt tag configure h4 -font $cfgVariables(h4Font)
|
||||
$txt tag configure h5 -font $cfgVariables(h5Font)
|
||||
$txt tag configure h6 -font $cfgVariables(h6Font)
|
||||
$txt tag configure mdList -font $cfgVariables(mdListFont)
|
||||
$txt tag configure codeBlock -foreground $cfgVariables(codeBlockFG) \
|
||||
-background $cfgVariables(codeBlockBG) -font $cfgVariables(codeBlockFont)
|
||||
$txt tag configure italic -font $cfgVariables(italicFont)
|
||||
$txt tag configure bold -font $cfgVariables(boldFont)
|
||||
$txt tag configure italicBold -font $cfgVariables(italicBoldFont)
|
||||
$txt tag configure link -foreground $cfgVariables(linkFG) -font $cfgVariables(linkFont)
|
||||
$txt tag configure quote -background $cfgVariables(codeBlockBG)
|
||||
} else {
|
||||
set txt .viewer.frmHelp.txt
|
||||
$txt delete 0.0 end
|
||||
}
|
||||
bind .viewer <Escape> {destroy .viewer}
|
||||
|
||||
$txt tag configure h1 -font $cfgVariables(h1Font)
|
||||
$txt tag configure h2 -font $cfgVariables(h2Font)
|
||||
$txt tag configure h3 -font $cfgVariables(h3Font)
|
||||
$txt tag configure h4 -font $cfgVariables(h4Font)
|
||||
$txt tag configure h5 -font $cfgVariables(h5Font)
|
||||
$txt tag configure h6 -font $cfgVariables(h6Font)
|
||||
$txt tag configure mdList -font $cfgVariables(mdListFont)
|
||||
$txt tag configure codeBlock -foreground $cfgVariables(codeBlockFG) \
|
||||
-background $cfgVariables(codeBlockBG) -font $cfgVariables(codeBlockFont)
|
||||
$txt tag configure italic -font $cfgVariables(italicFont)
|
||||
$txt tag configure bold -font $cfgVariables(boldFont)
|
||||
$txt tag configure italicBold -font $cfgVariables(italicBoldFont)
|
||||
$txt tag configure link -foreground $cfgVariables(linkFG) -font $cfgVariables(linkFont)
|
||||
|
||||
set codeBlockBegin false
|
||||
|
||||
set f [open "$fileFullPath" r]
|
||||
@@ -102,6 +107,13 @@ proc ShowMD {fileFullPath} {
|
||||
ProcessLineWithURL $line $txt $result
|
||||
} elseif {$textTag eq "markable"} {
|
||||
ProcessLineWithMark $line $txt $result
|
||||
} elseif {$textTag eq "quote"} {
|
||||
set symList [split [lindex $result 2] ">"]
|
||||
for {set i 1} { $i < [llength $symList]} {incr i} {
|
||||
$txt insert end " " quote
|
||||
$txt insert end " "
|
||||
}
|
||||
$txt insert end [lindex $result 1]\n
|
||||
} else {
|
||||
$txt insert end "[lindex $result 1]\n" $textTag
|
||||
}
|
||||
@@ -299,6 +311,11 @@ proc MarkDownParser {line} {
|
||||
set result [ExtractURL $line {\[([^\]]+)\]\(([^)]+)\)}]
|
||||
return [list link $result]
|
||||
}
|
||||
# Quoted text
|
||||
if [regexp -nocase -line -- {(^>(?:>|\s)*)(.*)$} $line match v1 v2] {
|
||||
puts "Quoted text $match"
|
||||
return [list quote $v2 $v1]
|
||||
}
|
||||
|
||||
return [list {} $line]
|
||||
|
||||
@@ -381,6 +398,3 @@ proc ExtractBlocks {line pattern} {
|
||||
}
|
||||
return $result
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -925,6 +925,22 @@ proc Execute {filePath w activeEditor} {
|
||||
|
||||
# Added executor from config
|
||||
set fileType [string toupper [string trimleft [file extension $filePath] "."]]
|
||||
switch -regexp -- $fileType {
|
||||
[[:digit:]]+ {
|
||||
if {[FileOper::GetFileMimeType $filePath] eq "troff"} {
|
||||
set fileType TROFF
|
||||
} else {
|
||||
set fileType "Unknow"
|
||||
}
|
||||
}
|
||||
^$ {
|
||||
if {[FileOper::GetFileMimeType $filePath] eq "troff"} {
|
||||
set fileType TROFF
|
||||
} else {
|
||||
set fileType "Unknow"
|
||||
}
|
||||
}
|
||||
}
|
||||
if {[info exists cfgVariables($fileType)] != 0 && $cfgVariables($fileType) ne ""} {
|
||||
$w.frame.text insert end "$cfgVariables($fileType) %f"
|
||||
}
|
||||
@@ -1131,7 +1147,7 @@ proc ExecutorCommandPathSetting {fileType} {
|
||||
}
|
||||
if {[info exists cfgVariables($fileType)] == 0} {
|
||||
set cfgVariables($fileType) ""
|
||||
DebugPuts $cfgVariables($fileType)
|
||||
DebugPuts "ExecutorCommandPathSetting: cfgVariables($fileType) = $cfgVariables($fileType)"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ exec wish8.6 "$0" -- "$@"
|
||||
######################################################
|
||||
# Version: 2.0.0
|
||||
# Release: beta6
|
||||
# Build: 08042026164832
|
||||
# Build: 21042026112230
|
||||
######################################################
|
||||
|
||||
# определим текущую версию, релиз и т.д.
|
||||
|
||||
Reference in New Issue
Block a user