/****************************************************************************
- * Copyright (c) 2007 Free Software Foundation, Inc. *
+ * Copyright 2020,2022 Thomas E. Dickey *
+ * Copyright 2007-2010,2017 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
* authorization. *
****************************************************************************/
/*
- * $Id: test_instr.c,v 1.4 2007/07/21 19:38:04 tom Exp $
+ * $Id: test_instr.c,v 1.12 2022/12/10 23:58:01 tom Exp $
*
* Author: Thomas E Dickey
*
static void
show_1st(WINDOW *win, int line, char *buffer)
{
- mvwaddstr(win, line, 5, buffer);
+ MvWAddStr(win, line, 5, buffer);
}
static void
}
static int
-test_inchs(int level, char **argv, WINDOW *chrwin, WINDOW *strwin)
+recursive_test(int level, char **argv, WINDOW *chrwin, WINDOW *strwin)
{
WINDOW *txtbox = 0;
WINDOW *txtwin = 0;
return FALSE;
}
+ *buffer = '\0';
if (level > 1) {
txtbox = newwin(LINES - BASE_Y, COLS - level, BASE_Y, level);
box(txtbox, 0, 0);
beep();
break;
case 'w':
- test_inchs(level + 1, argv, chrwin, strwin);
+ recursive_test(level + 1, argv, chrwin, strwin);
if (txtbox != 0) {
touchwin(txtbox);
wnoutrefresh(txtbox);
break;
}
- mvwprintw(chrwin, 0, 0, "line:");
+ MvWPrintw(chrwin, 0, 0, "line:");
wclrtoeol(chrwin);
if (txtwin != stdscr) {
}
wnoutrefresh(chrwin);
- mvwprintw(strwin, 0, 0, "%4d:", limit);
+ MvWPrintw(strwin, 0, 0, "%4d:", limit);
wclrtobot(strwin);
if (txtwin != stdscr) {
return TRUE;
}
+static void
+usage(int ok)
+{
+ static const char *msg[] =
+ {
+ "Usage: test_instr [options] [file1 [...]]"
+ ,""
+ ,USAGE_COMMON
+ };
+ size_t n;
+
+ for (n = 0; n < SIZEOF(msg); n++)
+ fprintf(stderr, "%s\n", msg[n]);
+
+ ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE);
+}
+/* *INDENT-OFF* */
+VERSION_COMMON()
+/* *INDENT-ON* */
+
int
main(int argc, char *argv[])
{
WINDOW *chrbox;
WINDOW *chrwin;
WINDOW *strwin;
+ int ch;
+
+ while ((ch = getopt(argc, argv, OPTS_COMMON)) != -1) {
+ switch (ch) {
+ case OPTS_VERSION:
+ show_version(argv);
+ ExitProgram(EXIT_SUCCESS);
+ default:
+ usage(ch == OPTS_USAGE);
+ /* NOTREACHED */
+ }
+ }
setlocale(LC_ALL, "");
- if (argc < 2) {
- fprintf(stderr, "usage: %s file\n", argv[0]);
- return EXIT_FAILURE;
- }
+ if (optind + 1 > argc)
+ usage(FALSE);
initscr();
chrwin = derwin(chrbox, 2, COLS - 2, 1, 1);
strwin = derwin(chrbox, 2, COLS - 2, 3, 1);
- test_inchs(1, argv, chrwin, strwin);
+ recursive_test(optind, argv, chrwin, strwin);
endwin();
ExitProgram(EXIT_SUCCESS);