~aperezdc/sue

75b08dbb8d38797edbefe1f2b8d19c09f18e0b21 — Adrian Perez de Castro 2 years ago db453a2
Replace wp[1234] macros with a single one

The wp[1234] macros in reality are accomodating for the fact that
the C preprocessor did not use to have vararg macros, so replace
them all with a single wpn() macro which uses __VA_ARGS__.
4 files changed, 52 insertions(+), 66 deletions(-)

M ccommand.c
M fcommand.c
M funcs.c
M sue.h
M ccommand.c => ccommand.c +1 -3
@@ 130,7 130,7 @@ CKey_scan(void)
		}
		dohelp(PRIMARY, editwin);
		wattrset(editwin, PROMPTATTR);
		wp1("Strike a MENU KEY or RETURN: ");
		wpn("Strike a MENU KEY or RETURN: ");
		wattrset(editwin, A_NORMAL);
		wrefresh(editwin);
		ch = waitkey();


@@ 259,8 259,6 @@ CKey_scan(void)
		addtext(ch);				/* All else is text */
		break;
	}
	warnflag2 = 0;
	return;
}

/* --------------------------------------

M fcommand.c => fcommand.c +21 -31
@@ 106,33 106,29 @@ FKey_scan(void)
	case KEY_HELP:
	case KEY_F(3):				/* Function key mode help screen */
		wmove(editwin, 0, 0);
		wp1("[`F1`] Cancel command, or undelete     [`F6`] Search for and replace text\n");
		wp1("[`F2`] Search for string of text       [`F7`] Exit SUE, optionally saving text\n");
		wpn("[`F1`] Cancel command, or undelete     [`F6`] Search for and replace text\n");
		wpn("[`F2`] Search for string of text       [`F7`] Exit SUE, optionally saving text\n");
		if (restricted)
		{	wp1("[`F3`] This help");
		}
			wpn("[`F3`] This help");
		else
		{	wp1("[`F3`] This help                       [`F8`] Retrieve a new file from disk\n");
		}
		wp1("[`F4`] Block function menu             [`F9`] Reformat text to end of paragraph\n");
			wpn("[`F3`] This help                       [`F8`] Retrieve a new file from disk\n");
		wpn("[`F4`] Block function menu             [`F9`] Reformat text to end of paragraph\n");
		if (noF5)
		{	wp1("[`F12`] Setup menu (change defaults)  [`F10`] Save text to file and continue\n");
		}
			wpn("[`F12`] Setup menu (change defaults)  [`F10`] Save text to file and continue\n");
		else
		{	wp1("[`F5`] Setup menu (change defaults)   [`F10`] Save text to file and continue\n");
		}
		wp1("`PgUp/PgDn`, `arrow keys` - scroll text  `Insert` - toggle insert/overwrite\n");     
		wp1("`Home-Up/Down` - to top, end of file   `Home-Left/Right` - left, right end of line\n");
		wp1("`Home-B` - word back                   `Home-F` - word forward\n");
		wp1("`Home-T` - erase word                  `Home-Y` - erase line\n");
		wp1("`Home-N` - insert line after cursor    `Home-L` - repeat last find or replace\n");
		wp1("`Home-C` - toggle case of character    `Home-I` - go to line number\n");
		wp1("`Home-O` - refresh screen              `Home-P` - enter control character\n");
			wpn("[`F5`] Setup menu (change defaults)   [`F10`] Save text to file and continue\n");
		wpn("`PgUp/PgDn`, `arrow keys` - scroll text  `Insert` - toggle insert/overwrite\n");     
		wpn("`Home-Up/Down` - to top, end of file   `Home-Left/Right` - left, right end of line\n");
		wpn("`Home-B` - word back                   `Home-F` - word forward\n");
		wpn("`Home-T` - erase word                  `Home-Y` - erase line\n");
		wpn("`Home-N` - insert line after cursor    `Home-L` - repeat last find or replace\n");
		wpn("`Home-C` - toggle case of character    `Home-I` - go to line number\n");
		wpn("`Home-O` - refresh screen              `Home-P` - enter control character\n");
		if (restricted != 0)
			wp1("`Home-!` - shell escape\n");
		wp1("`Backspace` - delete backwards         `Delete` - delete forwards\n");
			wpn("`Home-!` - shell escape\n");
		wpn("`Backspace` - delete backwards         `Delete` - delete forwards\n");
		wattrset(editwin, PROMPTATTR);
		wp1("Strike any key, or F3 to toggle help: ");
		wpn("Strike any key, or F3 to toggle help: ");
		wattrset(editwin, A_NORMAL);
		wrefresh(editwin);
		disp_mode = dpage;		/* Repaint text */


@@ 264,8 260,6 @@ FKey_scan(void)
		addtext(ch);
		break;
	}
	warnflag2 = 0;
	return;
}
/* -------------------------------------------------
 * Home key help


@@ 402,11 396,9 @@ setup(void)
	else
	{	wmove(editwin, 0, 0);
		if (restricted)
		{	wp1("`C`odes, `M`argin, `R`elease, `T`ab, `I`nfo");
		}
			wpn("`C`odes, `M`argin, `R`elease, `T`ab, `I`nfo");
		else
		{	wp1("`C`odes, `F`ilemode, `M`argin, `R`elease, `N`ame, `T`ab, `I`nfo");	
		}
			wpn("`C`odes, `F`ilemode, `M`argin, `R`elease, `N`ame, `T`ab, `I`nfo");	
	}
	result = promptkey("Setup command: ");
	if (result < 255)


@@ 485,11 477,9 @@ block(void)
	else
	{	wmove(editwin, 0, 0);
		if (restricted)
		{	wp1("`B`egin, `E`nd, `C`opy, `M`ove, `H`ide, `D`elete");	
		}
			wpn("`B`egin, `E`nd, `C`opy, `M`ove, `H`ide, `D`elete");	
		else
		{	wp1("`B`egin, `E`nd, `C`opy, `M`ove, `W`rite, `H`ide, `D`elete, `R`ead");	
		}
			wpn("`B`egin, `E`nd, `C`opy, `M`ove, `W`rite, `H`ide, `D`elete, `R`ead");	
	}
	result = promptkey("Block command: ");
	if (result < 255)

M funcs.c => funcs.c +25 -25
@@ 31,7 31,7 @@ blockhlp(int signum)
	else
	{	dohelp(htype, editwin);		/* Show in edit window */
		wattrset(editwin, PROMPTATTR);
		wp1("Strike any key: ");
		wpn("Strike any key: ");
		wattrset(editwin, A_NORMAL);
		wrefresh(editwin);
		waitkey();


@@ 48,7 48,7 @@ quickhlp(int signum)
	else
	{	dohelp(QUICK, editwin);		/* Show in edit window */
		wattrset(editwin, PROMPTATTR);
		wp1("Strike any key: ");
		wpn("Strike any key: ");
		wattrset(editwin, A_NORMAL);
		wrefresh(editwin);
		waitkey();


@@ 65,7 65,7 @@ onscrhlp(int signum)
	else
	{	dohelp(ONSCREEN, editwin);		/* Show in edit window */
		wattrset(editwin, PROMPTATTR);
		wp1("Strike any key: ");
		wpn("Strike any key: ");
		wattrset(editwin, A_NORMAL);
		wrefresh(editwin);
		waitkey();


@@ 80,17 80,17 @@ void
lookbusy(void)
{
	wclear(editwin);
wp1("and the annual outlook for such a plan seems reasonably promising. \n");
wp1("On the other hand, we will have to anticipate further adjustments \n");
wp1("to the entire project if current trends continue for the rest of \n");
wp1("the fiscal year.  What must be taken into account is the continual \n");
wp1("fluidity of the marketplace despite predictions of a coming period \n");
wp1("of stabilization.  While the firm has in the past dealt \n");
wp1("effectively with market forces beyond its control, in the future \n");
wp1("further attention must be paid to the possible side effects of \n");
wp1("these forces.\n\n");
wp1("Another aspect of the problem that must be taken into \n");
wp1("consideration is the continual growth in significance of nonmarket ");
	wpn("and the annual outlook for such a plan seems reasonably promising. \n");
	wpn("On the other hand, we will have to anticipate further adjustments \n");
	wpn("to the entire project if current trends continue for the rest of \n");
	wpn("the fiscal year.  What must be taken into account is the continual \n");
	wpn("fluidity of the marketplace despite predictions of a coming period \n");
	wpn("of stabilization.  While the firm has in the past dealt \n");
	wpn("effectively with market forces beyond its control, in the future \n");
	wpn("further attention must be paid to the possible side effects of \n");
	wpn("these forces.\n\n");
	wpn("Another aspect of the problem that must be taken into \n");
	wpn("consideration is the continual growth in significance of nonmarket ");
	wrefresh(editwin);
	waitkey();				/* Get key */
	disp_mode = dpage;		/* Repaint text */


@@ 191,20 191,20 @@ infofunc(void)
	status(0, "SUE version %s Copyright 1995 Point to Point", suerev);
	statprint(COLS - 23, "Author: carson@ppci.com");
	wmove(editwin, 0,0);
	wp4("           Editing: `%s` at line `%u` column `%u`\n", txtname, txt_x, txt_y);		/* show full name */
	wp2("          Modified: `%s`\n", mod ? "Yes" : "No");
	wp2("            Access: `%s`\n",
	wpn("           Editing: `%s` at line `%u` column `%u`\n", txtname, txt_x, txt_y);		/* show full name */
	wpn("          Modified: `%s`\n", mod ? "Yes" : "No");
	wpn("            Access: `%s`\n",
	      (restricted) ? "Restricted" : "Unrestricted");
	wp2("         File mode: `%s`\n", modestr);
	wp2("      Right margin: `%d`\n", rt_marg);
	wp2("    Hard tab width: `%d`\n", tabdef);
	wp2("Control characters: `%s`\n", cntlflag ? "On" : "Off");
	wp3("      Memory usage: `%ld` bytes `%ld` free\n",
	wpn("         File mode: `%s`\n", modestr);
	wpn("      Right margin: `%d`\n", rt_marg);
	wpn("    Hard tab width: `%d`\n", tabdef);
	wpn("Control characters: `%s`\n", cntlflag ? "On" : "Off");
	wpn("      Memory usage: `%ld` bytes `%ld` free\n",
	     gap_beg - txt_beg + txt_end - gap_end, gap_end - gap_beg - 1);
	wp2("         Baud rate: `%d`\n", baudrate());
	wp2("     Terminal type: `%s`\n", longname());
	wpn("         Baud rate: `%d`\n", baudrate());
	wpn("     Terminal type: `%s`\n", longname());
	wattrset(editwin, PROMPTATTR);
	wp1("    Strike any key: ");
	wpn("    Strike any key: ");
	wattrset(editwin, A_NORMAL);
	wrefresh(editwin);
	waitkey();					/* Get key */

M sue.h => sue.h +5 -7
@@ 352,10 352,8 @@ void edit_init(char *v_name);

/* ===================== GLOBAL MACROS ==================== */

#define wp1(str1) wclrtoeol(editwin); xwprintw(editwin, str1)
#define wp2(str1, str2) wclrtoeol(editwin); xwprintw(editwin, str1, str2)
#define wp3(str1, str2, str3) wclrtoeol(editwin); \
	xwprintw(editwin, str1, str2, str3)
#define wp4(str1, str2, str3, str4) wclrtoeol(editwin); \
	xwprintw(editwin, str1, str2, str3, str4)

#define wpn(...) \
	do { \
		wclrtoeol(editwin); \
		xwprintw(editwin, __VA_ARGS__); \
	} while (0)