From 02c54fe6f289901f5b356ca98a81dec78fef4f36 Mon Sep 17 00:00:00 2001 From: KatolaZ Date: Fri, 16 Aug 2019 19:36:20 +0100 Subject: add support for comments --- Changelog | 9 +++++++++ TODO | 2 +- draw.c | 9 +++++++++ gramscii.1 | 4 ++++ gramscii.c | 4 ++++ gramscii.h | 2 ++ screen.c | 2 ++ 7 files changed, 31 insertions(+), 1 deletion(-) diff --git a/Changelog b/Changelog index 31ba0de..33056e3 100644 --- a/Changelog +++ b/Changelog @@ -1,3 +1,12 @@ +0940cd0 2019-08-14 (KatolaZ) update manpage to include parallelogram +a95019d 2019-08-14 (KatolaZ) add parallelogram mode +257ec5d 2019-08-13 (KatolaZ) towards parallelograms +39ec615 2019-08-12 (Quentin Rameau) Arrange makefile debug target +3d5be35 2019-08-12 (KatolaZ) accept commands from stdin in script-mode +0522ef6 2019-08-12 (KatolaZ) fix read of command scripts and script-mode +a46183e 2019-08-11 (KatolaZ) replace cleanup() with exit() in usage() +e4c527b 2019-08-09 (KatolaZ) check all mem allocations +a6f10d6 2019-08-09 (KatolaZ) release 0.3 1ad3249 2019-08-09 (KatolaZ) bump version to 0.3 bc374cf 2019-08-09 (KatolaZ) update TODO 0c0e806 2019-08-09 (KatolaZ) small change to manpage diff --git a/TODO b/TODO index 48e2395..1375028 100644 --- a/TODO +++ b/TODO @@ -1,5 +1,4 @@ + optimize redraws (redraw only the modified rectangle) -- implement comment (#: ignore everything until the end of the line) - add screen geometry option (-g 25x80?) - (?)maybe move "text" mode to "t" - implement ellipse @@ -14,6 +13,7 @@ - allow scrolling (both vertical and horizontal) - catch SIGWINCH and react appropriately (after scrolling is enabled) +* implement comment (#: ignore everything until the end of the line) * implement parallelogram mode (z/Z) * fix bug in reading commands from files * fix bug in visual crop diff --git a/draw.c b/draw.c index c361acb..1c74a94 100644 --- a/draw.c +++ b/draw.c @@ -508,3 +508,12 @@ void redo_change(){ redraw(); } + +/** Comments **/ + +void get_comment(FILE *fc){ + char c; + redraw(); + while((c = fgetc(fc)) != EOF && c != '\n'); + mode = MOVE; +} diff --git a/gramscii.1 b/gramscii.1 index e9dd102..3370c24 100644 --- a/gramscii.1 +++ b/gramscii.1 @@ -144,6 +144,10 @@ prompted for a filename to save the screen to. Write the current screen to a new file. This commands acts like .B w but always prompts for a file name to use. +.TP 5m +.BI # +Start a comment. Discard all the characters until a newline is +entered. Useful to include comments in scripts. .SS MOVEMENTS The following movement commands are available in any mode where cursor diff --git a/gramscii.c b/gramscii.c index 29b3f04..977a8cb 100644 --- a/gramscii.c +++ b/gramscii.c @@ -138,6 +138,10 @@ void commands(FILE *fc){ mode = PAR; get_box(fc, BOX_PARR); break; + case '#': + mode = REM; + get_comment(fc); + break; case 'q': check_modified(fc);/** FALLTHROUGH **/ case 'Q': diff --git a/gramscii.h b/gramscii.h index 6adea42..8aec939 100644 --- a/gramscii.h +++ b/gramscii.h @@ -19,6 +19,7 @@ #define DEL 0x08 #define VIS 0x10 #define PAR 0x20 +#define REM 0x40 /**/ /* directions */ @@ -186,6 +187,7 @@ void visual_box(FILE *fc); void paste(); void undo_change(); void redo_change(); +void get_comment(FILE *fc); /**/ /** file-related functions **/ diff --git a/screen.c b/screen.c index 21289c1..28d2318 100644 --- a/screen.c +++ b/screen.c @@ -37,6 +37,8 @@ char* mode_str(){ return "vis"; case PAR: return "par"; + case REM: + return "rem"; default: return "ERR"; } -- cgit v1.2.3