git.y1.nz

mtm

Ncurses-based terminal multiplexer
download: https://git.y1.nz/archives/mtm.tar.gz
Files | Log | Refs

commit 623d54aebb11329ef761e7ae48b2e856d6977d9e
parent 27c2fcaf75dc784c538f9581ba3e47ce701ed1ca
Author: Rob King <deadpixi@users.noreply.github.com>
Date:   Sat, 18 Feb 2017 21:43:41 -0600

Merge pull request #2 from fxleblanc/config

config.h
Diffstat:
Aconfig.h18++++++++++++++++++
Mmtm.c19++++++++++---------
2 files changed, 28 insertions(+), 9 deletions(-)

diff --git a/config.h b/config.h @@ -0,0 +1,18 @@ +// Command key +#define COMMAND_KEY 'g' + +// Basic motions +#define MOVE_UP KEY_UP +#define MOVE_DOWN KEY_DOWN +#define MOVE_RIGHT KEY_RIGHT +#define MOVE_LEFT KEY_LEFT + +// Split commands +#define SPLIT_HORIZONTAL 'h' +#define SPLIT_VERTICAL 'v' + +// Delete a node +#define DELETE_NODE 'w' + +// Redraw +#define REDRAW 'l' diff --git a/mtm.c b/mtm.c @@ -32,6 +32,7 @@ #include NCURSESW_INCLUDE_H #include "tmt.h" +#include "config.h" #define CTL(x) ((x) & 0x1f) #define TOPAIR(fg, bg) (monochrome? 0 : (((fg) * 8) | (bg))) @@ -65,7 +66,7 @@ struct NODE{ static NODE *root, *focused; static bool monochrome, needresize = true; -static int commandkey = CTL('g'); +static int commandkey = CTL(COMMAND_KEY); static void reshape(NODE *n, int y, int x, int h, int w); static void draw(NODE *n, bool force); @@ -429,14 +430,14 @@ handlechar(int k, int pt) DO(false, KEY_HOME, WRITESTR(TMT_KEY_HOME)) DO(false, KEY_END, WRITESTR(TMT_KEY_END)) DO(cmd, commandkey, return cmd = !cmd) - DO(true, KEY_UP, focus(findnode(root, ABOVE(focused)))) - DO(true, KEY_DOWN, focus(findnode(root, BELOW(focused)))) - DO(true, KEY_LEFT, focus(findnode(root, LEFT(focused)))) - DO(true, KEY_RIGHT, focus(findnode(root, RIGHT(focused)))) - DO(true, 'h', split(focused, HORIZONTAL)) - DO(true, 'v', split(focused, VERTICAL)) - DO(true, 'w', deletenode(focused)) - DO(true, 'l', draw(root, true)) + DO(true, MOVE_UP, focus(findnode(root, ABOVE(focused)))) + DO(true, MOVE_DOWN, focus(findnode(root, BELOW(focused)))) + DO(true, MOVE_LEFT, focus(findnode(root, LEFT(focused)))) + DO(true, MOVE_RIGHT, focus(findnode(root, RIGHT(focused)))) + DO(true, SPLIT_HORIZONTAL, split(focused, HORIZONTAL)) + DO(true, SPLIT_VERTICAL, split(focused, VERTICAL)) + DO(true, DELETE_NODE, deletenode(focused)) + DO(true, REDRAW, draw(root, true)) return cmd = false; }

This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.