add support for comments - gramscii - A simple editor for ASCII box-and-arrow charts
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) Tags
(DIR) README
(DIR) LICENSE
---
(DIR) commit 02c54fe6f289901f5b356ca98a81dec78fef4f36
(DIR) parent 0940cd06c4a36b4794c48ebc703559caf7d53c53
(HTM) Author: KatolaZ <katolaz@freaknet.org>
Date: Fri, 16 Aug 2019 19:36:20 +0100
add support for comments
Diffstat:
M Changelog | 9 +++++++++
M TODO | 2 +-
M draw.c | 9 +++++++++
M gramscii.1 | 4 ++++
M gramscii.c | 4 ++++
M gramscii.h | 2 ++
M screen.c | 2 ++
7 files changed, 31 insertions(+), 1 deletion(-)
---
(DIR) diff --git 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
(DIR) diff --git 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
(DIR) diff --git 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;
+}
(DIR) diff --git 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
(DIR) diff --git 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':
(DIR) diff --git 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 **/
(DIR) diff --git 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";
}