commit df1abe55cadfd73e4c97b65b9213d4b3bb041f66
parent dc03315b6ed63eb00b28a6535d95a0e8ba8a71ec
Author: Andreas Gruhler <agruhl@gmx.ch>
Date: Sun, 2 Jan 2022 00:51:32 +0100
add no_mouse flag
Diffstat:
3 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/src/diary.c b/src/diary.c
@@ -373,6 +373,7 @@ void usage() {
printf(" -f, --fmt FMT : Date and file format, change with care\n");
printf(" -F, --fmt-cmd FMT_CMD : Format entry preview with command FMT_CMD\n");
printf(" -p, --no-pty : Result of FMT_CMD not printed to pty but processed within Ncurses\n");
+ printf(" -m, --no-mouse : Disable mouse, don't listen for mouse events\n");
printf(" -r, --range RANGE : RANGE is the number of years to show before/after today's date\n");
printf(" -w, --weekday DAY : First day of the week, 0 = Sun, 1 = Mon, ..., 6 = Sat\n");
printf("\n");
@@ -469,6 +470,7 @@ int main(int argc, char** argv) {
{ "fmt", required_argument, 0, 'f' },
{ "fmt-cmd", required_argument, 0, 'F' },
{ "no-pty", no_argument, 0, 'p' },
+ { "no-mouse", no_argument, 0, 'm' },
{ "range", required_argument, 0, 'r' },
{ "weekday", required_argument, 0, 'w' },
{ 0, 0, 0, 0 }
@@ -476,7 +478,7 @@ int main(int argc, char** argv) {
// read option characters
while (1) {
- option_char = getopt_long(argc, argv, "vhpd:r:w:f:F:e:", long_options, &option_index);
+ option_char = getopt_long(argc, argv, "vhpmd:r:w:f:F:e:", long_options, &option_index);
if (option_char == -1) {
break;
@@ -523,6 +525,10 @@ int main(int argc, char** argv) {
// set no-pty flag
CONFIG.no_pty = true;
break;
+ case 'm':
+ // set no-mouse flag
+ CONFIG.no_mouse = true;
+ break;
case 'e':
// set default editor from option character
CONFIG.editor = (char *) calloc(strlen(optarg) + 1, sizeof(char));
@@ -593,10 +599,15 @@ int main(int argc, char** argv) {
WINDOW* prev = newwin(prev_height, prev_width, 1, ASIDE_WIDTH + CAL_WIDTH);
display_entry(CONFIG.dir, diary_dir_size, &today, prev, prev_width);
+
mmask_t oldmask;
- mousemask(ALL_MOUSE_EVENTS, &oldmask);
MEVENT event;
+ if (!CONFIG.no_mouse) {
+ // listen for mouse events if not disabled explicitly
+ mousemask(ALL_MOUSE_EVENTS, &oldmask);
+ }
+
do {
ch = wgetch(cal);
// new_date represents the desired date the user wants to go_to(),
diff --git a/src/utils.c b/src/utils.c
@@ -404,6 +404,7 @@ config CONFIG = {
.fmt = "%Y-%m-%d",
.fmt_cmd = "",
.no_pty = false,
+ .no_mouse = false,
.editor = "",
.google_tokenfile = GOOGLE_OAUTH_TOKEN_FILE,
.google_clientid = GOOGLE_OAUTH_CLIENT_ID,
diff --git a/src/utils.h b/src/utils.h
@@ -50,6 +50,8 @@ typedef struct
char* fmt_cmd;
// Don't use pty, use ncurses for preview
bool no_pty;
+ // Don't listen for mouse events
+ bool no_mouse;
// Editor to open journal files with
char* editor;
// File for Google OAuth access token