summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick White <git@njw.me.uk>2013-12-20 12:42:56 +0000
committerNick White <git@njw.me.uk>2013-12-20 12:42:56 +0000
commit417f681bbf1deeabe30b5c60d1272bbcb6b0c8fb (patch)
tree0e9acbf6cf57d6dc730f3c63c9138afc924af5d4
parent6bc1dff7b13029be6c1d631f09aca2bf6ab9283c (diff)
downloadtkread-417f681bbf1deeabe30b5c60d1272bbcb6b0c8fb.tar.bz2
tkread-417f681bbf1deeabe30b5c60d1272bbcb6b0c8fb.zip
Put markdown formatting behind a flag
-rwxr-xr-xtkread17
1 files changed, 12 insertions, 5 deletions
diff --git a/tkread b/tkread
index 037befb..b14204a 100755
--- a/tkread
+++ b/tkread
@@ -1,6 +1,7 @@
#!/usr/bin/tclsh
-# Usage: tkread [-w]
+# Usage: tkread [-w] [-m]
# -w rewrap lines
+# -m format markdown text
#
# The markdown parsing is inspired by the code of smu:
# <https://github.com/Gottox/smu>
@@ -11,7 +12,7 @@
# - add function to type 30g to scroll 30% through an article
# - if window width is small, reduce padx space
# - make scrolling using mouse work even when text area isn't hovered over (also note this sort of scrolling doesn't update the title); integrate the MouseWheel event with scroll. this *should* also fix the issue of dragging and then leaving the window, as the strange scrolling is likely caused by related default behaviour
-# - add more markdown processing and control it using a flag
+# - add more markdown processing
# - use font create / configure to name a font to simplify changing its size
set fontsize 15
@@ -25,6 +26,7 @@ set invertoutercolour #222222
set inverted 0
set drag 0
set tagnum 0
+set domarkdown 0
set surroundfmt { \
{"***" "bold italic"} \
@@ -138,11 +140,16 @@ proc doMotion {ypos} {
text .t -font "Times $fontsize" -wrap word -width 64 -padx [expr $fontsize * 3] -bg $bgcolour -fg $textcolour -relief flat -inactiveselectbackground {} -cursor {}
pack .t -expand yes -fill y
set text [read stdin]
-if { $::argc > 0 && [lindex $::argv 0] == "-w" } {
- set text [rewrap $text]
+foreach arg $::argv {
+ switch $arg {
+ -w { set text [rewrap $text] }
+ -m { set domarkdown 1 }
+ }
}
.t insert end $text
-markup .t
+if { $domarkdown } {
+ markup .t
+}
.t configure -state disabled ;# disable cursor
bind . <Up> {scroll -1 unit}