From d76b2c1c43fae29e67b2eed400d8e0c6ebc880b1 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Tue, 12 Jun 2018 09:35:06 +1000 Subject: [PATCH 1/3] working plain ascii export --- pxltrm | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/pxltrm b/pxltrm index 88cb392..95b39d4 100755 --- a/pxltrm +++ b/pxltrm @@ -47,14 +47,19 @@ status_line() { } save_file() { - local IFS= - printf '\e[2J\e[2;H%b\e[m\e[%s;H' "${hist[*]}" "$((LINES-3))" > "$1" + for((i=2;i "${file:-/dev/null}" ;; o) read -rp "load file: " file; [[ -f "$file" ]] && load_file "$file" ;; c) read -rp "input color: " color ;; b) read -rp "input brush: " brush_char ;; From 18f0e5469c9b058d7c1870729e0045cf202576ab Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Tue, 12 Jun 2018 10:04:11 +1000 Subject: [PATCH 2/3] working plain ascii export --- pxltrm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pxltrm b/pxltrm index 95b39d4..2d804b5 100755 --- a/pxltrm +++ b/pxltrm @@ -48,18 +48,18 @@ status_line() { save_file() { for((i=2;i Date: Tue, 12 Jun 2018 10:35:52 +1000 Subject: [PATCH 3/3] add export option --- pxltrm | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/pxltrm b/pxltrm index 2d804b5..0831b83 100755 --- a/pxltrm +++ b/pxltrm @@ -34,7 +34,7 @@ status_line() { print_color print_palette - hud="[d]raw, [e]rase, cle[a]r, [s]ave, [o]pen, [u]ndo, [r]edo" + hud="[d]raw, [e]rase, cle[a]r, [u]ndo, [r]edo, [s]ave, [o]pen, e[x]port" hud="${hud::$COLUMNS}" hud="${hud//\[/\[\\e[1m}" printf '\e[s\e[;H\e[m%b' "${hud//\]/\\e[m\]}" @@ -46,7 +46,7 @@ status_line() { "${padding}${status//▃/ }\\n${padding}${status}" } -save_file() { +export_file() { for((i=2;i "${file:-/dev/null}" ;; - o) read -rp "load file: " file; [[ -f "$file" ]] && load_file "$file" ;; + s) read -rp "save file: " f; save_file > "${f:-/dev/null}.pxl" ;; + o) read -rp "load file: " f; [[ -f "$f" ]] && load_file "$f" ;; c) read -rp "input color: " color ;; b) read -rp "input brush: " brush_char ;; a) read -n 1 -rp "clear? [y/n]: " y; [[ "$y" == y ]] && clear_screen ;; + x) read -rp "export file: " f; export_file > "${f:-/dev/null}" ;; esac printf '\e[u' @@ -133,7 +139,7 @@ cursor() { u) (("${#hist}">0)) && undo; status_line ;; r) (("${#undos}">1)) && redo; status_line ;; - a|b|c|o|s) prompt "${1: -1}" ;; + a|b|c|o|s|x) prompt "${1: -1}" ;; esac }