Add version 1.1.1

This commit is contained in:
No Time To Play 2023-09-09 15:31:00 +00:00
parent 55fc68056d
commit 1bc36befda
3 changed files with 42 additions and 26 deletions

12
NEWS.md
View File

@ -1,4 +1,14 @@
# Toyed project news
# ToyEd text editor project news
## [1.1.1] - 2023-09-07
### Changed
* [internal] Unified window / dialog titles.
### Fixed
* modified flag not reset on file save
## [1.1] - 2023-01-06

View File

@ -12,9 +12,9 @@ ToyEd is written in 650 lines of Tcl/Tk (see below), but has many expected featu
- formatting functions
- display options
ToyEd is open source under the MIT license. See source code:
ToyEd is open source under the MIT license. See source code.
As of 6 January 2023, the code seems to work right, but hasn't really been tested. Please back up your data.
As of 7 September 2023, the code seems to work right, but hasn't really been tested. Please back up your data.
The user interface should be fairly obvious.

View File

@ -1,7 +1,7 @@
#!/usr/bin/env tclsh
#
# ToyEd: a toy text editor for educational purposes in Tcl/Tk.
# Copyright 2022 Felix Pleșoianu <https://felix.plesoianu.ro/>
# Copyright 2022, 2023 Felix Pleșoianu <https://felix.plesoianu.ro/>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
@ -28,7 +28,9 @@ package require try
package require getstring
namespace import getstring::*
set about_text "A toy text editor\nVersion 1.1 (6 Jan 2023)\nMIT License"
set window_title "ToyEd Text Editor"
set about_text "A toy text editor\nVersion 1.1.1 (7 Sep 2023)\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/"
@ -156,7 +158,7 @@ namespace eval tk_util {
}
}
wm title . "ToyEd"
wm title . $window_title
option add *tearOff 0
. configure -padx 4
@ -340,12 +342,12 @@ proc show_modified {} {
}
proc do_new {} {
global status file_name
global status file_name window_title
if {[.editor edit modified]} {
set answer [tk_messageBox -parent . \
-type "yesno" -icon "question" \
-title "ToyEd" \
-title $window_title \
-message "New file?" \
-detail "File is unsaved.\nStart another?"]
if {!$answer} {
@ -353,7 +355,7 @@ proc do_new {} {
return
}
}
wm title . "ToyEd"
wm title . $window_title
set file_name ""
.editor delete "1.0" "end"
.editor edit reset
@ -362,12 +364,12 @@ proc do_new {} {
}
proc do_open {} {
global status file_types file_name
global status file_types file_name window_title
if {[.editor edit modified]} {
set answer [tk_messageBox -parent . \
-type "yesno" -icon "question" \
-title "ToyEd" \
-title $window_title \
-message "Open another file?" \
-detail "File is unsaved.\nOpen another?"]
if {!$answer} {
@ -384,7 +386,7 @@ proc do_open {} {
} elseif {![file isfile $choice]} {
tk_messageBox -parent . \
-type "ok" -icon "error" \
-title "ToyEd" \
-title $window_title \
-message "Error opening file" \
-detail "File not found: $choice"
} elseif {[load_file $choice]} {
@ -393,19 +395,19 @@ proc do_open {} {
}
proc load_file full_path {
global status
global status window_title
set fn [file tail $full_path]
try {
set f [open $full_path]
tk_util::load_text .editor [read $f]
set status "Opened $fn"
wm title . "$fn | ToyEd"
wm title . "$fn | $window_title"
return 1
} on error e {
tk_messageBox -parent . \
-type "ok" -icon "error" \
-title "ToyEd" \
-title $window_title \
-message "Error opening file" \
-detail $e
return 0
@ -446,7 +448,7 @@ proc do_save_as {} {
}
proc save_file full_path {
global status
global status window_title
set fn [file tail $full_path]
set data [.editor get "1.0" "end"]
@ -455,13 +457,14 @@ proc save_file full_path {
set f [open $full_path "w"]
puts -nonewline $f "$data\n"
flush $f
.editor edit modified 0
set status "Saved $fn"
wm title . "$fn | ToyEd"
wm title . "$fn | $window_title"
return 1
} on error e {
tk_messageBox -parent . \
-type "ok" -icon "error" \
-title "ToyEd" \
-title $window_title \
-message "Error saving file" \
-detail $e
return 0
@ -471,17 +474,17 @@ proc save_file full_path {
}
proc do_reload {} {
global file_name status
global file_name status window_title
if {$file_name eq ""} {
tk_messageBox -parent . \
-type "ok" -icon "warning" \
-title "ToyEd" \
-title $window_title \
-message "Can't reload." \
-detail "The file was never saved."
} else {
set answer [tk_messageBox -parent . \
-type "yesno" -icon "question" \
-title "ToyEd" \
-title $window_title \
-message "Reload file?" \
-detail "Reload last save?"]
if {$answer eq "yes"} {
@ -493,6 +496,7 @@ proc do_reload {} {
}
proc show_stats {} {
global window_title
set data [tk_util::text_selection .editor]
if {$data eq ""} {
set data [.editor get "1.0" "end"]
@ -506,16 +510,17 @@ proc show_stats {} {
set chars [string length $data]
set stats "Lines: $lines\nWords: $words\nCharacters: $chars"
tk_messageBox -parent . \
-type "ok" -icon "info" -title "ToyEd" \
-type "ok" -icon "info" -title $window_title \
-message $msg -detail $stats
}
proc do_quit {} {
global window_title
if {[.editor edit modified]} {
set answer [tk_messageBox -parent . \
-type "yesno" -icon "question" \
-title "ToyEd" \
-message "Quit ToyEd?" \
-title $window_title \
-message "Quit $window_title?" \
-detail "File is unsaved.\nQuit anyway?"]
} else {
set answer "yes"
@ -618,9 +623,10 @@ proc prefix_lines {} {
}
proc alert message {
global window_title
tk_messageBox -parent . \
-type "ok" -icon "info" \
-title "ToyEd" \
-title $window_title \
-message $message
}
@ -644,7 +650,7 @@ if {[llength $argv] > 0} {
if {![file exists $fn]} {
set file_name [file normalize $fn]
set fn [file tail $file_name]
wm title . "$fn | ToyEd"
wm title . "$fn | $window_title"
} elseif {[load_file $fn]} {
set file_name [file normalize $fn]
}