@@ 98,9 98,6 @@ char* nnmsg(int desc, char *format, ...) {
if(r > 0 && desc > 0) write(desc, nne_msgbuf, r);
return nne_msgbuf;
}
-#define nnformat(...) nnmsg(0,__VA_ARGS__)
-#define nnprintf(...) nnmsg(1,__VA_ARGS__)
-#define nntrace(...) nnmsg(2,__VA_ARGS__)
/* write a widechar (internal) to stdout */
void nnwritew(int w) {uchar c;while((c=(w&255))>0){write(1,&c,1);w>>=8;}}
@@ 367,10 364,10 @@ uint inkey() { /* input a single key (logical) */
/* Esc (or double Esc) aborts */
/* returns the resulting amount of input characters */
uint nne_prompt(char *prompt) {
- nnprintf(CURSET LINECLR, nne_termh, 1); /* clear the status bar line */
+ nnmsg(1, CURSET LINECLR, nne_termh, 1); /* clear the status bar line */
uint c, rd = 0, endinput = 0, l = strlen(prompt);
/* print the prompt message and move the cursor after it */
- if(l > 0) nnprintf("%s ", prompt);
+ if(l > 0) nnmsg(1, "%s ", prompt);
memset(nne_cmdbuf, 0, NNE_IOBUFSZ * NNE_CSZ); /* zero out the input buffer */
while(rd < NNE_IOBUFSZ) {
c = inkey();
@@ 381,7 378,7 @@ uint nne_prompt(char *prompt) {
nne_cmdbuf[rd-1] = 0; /* zero out the character */
rd--; /* decrement the read counter */
/* move cursor back and erase until the end of the line */
- nnprintf("\x1b[%uD\x1b[0K", c == '\t' ? NNE_TABWIDTH : 1);
+ nnmsg(1, "\x1b[%uD\x1b[0K", c == '\t' ? NNE_TABWIDTH : 1);
}
break;
case K_ESC: case K_MODCMD: endinput = 1; rd = 0; break; /* abort */
@@ 477,11 474,11 @@ void render() { /* main screen rendering function */
scrbuf_append(nne_msgbuf);
nne_status_override = 0;
}
- else scrbuf_append(nnformat(CURSET "%c %s %u,%u %02u%% %ux%u", nne_termh, 1,
+ else scrbuf_append(nnmsg(0, CURSET "%c %s %u,%u %02u%% %ux%u", 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));
- scrbuf_append(nnformat(CURSET CURSHOW "\0", nne_scry, nne_scrx));
+ scrbuf_append(nnmsg(0, CURSET CURSHOW "\0", nne_scry, nne_scrx));
/* actually draw the screen buffer until the first zero byte */
nnputs(nne_scrbuf);
}
@@ 592,7 589,7 @@ int motion_save() { /* save the buffer into file */
nne_cmdbuf[i] >>= 8;
}
} else { /* no new name entered */
- nnformat(CURSET "No file saved", nne_termh, 1);
+ nnmsg(0, CURSET "No file saved", nne_termh, 1);
nne_status_override = 1;
return 0;
}
@@ 609,14 606,14 @@ int nne_action(int key) {
switch(key) {
case 's': case 'w':
if(motion_save()) {
- nnformat(CURSET "Saved %s, %u chars, %u lines",
+ nnmsg(0, CURSET "Saved %s, %u chars, %u lines",
nne_termh, 1, nne_fname, nne_real_len - 2, nne_buflines);
nne_status_override = 1;
}
break;
case 'y': /* copy current line */
r = nne_copyregion(nne_linestart(nne_pos), nne_lineend(nne_pos) + 1);
- nnformat(CURSET "Copied %u chars", nne_termh, 1, r);
+ nnmsg(0, CURSET "Copied %u chars", nne_termh, 1, r);
nne_status_override = 1;
break;
case 'Y': /* copy multiple lines starting from the current one */
@@ 624,14 621,14 @@ int nne_action(int key) {
if(r < 1 || r > nne_buflines - nne_row) r = 1;
i = nne_lineend(nne_findline(nne_row + r - 1));
r = nne_copyregion(nne_linestart(nne_pos), i + 1);
- nnformat(CURSET "Copied %u chars", nne_termh, 1, r);
+ nnmsg(0, CURSET "Copied %u chars", nne_termh, 1, r);
nne_status_override = 1;
break;
case 'd': /* cut current line */
r = nne_copyregion(i = nne_linestart(nne_pos), nne_lineend(nne_pos) + 1);
nne_pos = i; /* go to the current line start */
for(i=0;i<r;i++) motion_del();
- nnformat(CURSET "Cut %u chars", nne_termh, 1, r);
+ nnmsg(0, CURSET "Cut %u chars", nne_termh, 1, r);
nne_status_override = 1;
break;
case 'D': /* cut multiple lines starting from the current one */
@@ 641,12 638,12 @@ int nne_action(int key) {
r = nne_copyregion(i = nne_linestart(nne_pos), j + 1);
nne_pos = i; /* go to the current line start */
for(i=0;i<r;i++) motion_del();
- nnformat(CURSET "Cut %u chars", nne_termh, 1, r);
+ nnmsg(0, CURSET "Cut %u chars", nne_termh, 1, r);
nne_status_override = 1;
break;
case 'v': case 'p': /* paste */
for(i=0;i<nne_cliplen;i++) nne_inschar(nne_clipbuf[i]);
- nnformat(CURSET "Pasted %u chars", nne_termh, 1, nne_cliplen);
+ nnmsg(0, CURSET "Pasted %u chars", nne_termh, 1, nne_cliplen);
nne_status_override = 1;
break;
case 'l':
@@ 673,7 670,7 @@ int nne_action(int key) {
if(r) {nne_pos = nne_searchidx = i; break;}
if(i == nne_real_len - 2) {
nne_searchidx = -1;
- nnformat(CURSET "End of search results", nne_termh, 1);
+ nnmsg(0, CURSET "End of search results", nne_termh, 1);
nne_status_override = 1;
break;
}
@@ 700,7 697,7 @@ int nne_action(int key) {
r = system(rcmd); /* run the shell command */
free(rcmd); /* free command buffer */
nne_loadfile(nne_fname); /* reload file */
- nnformat(CURSET "Command exit code: %d", nne_termh, 1, r);
+ nnmsg(0, CURSET "Command exit code: %d", nne_termh, 1, r);
nne_status_override = 1;
}
break;