Add version 1.3
This commit is contained in:
parent
7ff9c3e201
commit
3e892a4d2e
14
NEWS.md
14
NEWS.md
|
@ -1,5 +1,19 @@
|
|||
# ToyEd text editor project news
|
||||
|
||||
## [1.3] - 2024-01-23
|
||||
|
||||
### Added
|
||||
|
||||
* Line numbers
|
||||
|
||||
### Changed
|
||||
|
||||
* Choice of toolbar buttons
|
||||
|
||||
### Removed
|
||||
|
||||
* Shortcut keys from toolbar
|
||||
|
||||
## [1.2] - 2023-10-06
|
||||
|
||||
### Changed
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
# About ToyEd
|
||||
|
||||
"A toy text editor in Tcl/Tk for educational purposes."
|
||||
> A toy text editor in Tcl/Tk for educational purposes.
|
||||
|
||||
ToyEd is a toy text editor made for fun and learning. It's not meant for serious use, but rather to be studied and built upon.
|
||||
|
||||
ToyEd is written in 700 lines of Tcl/Tk (see below), but has many expected features:
|
||||
ToyEd is written in 700+ lines of Tcl/Tk (see below), but has many expected features:
|
||||
|
||||
- GUI controls
|
||||
- keyboard operation
|
||||
|
@ -14,7 +14,7 @@ ToyEd is written in 700 lines of Tcl/Tk (see below), but has many expected featu
|
|||
|
||||
ToyEd is open source under the MIT license. See source code.
|
||||
|
||||
As of 6 October 2023, the code seems to work right, but hasn't been tested much. Please back up your data.
|
||||
As of 23 Jan 2024, the editor has seen little use. Please back up your data.
|
||||
|
||||
The user interface should be fairly obvious.
|
||||
|
||||
|
|
51
toyed.tcl
51
toyed.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 "ToyEd Text Editor"
|
||||
|
||||
set about_text "A toy text editor\nVersion 1.2 (6 Oct 2023)\nMIT License"
|
||||
set about_text "A toy text editor\nVersion 1.3 (23 Jan 2024)\nMIT License"
|
||||
set credits_text "Made by No Time To Play\nbased on knowledge\nfrom TkDocs.com"
|
||||
set site_link "https://ctrl-c.club/~nttp/toys/toyed/"
|
||||
|
||||
|
@ -175,37 +176,33 @@ pack .status -side bottom -fill x -pady 4
|
|||
pack .status.line -side left -fill x -expand 1
|
||||
pack .status.grip -side right -anchor s
|
||||
|
||||
text .editor -width 80 -height 24 -wrap "word" -undo 1
|
||||
ctext .editor -width 80 -height 24 -wrap "word" -undo 1 -linemap 0
|
||||
font_size::reset .editor
|
||||
tk_util::pack_scrolled .editor
|
||||
|
||||
ttk::button .toolbar.new -text "New" -width 8 -under 0 -command do_new
|
||||
ttk::button .toolbar.bOpen -text "Open" -width 8 -under 0 -command do_open
|
||||
ttk::button .toolbar.save -text "Save" -width 8 -under 0 -command do_save
|
||||
ttk::button .toolbar.new -text "New" -width 8 -command do_new
|
||||
ttk::button .toolbar.bOpen -text "Open" -width 8 -command do_open
|
||||
ttk::button .toolbar.save -text "Save" -width 8 -command do_save
|
||||
ttk::button .toolbar.reload -text "Reload" -width 8 -command do_reload
|
||||
|
||||
ttk::separator .toolbar.sep1 -orient vertical
|
||||
|
||||
ttk::button .toolbar.reload -text "Reload" -width 8 -under 0 -command do_reload
|
||||
ttk::button .toolbar.stats -text "Stats" -width 8 -under 1 -command show_stats
|
||||
|
||||
ttk::separator .toolbar.sep2 -orient vertical
|
||||
|
||||
ttk::button .toolbar.find -text "Find" -width 8 -under 0 -command do_find
|
||||
ttk::button .toolbar.again -text "Again" -width 8 -under 1 -command find_again
|
||||
ttk::button .toolbar.undo -text "Undo" -width 8 -command {.editor edit undo}
|
||||
ttk::button .toolbar.redo -text "Redo" -width 8 -command {.editor edit redo}
|
||||
ttk::button .toolbar.find -text "Find" -width 8 -command do_find
|
||||
ttk::button .toolbar.next -text "Next" -width 8 -command find_again
|
||||
|
||||
pack .toolbar.new -side left
|
||||
pack .toolbar.bOpen -side left
|
||||
pack .toolbar.save -side left
|
||||
pack .toolbar.reload -side left
|
||||
|
||||
pack .toolbar.sep1 -side left -padx 4 -pady 4 -fill y
|
||||
|
||||
pack .toolbar.reload -side left
|
||||
pack .toolbar.stats -side left
|
||||
|
||||
pack .toolbar.sep2 -side left -padx 4 -pady 4 -fill y
|
||||
|
||||
pack .toolbar.undo -side left
|
||||
pack .toolbar.redo -side left
|
||||
pack .toolbar.find -side left
|
||||
pack .toolbar.again -side left
|
||||
pack .toolbar.next -side left
|
||||
|
||||
. configure -menu [menu .menubar]
|
||||
|
||||
|
@ -256,6 +253,8 @@ $m add command -label "Prefix lines..." -command prefix_lines \
|
|||
set m [menu .menubar.view]
|
||||
$m add checkbutton -label "Word wrap" -under 0 -var _word_wrap \
|
||||
-command {tk_util::word_wrap .editor}
|
||||
$m add checkbutton -label "Line numbers" -under 0 -var _line_nums \
|
||||
-command {toggle_lines .editor}
|
||||
$m add separator
|
||||
$m add command -label "Bigger font" -under 0 -accel "Ctrl +" \
|
||||
-command {font_size incr .editor}
|
||||
|
@ -348,7 +347,7 @@ proc do_new {} {
|
|||
-type "yesno" -icon "question" \
|
||||
-title $window_title \
|
||||
-message "New file?" \
|
||||
-detail "File is unsaved.\nStart another?"]
|
||||
-detail "File isn't saved.\nStart another?"]
|
||||
if {!$answer} {
|
||||
set status "New file canceled."
|
||||
return
|
||||
|
@ -370,7 +369,7 @@ proc do_open {} {
|
|||
-type "yesno" -icon "question" \
|
||||
-title $window_title \
|
||||
-message "Open another file?" \
|
||||
-detail "File is unsaved.\nOpen another?"]
|
||||
-detail "File isn't saved.\nOpen another?"]
|
||||
if {!$answer} {
|
||||
set status "Opening canceled."
|
||||
return
|
||||
|
@ -586,7 +585,7 @@ proc do_quit {} {
|
|||
proc do_find {} {
|
||||
global search_term status
|
||||
set term [tk_util::text_selection .editor]
|
||||
set ret [tk_getString .gs answer "Search pattern:" \
|
||||
set ret [tk_getString .gs answer "Search term:" \
|
||||
-title "Find" -entryoptions "-textvar search_term"]
|
||||
if {!$ret} {
|
||||
set status "Search canceled."
|
||||
|
@ -664,7 +663,7 @@ proc prefix_lines {} {
|
|||
}
|
||||
set ret [tk_getString .gs answer "Prefix selected lines with:"]
|
||||
if {!$ret} {
|
||||
set status "Search canceled."
|
||||
set status "Prefix canceled."
|
||||
return
|
||||
}
|
||||
set lines [split $sel "\n"]
|
||||
|
@ -675,6 +674,14 @@ proc prefix_lines {} {
|
|||
.editor replace sel.first sel.last [join $result "\n"]
|
||||
}
|
||||
|
||||
proc toggle_lines widget {
|
||||
if {[$widget cget -linemap]} {
|
||||
$widget configure -linemap 0
|
||||
} else {
|
||||
$widget configure -linemap 1
|
||||
}
|
||||
}
|
||||
|
||||
proc alert message {
|
||||
global window_title
|
||||
tk_messageBox -parent . \
|
||||
|
|
Loading…
Reference in New Issue