tAllow set of status message - ve - a minimal text editor (work in progress)
(HTM) git clone git://src.adamsgaard.dk/ve
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit 8ce8f682e8b6e18b5b095a372c929090036ea07b
(DIR) parent 6652c9e2828ed13a56d577d091a2bb2ba174da83
(HTM) Author: Anders Damsgaard <anders@adamsgaard.dk>
Date: Tue, 6 Aug 2019 14:52:53 +0200
Allow set of status message
Diffstat:
M byote.h | 3 +++
M output.c | 13 +++++++++++++
M terminal.c | 3 +++
3 files changed, 19 insertions(+), 0 deletions(-)
---
(DIR) diff --git a/byote.h b/byote.h
t@@ -2,6 +2,7 @@
#define BYOTE_H_
#include <termios.h>
+#include <time.h>
#define PROGNAME "byote"
#define VERSION "0.0.1"
t@@ -25,6 +26,8 @@ struct editor_config {
char *filename;
struct termios orig_termios;
int mode; /* 0: normal, 1: insert, 2: visual */
+ char status_msg[80];
+ time_t status_msg_time;
};
extern struct editor_config E;
(DIR) diff --git a/output.c b/output.c
t@@ -2,6 +2,8 @@
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
+#include <stdarg.h>
+#include <time.h>
#include "terminal.h"
#include "output.h"
#include "byote.h"
t@@ -158,3 +160,14 @@ editor_refresh_screen()
write(STDOUT_FILENO, ab.b, ab.len);
ab_free(&ab);
}
+
+/* set status message text, uses same format as printf */
+void
+editor_set_status_message(const char *fmt, ...)
+{
+ va_list ap;
+ va_start(ap, fmt);
+ vsnprintf(E.status_msg, sizeof(E.status_msg), fmt, ap);
+ va_end(ap);
+ E.status_msg_time = time(NULL);
+}
(DIR) diff --git a/terminal.c b/terminal.c
t@@ -118,6 +118,9 @@ init_editor() {
E.row_offset = 0;
E.column_offset = 0;
E.filename = NULL;
+ E.status_msg[0] = '\0';
+ E.status_msg_time = 0;
+
if (get_window_size(&E.screen_rows, &E.screen_columns) == -1)
die("get_window_size");
E.screen_rows -= 1;