static void acs_display() /* display the ACS character set */ { int i, j; erase(); attron(A_BOLD); mvaddstr(0, 20, "Display of the ACS Character Set"); attroff(A_BOLD); refresh(); #define ACSY 2 mvaddstr(ACSY + 0, 0, "ACS_ULCORNER: "); addch(ACS_ULCORNER); mvaddstr(ACSY + 1, 0, "ACS_LLCORNER: "); addch(ACS_LLCORNER); mvaddstr(ACSY + 2, 0, "ACS_URCORNER: "); addch(ACS_URCORNER); mvaddstr(ACSY + 3, 0, "ACS_LRCORNER: "); addch(ACS_LRCORNER); mvaddstr(ACSY + 4, 0, "ACS_RTEE: "); addch(ACS_RTEE); mvaddstr(ACSY + 5, 0, "ACS_LTEE: "); addch(ACS_LTEE); mvaddstr(ACSY + 6, 0, "ACS_BTEE: "); addch(ACS_BTEE); mvaddstr(ACSY + 7, 0, "ACS_TTEE: "); addch(ACS_TTEE); mvaddstr(ACSY + 8, 0, "ACS_HLINE: "); addch(ACS_HLINE); mvaddstr(ACSY + 9, 0, "ACS_VLINE: "); addch(ACS_VLINE); mvaddstr(ACSY + 10,0, "ACS_PLUS: "); addch(ACS_PLUS); mvaddstr(ACSY + 11,0, "ACS_S1: "); addch(ACS_S1); mvaddstr(ACSY + 12,0, "ACS_S9: "); addch(ACS_S9); mvaddstr(ACSY + 0, 40, "ACS_DIAMOND: "); addch(ACS_DIAMOND); mvaddstr(ACSY + 1, 40, "ACS_CKBOARD: "); addch(ACS_CKBOARD); mvaddstr(ACSY + 2, 40, "ACS_DEGREE: "); addch(ACS_DEGREE); mvaddstr(ACSY + 3, 40, "ACS_PLMINUS: "); addch(ACS_PLMINUS); mvaddstr(ACSY + 4, 40, "ACS_BULLET: "); addch(ACS_BULLET); mvaddstr(ACSY + 5, 40, "ACS_LARROW: "); addch(ACS_LARROW); mvaddstr(ACSY + 6, 40, "ACS_RARROW: "); addch(ACS_RARROW); mvaddstr(ACSY + 7, 40, "ACS_DARROW: "); addch(ACS_DARROW); mvaddstr(ACSY + 8, 40, "ACS_UARROW: "); addch(ACS_UARROW); mvaddstr(ACSY + 9, 40, "ACS_BOARD: "); addch(ACS_BOARD); mvaddstr(ACSY + 10,40, "ACS_LANTERN: "); addch(ACS_LANTERN); mvaddstr(ACSY + 11,40, "ACS_BLOCK: "); addch(ACS_BLOCK); #define HYBASE (ACSY + 13) mvprintw(HYBASE + 1, 0, "High-half characters via echochar:\n"); for (i = 0; i < 4; i++) { move(HYBASE + i + 3, 24); for (j = 0; j < 32; j++) echochar(128 + 32 * i + j); } move(LINES - 1, 0); addstr("Press any key to continue... "); (void) getch(); erase(); endwin(); }
static void draw(int x, int y, bool forward) { if (!forward) { move(y * 2 + 1, x * 2 + 1); echochar(' '); } else attron(A_REVERSE); if (maze[y][x].from == 1) { move(y * 2 + 1, x * 2 + 1 - 1); echochar(' '); } else if (maze[y][x].from == -1) { move(y * 2 + 1, x * 2 + 1 + 1); echochar(' '); } else if (maze[y][x].from == width) { move(y * 2 + 1 - 1, x * 2 + 1); echochar(' '); } else if (maze[y][x].from == -width) { move(y * 2 + 1 + 1, x * 2 + 1); echochar(' '); } if (forward) { usleep(delay); move(y * 2 + 1, x * 2 + 1); echochar(' '); usleep(delay); attroff(A_REVERSE); } }
int getpasswd( char *passwd, int size ) { int c; int n = 0; printf("Please Input password:"******"*"); passwd[n++] = c; } } while ( c != '\n' && n < size - 1 ); passwd[n] = '\0'; return n; }
/* * yet another purkka by jaakko .. * (no mvgetnstr support in jaakko's ncurses) */ void liima_mvgetnstr(int y, int x, char *buf, int maxlen) { int ch, curlen; curlen = 0; memset(buf, 0, maxlen + 1); for (ch = 0; ch != 10;) { mvaddstr(y, x + curlen, " "); move(y, x); if (curlen) addstr(buf); refresh(); switch (ch = getch()) { case KEY_BACKSPACE: case 4: /* EOT */ case 8: /* BS */ case 127: /* DEL */ if (curlen) { echochar(ch); curlen--; buf[curlen] = '\0'; } break; case 10: break; case 27: /* ESC */ flushinp(); break; default: if (curlen != maxlen && !iscntrl(ch)) buf[curlen++] = ch; break; } } }
static char * getl() { char *ret; int i, c; ret = malloc(80); (void) flushinp(); for(i = 0; i < 80; i++){ c = getch(); if(c == KEY_BACKSPACE){ (void) ungetch(c); continue; } if(c == 13){ goto end; } (void) echochar(c); ret[i] = c; } end: ret[i++] = '\0'; return ret; }
void eputchars(const char *str) { while(*str) { echochar(*str); str++; } }
int window_new_identity_run_command (int c) { int y, x; getmaxyx (stdscr, y, x); if (gui_window_new_identity.x1 == -999) { } else x = gui_window_new_identity.x1; switch (c) { case KEY_DC: delch (); break; case KEY_BACKSPACE: case 127: if (active_gui->xcursor > 10) { int xcur, ycur; active_gui->xcursor--; getyx (stdscr, ycur, xcur); move (ycur, xcur - 1); delch (); } break; case '\n': case '\r': case KEY_ENTER: case KEY_DOWN: if (gui_window_new_identity.ycursor < 3) { gui_window_new_identity.ycursor++; gui_window_new_identity.xcursor = 10; } break; case KEY_UP: if (gui_window_new_identity.ycursor > 0) { gui_window_new_identity.ycursor--; gui_window_new_identity.xcursor = 10; } break; case KEY_RIGHT: if (gui_window_new_identity.xcursor < (x - gui_window_new_identity.x0 - 1)) gui_window_new_identity.xcursor++; break; case KEY_LEFT: if (gui_window_new_identity.xcursor > 0) gui_window_new_identity.xcursor--; break; /* case 20: *//* Ctrl-T */ case 1: /* Ctrl-A */ { int ycur = gui_window_new_identity.y0; int xcur = gui_window_new_identity.x0 + 10; char sipurl[200]; char telurl[200]; char email[200]; char phone[200]; mvinnstr (ycur, xcur, sipurl, x - gui_window_new_identity.x0 - 10); ycur++; mvinnstr (ycur, xcur, telurl, x - gui_window_new_identity.x0 - 10); ycur++; mvinnstr (ycur, xcur, email, x - gui_window_new_identity.x0 - 10); ycur++; mvinnstr (ycur, xcur, phone, x - gui_window_new_identity.x0 - 10); _josua_add_contact (sipurl, telurl, email, phone); /* mvinnstr(ycur, xcur, tmp, 199); */ } break; case 4: /* Ctrl-D */ { char buf[200]; attrset (COLOR_PAIR (0)); snprintf (buf, 199, "%199.199s", " "); mvaddnstr (gui_window_new_identity.y0 + gui_window_new_identity.ycursor, gui_window_new_identity.x0 + 10, buf, x - gui_window_new_identity.x0 - 10 - 1); gui_window_new_identity.xcursor = 10; } break; case 5: /* Ctrl-E */ gui_window_new_identity.xcursor = 10; gui_window_new_identity.ycursor = 0; window_new_identity_print (); break; default: /* fprintf(stderr, "c=%i", c); exit(0); */ if (gui_window_new_identity.xcursor < (x - gui_window_new_identity.x0 - 1)) { gui_window_new_identity.xcursor++; attrset (COLOR_PAIR (0)); echochar (c); } else beep (); return -1; } return 0; }
int run_access (newts_nfref *ref) { List access_list; short changed = FALSE; short redraw = TRUE; int c; int first = 0; int entries; entries = get_access_list (ref, &access_list); while (1) { if (redraw) display_access (&access_list, first, entries); redraw = FALSE; mvprintw (LINES - 2, 0, _("Option: ")); refresh (); c = getch (); switch (c) { case '?': access_help (); /* Fall through. */ case 'r': /* Redraw the screen. */ case '\f': redraw = TRUE; break; case '!': redraw = TRUE; spawn_subshell (); break; case 's': move (LINES - 2, 0); clrtoeol (); printw (_("Sorting...")); refresh (); list_merge_sort (&access_list); redraw = TRUE; break; case 'Q': /* Quit without saving. */ case 'K': list_destroy (&access_list); return 0; case 'q': case 'k': if (changed) { list_merge_sort (&access_list); write_access_list (ref, &access_list); } list_destroy (&access_list); return 0; case '-': case KEY_UP: case KEY_PPAGE: first -= c == KEY_UP ? 1 : (LINES - 6) / 2 - 1; if (first < 0) first = 0; redraw = TRUE; break; case '+': case KEY_DOWN: case KEY_NPAGE: first += c == KEY_DOWN ? 1 : (LINES - 6) / 2 - 1; if (first >= entries - (LINES - 6) / 2) { first = entries - (LINES - 6) - 3; if (first < 0) first = 0; } redraw = TRUE; break; case 'i': /* Insert new entries. */ { char *persistent_error = NULL; short stop = FALSE; while (entries < NPERMS && !stop) { ListNode *node; struct access *access_entry; char *temp, *name, *prompt; int key, i; int y, x; enum newts_access_scopes scope; int scope_is_set = FALSE; int mode; short restart = FALSE; short advice_displayed = FALSE; if (traditional) mvprintw (LINES - 5, 39, _("Entry type: ")); else { clear (); display_access (&access_list, first, entries); if (persistent_error != NULL) { move (LINES - 3, 0); clrtoeol (); printw ("%s", persistent_error); persistent_error = NULL; } move (LINES - 2, 0); clrtoeol (); printw (_("Entry type: ")); } refresh (); if (!traditional) advice_displayed = FALSE; getyx (stdscr, y, x); while (scope_is_set == FALSE) { key = getch (); if (key == '\n' || key == '\r' || key == KEY_ENTER || key == 'q' || key == 'k') { if (traditional && (key == 'k' || key == 'q')) echochar (key); stop = TRUE; break; } switch (key) { case 'u': if (traditional) { echochar (key); move (y, x); } scope = SCOPE_USER; scope_is_set = TRUE; break; case 'g': if (traditional) { echochar (key); move (y, x); } scope = SCOPE_GROUP; scope_is_set = TRUE; break; case 's': if (traditional) { echochar (key); move (y, x); } scope = SCOPE_SYSTEM; scope_is_set = TRUE; break; case KEY_RESIZE: break; case EOF: clear (); display_access (&access_list, first, entries); if (traditional) { if (advice_displayed) mvprintw (LINES - 5, 54, "(u,g,s, q,k,<cr>)"); move (LINES - 5, 51); } else { if (advice_displayed) mvprintw (LINES - 3, 0, _("Please enter 'u', 'g', or 's'; or " "'q', 'k', or <RET> to exit.")); mvprintw (LINES - 2, 0, _("Entry type: ")); } refresh (); break; default: advice_displayed = TRUE; if (traditional) { mvprintw (LINES - 5, 54, "(u,g,s, q,k,<cr>)"); move (LINES - 5, 51); } else { move (LINES - 3, 0); clrtoeol (); printw (_("Please enter 'u', 'g', or 's'; or 'q', " "'k', or <RET> to exit.")); move (LINES - 2, 0); clrtoeol (); printw (_("Entry type: ")); } refresh (); break; } } if (stop) continue; if (traditional) { prompt = newts_nmalloc (strlen (_("Name: ")) + 40, sizeof (char)); strcpy (prompt, " "); strncat (prompt, _("Name: "), strlen (_("Name: ")) + 1); move (LINES - 4, 0); clrtoeol (); } else { move (LINES - 3, 0); clrtoeol (); prompt = newts_strdup (scope == SCOPE_SYSTEM ? _("System name: ") : scope == SCOPE_GROUP ? _("Group name: ") : _("User name: ")); move (LINES - 2, 0); clrtoeol (); } refresh (); temp = gl_getline (prompt); temp[strlen (temp) - 1] = '\0'; newts_free (prompt); if (strlen (temp) == 0) continue; name = newts_strdup (temp); gl_histadd (name); if (scope == SCOPE_USER) { if (strcasecmp (name, "other") != 0) { struct passwd *pw = getpwnam (name); if (pw == NULL) { if (traditional) { move (LINES - 3, 0); clrtoeol (); mvprintw (LINES - 3, 39, _("--No such user--")); } else persistent_error = _("No such user."); continue; } endpwent (); } } if (scope == SCOPE_GROUP) { if (strcasecmp (name, "other") != 0) { struct group *gp = getgrnam (name); if (gp == NULL) { if (traditional) { move (LINES - 3, 0); clrtoeol (); mvprintw (LINES - 3, 39, _("--No such group--")); } else persistent_error = _("No such group."); continue; } endgrent (); } } node = list_head (&access_list); for (i=0; i<entries; i++) { access_entry = (struct access *) list_data (node); if (access_scope (access_entry) == scope && strcmp (access_name (access_entry), name) == 0) { if (traditional) { move (LINES - 3, 0); clrtoeol (); mvprintw (LINES - 3, 39, _("%s entry exists"), name); } else persistent_error = scope == SCOPE_USER ? _("User already exists in " "permission table.") : (scope == SCOPE_GROUP ? _("Group already exists in " "permission table.") : _("System already exists in permission table.")); restart = TRUE; continue; } node = list_next (node); if (node == NULL) continue; } if (restart) continue; { struct access *new_access = access_alloc (); access_set_permissions (new_access, READ | WRITE | REPLY); access_set_scope (new_access, scope); access_set_name (new_access, name); get_mode (new_access, &access_list, first, entries); list_insert_sorted (&access_list, (void *) new_access); } newts_free (name); entries++; redraw = TRUE; changed = TRUE; clear (); display_access (&access_list, first, entries); } if (!traditional) redraw = TRUE; break; } case 'd': /* Delete existing entries. */ { ListNode *node, *prev; struct access *data; int key, number, i; move (LINES - 2, 0); clrtoeol (); if (traditional) printw ("%s", _("Delete entry #: ")); else printw ("%s", _("Delete entry number: ")); key = getch (); while (key != '\n' && key != '\r' && key != KEY_ENTER && (key < '1' || key > '9')) key = getch (); if (key == '\n' || key == '\r' || key == KEY_ENTER) { redraw = TRUE; break; } number = get_number (key, entries); if (number < 0) { redraw = TRUE; break; } if (number > entries || key < '0' || key > '9' || number == 0) { clear (); display_access (&access_list, first, entries); if (traditional) { move (LINES - 1, 0); clrtoeol (); printw ("%s", _("Bad entry")); } else { move (LINES - 3, 0); clrtoeol (); printw ("%s", _("Invalid entry.")); } break; } number--; /* Adjust to base zero. */ prev = NULL; node = list_head (&access_list); for (i=0; i<number; i++) { prev = node; node = list_next (prev); } data = (struct access *) list_data (node); if (data->scope == SCOPE_USER && strcmp (data->name, username) == 0) { clear (); display_access (&access_list, first, entries); if (traditional) { move (LINES - 1, 0); clrtoeol (); printw ("%s", _(" Can't Delete self")); } else { move (LINES - 3, 0); clrtoeol (); printw ("%s", _("Can't delete own entry.")); } break; } list_remove_next (&access_list, prev, NULL); entries--; changed = TRUE; redraw = TRUE; break; } case 'm': /* Modify existing entries. */ { ListNode *node; struct access *existing_entry; int key, number, i; move (LINES - 2, 0); clrtoeol (); if (traditional) printw ("%s", _("Modify entry #: ")); else printw ("%s", _("Modify entry number: ")); key = getch (); while (key != '\n' && key != '\r' && key != KEY_ENTER && (key < '1' || key > '9')) key = getch (); if (key == '\n' || key == '\r' || key == KEY_ENTER) { redraw = TRUE; break; } number = get_number (key, entries); if (number < 0) { redraw = TRUE; break; } if (number > entries || key < '0' || key > '9' || number == 0) { clear (); display_access (&access_list, first, entries); if (traditional) { move (LINES - 1, 0); clrtoeol (); printw ("%s", _("Bad entry")); } else { move (LINES - 3, 0); clrtoeol (); printw ("%s", _("Invalid entry.")); } break; } number--; /* Adjust to base zero. */ node = list_head (&access_list); for (i=0; i<number; i++) { node = list_next (node); } existing_entry = (struct access *) list_data (node); get_mode (existing_entry, &access_list, first, entries); changed = TRUE; redraw = TRUE; break; } case '\004': list_destroy (&access_list); return QUITNOSEQ; case 'z': list_destroy (&access_list); return QUITSEQ; default: beep (); break; } } return 0; }
static void get_mode (struct access *access_entry, List *access_list, int first, int entries) { int c; unsigned new_mode = access_permissions (access_entry); if (!traditional) { clear (); display_access (access_list, first, entries); } while (1) { if (traditional) { move (LINES - 3, 39); clrtoeol (); addch (' '); printw (_("Mode: %s"), permmap[new_mode]); move (LINES - 2, 39); printw (_("Mods: ")); } else { move (LINES - 2, 0); clrtoeol (); printw (_("Mode: %s"), permmap[new_mode]); } refresh (); c = getch (); if (traditional) echochar (c); switch (c) { case KEY_RESIZE: break; case '!': spawn_subshell (); /* Fallthrough */ case '?': if (c == '?') getmode_help (); /* Fallthrough */ case EOF: clear (); display_access (access_list, first, entries); if (traditional) { move (LINES - 3, 39); clrtoeol (); addch (' '); printw (_("Mode: %s"), permmap[new_mode]); move (LINES - 2, 39); printw (_("Mods: ")); } else { move (LINES - 2, 0); clrtoeol (); printw (_("Mode: %s"), permmap[new_mode]); } refresh (); break; case 'a': if (new_mode & WRITE) break; if (new_mode & REPLY) new_mode &= ~REPLY; else new_mode |= REPLY; break; case 'r': if (new_mode & DIRECTOR) break; if (new_mode & READ) new_mode &= ~READ; else new_mode |= READ; break; case 'w': if (new_mode & DIRECTOR) break; if (new_mode & WRITE) new_mode &= ~WRITE; else new_mode |= WRITE | REPLY; break; case 'd': if (new_mode & OWNER) break; if (new_mode & DIRECTOR) new_mode &= ~DIRECTOR; else new_mode |= DIRECTOR | READ | WRITE | REPLY; break; case 'n': new_mode = 0; break; case '\n': case '\r': case KEY_ENTER: case 'q': case 'k': access_set_permissions (access_entry, new_mode); return; case 'Q': case 'K': return; } } }
/* ARGSUSED */ static int isearch(int f GCC_UNUSED, int n) { static TBUFF *pat_save = 0; /* Saved copy of the old pattern str */ int status; /* Search status */ register int cpos; /* character number in search string */ register int c; /* current input character */ MARK curpos, curp; /* Current point on entry */ int init_direction; /* The initial search direction */ /* Initialize starting conditions */ cmd_reexecute = -1; /* We're not re-executing (yet?) */ itb_init(&cmd_buff, EOS); /* Init the command buffer */ /* Save the old pattern string */ (void) tb_copy(&pat_save, searchpat); curpos = DOT; /* Save the current pointer */ init_direction = n; /* Save the initial search direction */ ignorecase = window_b_val(curwp, MDIGNCASE); scanboundry(FALSE, DOT, FORWARD); /* keep scanner() finite */ /* This is a good place to start a re-execution: */ start_over: /* ask the user for the text of a pattern */ promptpattern("ISearch: "); status = TRUE; /* Assume everything's cool */ /* * Get the first character in the pattern. If we get an initial * Control-S or Control-R, re-use the old search string and find the * first occurrence */ c = kcod2key(get_char()); /* Get the first character */ if ((c == IS_FORWARD) || (c == IS_REVERSE)) { /* Reuse old search string? */ for (cpos = 0; cpos < (int) tb_length(searchpat); ++cpos) echochar(tb_values(searchpat)[cpos]); /* and re-echo the string */ curp = DOT; if (c == IS_REVERSE) { /* forward search? */ n = -1; /* No, search in reverse */ last_srch_direc = REVERSE; backchar(TRUE, 1); /* Be defensive about EOB */ } else { n = 1; /* Yes, search forward */ last_srch_direc = FORWARD; forwchar(TRUE, 1); } unget_char(); status = scanmore(searchpat, n); /* Do the search */ if (status != TRUE) DOT = curp; c = kcod2key(get_char()); /* Get another character */ } else { tb_init(&searchpat, EOS); } /* Top of the per character loop */ for_ever { /* ISearch per character loop */ /* Check for special characters, since they might change the * search to be done */ if (ABORTED(c) || c == '\r') /* search aborted? */ return (TRUE); /* end the search */ if (isbackspace(c)) c = '\b'; if (c == quotec) /* quote character? */ c = kcod2key(get_char()); /* Get the next char */ switch (c) { /* dispatch on the input char */ case IS_REVERSE: /* If backward search */ case IS_FORWARD: /* If forward search */ curp = DOT; if (c == IS_REVERSE) { /* forward search? */ last_srch_direc = REVERSE; n = -1; /* No, search in reverse */ backchar(TRUE, 1); /* Be defensive about * EOB */ } else { n = 1; /* Yes, search forward */ last_srch_direc = FORWARD; forwchar(TRUE, 1); } status = scanmore(searchpat, n); /* Do the search */ if (status != TRUE) DOT = curp; c = kcod2key(get_char()); /* Get the next char */ continue; /* Go continue with the search */ case '\t': /* Generically allowed */ case '\n': /* controlled characters */ break; /* Make sure we use it */ case '\b': /* or if a Rubout: */ if (itb_length(cmd_buff) <= 1) /* Anything to delete? */ return (TRUE); /* No, just exit */ unget_char(); DOT = curpos; /* Reset the pointer */ n = init_direction; /* Reset the search direction */ (void) tb_copy(&searchpat, pat_save); /* Restore the old search str */ cmd_reexecute = 0; /* Start the whole mess over */ goto start_over; /* Let it take care of itself */ /* Presumably a quasi-normal character comes here */ default: /* All other chars */ if (!isPrint(c)) { /* Is it printable? */ /* Nope. */ unkeystroke(c); /* Re-eat the char */ return (TRUE); /* And return the last status */ } } /* Switch */ /* I guess we got something to search for, so search for it */ tb_append(&searchpat, c); /* put the char in the buffer */ echochar(c); /* Echo the character */ if (!status) { /* If we lost last time */ kbd_alarm(); /* Feep again */ } else /* Otherwise, we must have won */ status = scanmore(searchpat, n); /* or find the next * match */ c = kcod2key(get_char()); /* Get the next char */ } /* for_ever */ }
isearch(f, n) { int status; /* Search status */ int col; /* prompt column */ register int cpos; /* character number in search string */ register int c; /* current input character */ char pat_save[NPAT]; /* Saved copy of the old pattern str */ LINE *curline; /* Current line on entry */ int curoff; /* Current offset on entry */ int init_direction; /* The initial search direction */ /* Initialize starting conditions */ cmd_reexecute = -1; /* We're not re-executing (yet?) */ cmd_offset = 0; /* Start at the beginning of the buff */ cmd_buff[0] = '\0'; /* Init the command buffer */ strncpy (pat_save, pat, NPAT); /* Save the old pattern string */ curline = curwp->w_dotp; /* Save the current line pointer */ curoff = curwp->w_doto; /* Save the current offset */ init_direction = n; /* Save the initial search direction */ /* This is a good place to start a re-execution: */ start_over: /* ask the user for the text of a pattern */ col = promptpattern("ISearch: "); /* Prompt, remember the col */ cpos = 0; /* Start afresh */ status = TRUE; /* Assume everything's cool */ /* Get the first character in the pattern. If we get an initial Control-S or Control-R, re-use the old search string and find the first occurrence */ c = get_char(); /* Get the first character */ if ((c == IS_FORWARD) || (c == IS_REVERSE) || (c == IS_VMSFORW)) /* Reuse old search string? */ { for (cpos = 0; pat[cpos] != 0; cpos++) /* Yup, find the length */ col = echochar(pat[cpos],col); /* and re-echo the string */ if (c == IS_REVERSE) { /* forward search? */ n = -1; /* No, search in reverse */ backchar (TRUE, 1); /* Be defensive about EOB */ } else n = 1; /* Yes, search forward */ status = scanmore(pat,n,status); /* Do the search */ c = get_char (); /* Get another character */ } /* Top of the per character loop */ for (;;) /* ISearch per character loop */ { /* Check for magic characters first: */ /* Most cases here change the search */ switch (c) /* dispatch on the input char */ { case IS_ABORT: /* If abort search request */ return(FALSE); /* Quit searching again */ case IS_REVERSE: /* If backward search */ case IS_FORWARD: /* If forward search */ case IS_VMSFORW: /* of either flavor */ if (c == IS_REVERSE) /* If reverse search */ n = -1; /* Set the reverse direction */ else /* Otherwise, */ n = 1; /* go forward */ status = scanmore(pat,n,TRUE); /* Start the search again */ c = get_char (); /* Get the next char */ continue; /* Go continue with the search*/ case IS_QUIT: /* Want to quit searching? */ return (TRUE); /* Quit searching now */ case IS_NEWLINE: /* Carriage return */ c = '\n'; /* Make it a new line */ break; /* Make sure we use it */ case IS_QUOTE: /* Quote character */ case IS_VMSQUOTE: /* of either variety */ c = get_char (); /* Get the next char */ case IS_TAB: /* Generically allowed */ case '\n': /* controlled characters */ break; /* Make sure we use it */ case IS_BACKSP: /* If a backspace: */ case IS_RUBOUT: /* or if a Rubout: */ if (cmd_offset <= 1) /* Anything to delete? */ return (TRUE); /* No, just exit */ --cmd_offset; /* Back up over the Rubout */ cmd_buff[--cmd_offset] = '\0'; /* Yes, delete last char */ curwp->w_dotp = curline; /* Reset the line pointer */ curwp->w_doto = curoff; /* and the offset */ n = init_direction; /* Reset the search direction */ strncpy (pat, pat_save, NPAT); /* Restore the old search str */ cmd_reexecute = 0; /* Start the whole mess over */ goto start_over; /* Let it take care of itself */ /* Presumably a quasi-normal character comes here */ default: /* All other chars */ if (c < ' ') /* Is it printable? */ { /* Nope. */ reeat (c); /* Re-eat the char */ return (TRUE); /* And return the last status */ } } /* Switch */ /* I guess we got something to search for, so search for it */ pat[cpos++] = c; /* put the char in the buffer */ if (cpos >= NPAT) /* too many chars in string? */ { /* Yup. Complain about it */ mlwrite("? Search string too long"); return(TRUE); /* Return an error */ } pat[cpos] = 0; /* null terminate the buffer */ col = echochar(c,col); /* Echo the character */ if (!status) { /* If we lost last time */ (*term.t_putchar)(BELL); /* Feep again */ (*term.t_flush)(); /* see that the feep feeps */ } else /* Otherwise, we must have won*/ if (!(status = checknext(c,pat,n,status))) /* See if match */ status = scanmore(pat,n,TRUE); /* or find the next match */ c = get_char (); /* Get the next char */ } /* for {;;} */ }