Add syntax highlighting
This commit is contained in:
parent
aabe0b3667
commit
8ca9f92b56
6
NEWS.md
6
NEWS.md
|
@ -1,6 +1,10 @@
|
|||
# Genoa Banner Creator project news
|
||||
|
||||
## [0.5 alpha] - unreleased
|
||||
## [0.5 alpha] - 2023-09-15
|
||||
|
||||
### Added
|
||||
|
||||
* Syntax highlighting and line numbers
|
||||
|
||||
### Changed
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ As of September 2023, Genoa is at a very early alpha stage: incomplete, poorly d
|
|||
|
||||
## Usage
|
||||
|
||||
Genoa is powered by a little language based on Tcl. For example its own promotional banner is defined like this:
|
||||
Genoa is powered by a little language based on Tcl. For example its own promotional cover is defined like this:
|
||||
|
||||
```tcl
|
||||
# The viewport declaration can be anywhere.
|
||||
|
|
18
genoa.tcl
18
genoa.tcl
|
@ -24,12 +24,13 @@
|
|||
package require Tcl 8.6
|
||||
package require Tk 8.6
|
||||
|
||||
package require ctext
|
||||
package require getstring
|
||||
namespace import getstring::*
|
||||
|
||||
set window_title "Genoa Banner Creator"
|
||||
|
||||
set about_text "Tool to Generate Original Art\nv0.4 alpha (14 Sep 2023)"
|
||||
set about_text "Tool to Generate Original Art\nv0.5 alpha (15 Sep 2023)"
|
||||
set credits_text "Made by No Time To Play\nMIT License"
|
||||
set site_link "https://notimetoplay.org/graphics/genoa/"
|
||||
|
||||
|
@ -312,7 +313,7 @@ ttk::frame .workspace.view
|
|||
.workspace add .workspace.edit -weight 1
|
||||
.workspace add .workspace.view -weight 1
|
||||
|
||||
set editor [text .workspace.edit.text \
|
||||
set editor [ctext .workspace.edit.text \
|
||||
-width 40 -height 25 -wrap "word" -undo 1]
|
||||
font_size::reset $editor
|
||||
tk_util::pack_scrolled $editor
|
||||
|
@ -470,6 +471,18 @@ if {[llength [info commands "console"]] > 0} {
|
|||
bind . <Command-l> {console show}
|
||||
}
|
||||
|
||||
ctext::addHighlightClass $editor statements blue \
|
||||
"proc set incr if else for foreach while switch break continue return repeat alert"
|
||||
ctext::addHighlightClass $editor functions purple \
|
||||
"expr list string length llength + - * / sin cos"
|
||||
ctext::addHighlightClass $editor drawing purple \
|
||||
"line box circle oval text polygon color fill width font size viewport"
|
||||
ctext::addHighlightClassWithOnlyCharStart $editor variables fuchsia "\$"
|
||||
ctext::addHighlightClassForSpecialChars $editor punctuation blue {[]{};}
|
||||
ctext::addHighlightClassForRegexp $editor comments gray {#[^\n\r]*}
|
||||
ctext::addHighlightClassForRegexp $editor numbers green {[0-9\.\-]+}
|
||||
ctext::addHighlightClassForRegexp $editor strings green {".*?"}
|
||||
|
||||
proc show_modified {} {
|
||||
global status editor
|
||||
if {[$editor edit modified]} {
|
||||
|
@ -537,6 +550,7 @@ proc load_file full_path {
|
|||
try {
|
||||
set f [open $full_path]
|
||||
tk_util::load_text $editor [read $f]
|
||||
$editor highlight 1.0 end
|
||||
set status "Opened $fn"
|
||||
wm title . "$fn | $window_title"
|
||||
return 1
|
||||
|
|
Loading…
Reference in New Issue