Implemented help screen
This commit is contained in:
@@ -24,7 +24,7 @@
|
||||
#define NNE_CSZ sizeof(uint) /* single text character internal size */
|
||||
/* max amount of chars to be input/output on prompts/statuses */
|
||||
#ifndef NNE_IOBUFSZ
|
||||
#define NNE_IOBUFSZ 1000
|
||||
#define NNE_IOBUFSZ 2000
|
||||
#endif
|
||||
#ifndef NNE_TABWIDTH
|
||||
#define NNE_TABWIDTH 2
|
||||
@@ -84,6 +84,49 @@ static uint nne_scr_row; /* current wrapped cursor vertical position */
|
||||
static uint nne_buflines; /* amount of lines loaded into the buffer */
|
||||
static int nne_line_offset = 0; /* offset from the start to the screen */
|
||||
|
||||
/* help screen */
|
||||
|
||||
static char* nne_help_screen = "\x1b[s\
|
||||
---------------------------- nne shortcut help ---------------------------\
|
||||
\x1b[1B\x1b[74D\
|
||||
| |\
|
||||
\x1b[1B\x1b[74D\
|
||||
|Save Esc Esc s, Esc Esc w Line jump Esc Esc l [num] Return |\
|
||||
\x1b[1B\x1b[74D\
|
||||
|Quit Esc Esc q Brace match Esc Esc 5 |\
|
||||
\x1b[1B\x1b[74D\
|
||||
|Tab char Esc Esc Tab Find text Esc Esc / [text] Return|\
|
||||
\x1b[1B\x1b[74D\
|
||||
|Delete Del, Esc Esc Bksp Copy line Esc Esc y |\
|
||||
\x1b[1B\x1b[74D\
|
||||
|Page Up PgUp, Esc Esc Up Copy lines Esc Esc Y [num] Return |\
|
||||
\x1b[1B\x1b[74D\
|
||||
|Page Down PgDn, Esc Esc Down Cut line Esc Esc d |\
|
||||
\x1b[1B\x1b[74D\
|
||||
|Home Home, Esc Esc 0 Cut lines Esc Esc D [num] Return |\
|
||||
\x1b[1B\x1b[74D\
|
||||
|End End, Esc Esc 4 Paste Esc Esc p, Esc Esc v |\
|
||||
\x1b[1B\x1b[74D\
|
||||
|Next word Esc Esc Right Discard/undo Esc Esc u |\
|
||||
\x1b[1B\x1b[74D\
|
||||
|Prev word Esc Esc Left Run shell Esc Esc e [cmd] Return |\
|
||||
\x1b[1B\x1b[74D\
|
||||
|File start Esc Esc 8 This help Esc Esc h |\
|
||||
\x1b[1B\x1b[74D\
|
||||
|File end Esc Esc 9 |\
|
||||
\x1b[1B\x1b[74D\
|
||||
| |\
|
||||
\x1b[1B\x1b[74D\
|
||||
| Created by Luxferre in 2023 |\
|
||||
\x1b[1B\x1b[74D\
|
||||
| Released into public domain |\
|
||||
\x1b[1B\x1b[74D\
|
||||
| |\
|
||||
\x1b[1B\x1b[74D\
|
||||
| Press Return to exit this screen |\
|
||||
\x1b[1B\x1b[74D\
|
||||
--------------------------------------------------------------------------\x1b[u";
|
||||
|
||||
/* elementary routines */
|
||||
|
||||
/* generic routines to output string constants */
|
||||
@@ -474,10 +517,10 @@ void render() { /* main screen rendering function */
|
||||
scrbuf_append(nne_msgbuf);
|
||||
nne_status_override = 0;
|
||||
}
|
||||
else scrbuf_append(nnmsg(0, CURSET "%c %s %u,%u %02u%% %ux%u", nne_termh, 1,
|
||||
else scrbuf_append(nnmsg(0, CURSET "%c %s %u,%u %02u%% %ux%u | %s", nne_termh, 1,
|
||||
(nne_mode == NNE_CMD) ? 'C' : '-', nne_fname, nne_row, nne_col,
|
||||
(100*nne_pos/(nne_real_len <= 2 ? 2 : nne_real_len - 2)),
|
||||
nne_termw, nne_termh));
|
||||
nne_termw, nne_termh, "Press Esc Esc h to get help"));
|
||||
scrbuf_append(nnmsg(0, CURSET CURSHOW "\0", nne_scry, nne_scrx));
|
||||
/* actually draw the screen buffer until the first zero byte */
|
||||
nnputs(nne_scrbuf);
|
||||
@@ -750,6 +793,11 @@ int nne_action(int key) {
|
||||
case K_DOWN: motion_pgdn(); break;
|
||||
case K_BACKSPACE: motion_del(); break;
|
||||
case '\t': nne_inschar('\t'); break; /* insert literal tab */
|
||||
case 'h': /* help screen */
|
||||
nnmsg(1, CURSET "%s", (nne_termh >> 1) - 10, (nne_termw >> 1) - 37,
|
||||
nne_help_screen);
|
||||
r = nne_prompt(""); /* pause editing, wait for Return key */
|
||||
break;
|
||||
}
|
||||
nne_mode = NNE_NORMAL; /* exit the modcommand mode afterwards */
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user