void downLINE(RING * gbl, unsigned n) { gbl->curfile += n; if (gbl->curfile >= gbl->numfiles) gbl->curfile = gbl->numfiles - 1; if (gbl->curfile > vue->last_file) { unsigned savebase = vue->base_file; while (gbl->curfile > vue->last_file && (vue->last_file + 1) < gbl->numfiles) { vue->base_file += 1; setup_view(gbl); } #if defined(HAVE_WSCRL) && defined(HAVE_WSETSCRREG) if (vue->base_file > savebase && setscrreg((int) vue->base_row + 1, (int) vue->last_row - 1) != ERR) { scrl((int) (vue->base_file - savebase)); setscrreg(0, LINES - 1); } #endif showFILES(gbl, FALSE); } else showC(gbl); }
void cob_field_display (cob_field *f, cob_field *line, cob_field *column, cob_field *fgc, cob_field *bgc, cob_field *scroll, const int attr) { int sline; int scolumn; if (!cob_screen_initialized) { cob_screen_init (); } if (scroll) { sline = cob_get_int (scroll); if (attr & COB_SCREEN_SCROLL_DOWN) { sline = -sline; } scrollok (stdscr, 1); scrl (sline); scrollok (stdscr, 0); refresh (); } get_line_column (line, column, &sline, &scolumn); move (sline, scolumn); cob_screen_attr (fgc, bgc, attr); addnstr ((char *)f->data, (int)f->size); refresh (); }
/* * Move the cursor up/down the specified number of lines, scrolling * to a new screen if necessary. */ void upLINE(RING * gbl, unsigned n) { if (gbl->curfile < n) gbl->curfile = 0; else gbl->curfile -= n; if (gbl->curfile < vue->base_file) { unsigned savebase = vue->base_file; while (gbl->curfile < vue->base_file && vue->base_file > 0) { vue->base_file -= 1; setup_view(gbl); } #if defined(HAVE_WSCRL) && defined(HAVE_WSETSCRREG) if (vue->base_file < savebase && setscrreg((int) vue->base_row + 1, (int) vue->last_row - 1) != ERR) { scrl((int) (vue->base_file - savebase)); setscrreg(0, LINES - 1); } #endif showFILES(gbl, FALSE); } else { showC(gbl); } }
/* * Reposition by a given number of lines */ static int JumpBackwards(int *infile, int jump) { int savejump; int blank; int n; int page = NumP(1); savejump = jump = page - jump; n = TopOfPage(*infile, &blank); /* jump the requested number of lines */ if (jump > 0) { if (n == 0) { while ((blank = LineAt[n].blank) != 0) { n++; } } while (jump > 0) { if (++n >= max_lines) { return (-1); } if (blank && LineAt[n].blank) continue; blank = LineAt[n].blank; jump--; } } else { while (jump < 0) { if (--n < 0) { *infile = 0; /* take what we can get */ (void) JumpToLine(*infile); return (-1); } if (blank && LineAt[n].blank) continue; blank = LineAt[n].blank; jump++; } } #if defined(HAVE_WSCRL) && defined(HAVE_WSETSCRREG) if (jump != savejump && (n + NumP(1) < max_lines) && (jump - savejump) < NumP(1) && (savejump - jump) < NumP(1)) { int y, x; getyx(stdscr, y, x); move(LINES - 2, 0); setscrreg(mark_W + 1, LINES - 2); scrl(savejump - jump); setscrreg(0, LINES - 1); move(y, x); } #endif *infile = n; return JumpToLine(*infile); }
void Scrl ( int n ) { int retval; retval = scrl ( n ); if ( retval == ERR ) Fatal_failure ( "scrl\n" ); }
int main (void) { int x = 40, zufall, c = 0 , i; srand(79); initscr(); keypad(stdscr, TRUE); noecho(); scrollok(stdscr, TRUE); scroll(stdscr); while (c != QUIT) { scrl(1); for (i = 0; i < 5; ++i) { zufall = rand() % 79; mvaddch(20, zufall, '*'); mvprintw(0, 0, "'q' druecken fuer Quit | " "Taste fuer Start | " "<- nach links -> nach rechts"); mvprintw(1,0, "Position Raumschiff %d", x); } c = getch(); halfdelay(3); switch (c) { case LEFT: if (x < 1) x = 79; else --x; break; case RIGHT: if (x > 79) x = 1; else ++x; break; default: break; } print_raumschiff(x); } endwin(); return 0; }
/* cleanup: Invoked by the various err_xxx funtions when dying. * -------- */ void cleanup() { char *log_file, *tmp_log_file; int has_recv_data; ibuf_free(current_line); /* Cleanly scroll the screen up for a prompt */ scrl(1); move(LINES - 1, 0); printf("\n"); rline_write_history(rline, readline_history_path); /* The order of these is important. They each must restore the terminal * the way they found it. Thus, the order in which curses/readline is * started, is the reverse order in which they should be shutdown */ /* Shut down interface */ if_shutdown(); #if 0 if (masterfd != -1) util_free_tty(&masterfd, &slavefd, tty_name); #endif /* Finally, should display the errors. * TGDB guarentees the logger to be open at this point. * So, we can get the filename directly from the logger */ logger_get_file(logger, &tmp_log_file); log_file = strdup(tmp_log_file); logger_has_recv_data(logger, &has_recv_data); /* Shut down debugger */ tgdb_shutdown(tgdb); if (tty_set_attributes(STDIN_FILENO, &term_attributes) == -1) logger_write_pos(logger, __FILE__, __LINE__, "tty_reset error"); if (has_recv_data) fprintf(stderr, "CGDB had unexpected results, see %s for details.\n", log_file); free(log_file); log_file = NULL; }
/* * os_scroll_area * * Scroll a rectangular area of the screen up (units > 0) or down * (units < 0) and fill the empty space with the current background * colour. Top left coordinates are (1,1). The cursor stays put. * */ void os_scroll_area (int top, int left, int bottom, int right, int units) { top--; left--; bottom--; right--; if ((left == 0) && (right == h_screen_cols - 1)) { static int old_scroll_top = 0; static int old_scroll_bottom = 0; if (!((old_scroll_top == top) && (old_scroll_bottom == bottom))) { old_scroll_top = top; old_scroll_bottom = bottom; setscrreg(top, bottom); } scrollok(stdscr, TRUE); scrl(units); scrollok(stdscr, FALSE); } else { int row, col, x, y; chtype ch; getyx(stdscr, y, x); /* Must turn off attributes during copying. */ attrset(0); if (units > 0) { for (row = top; row <= bottom - units; row++) for (col = left; col <= right; col++) { ch = mvinch(row + units, col); mvaddch(row, col, ch); } } else if (units < 0) { for (row = bottom; row >= top - units; row--) for (col = left; col <= right; col++) { ch = mvinch(row + units, col); mvaddch(row, col, ch); } } /* Restore attributes. */ os_set_text_style(u_setup.current_text_style); move(y, x); } if (units > 0) os_erase_area(bottom - units + 2, left + 1, bottom + 1, right + 1, 0); else if (units < 0) os_erase_area(top + 1, left + 1, top - units, right + 1, 0); }/* os_scroll_area */
IoObject *IoCurses_scroll(IoCurses *self, IoObject *locals, IoMessage *m) { /*doc Curses scroll(num) Scrolls up num lines. num is optional and defaults to 1. Returns self. */ int num = 1; if (IoMessage_argCount(m) > 0) { num = IoNumber_asInt(IoMessage_locals_numberArgAt_(m, locals, 0)); } if (scrl(num) == ERR) { IoCurses_showError(self, m, "Curses.scroll", "Failed to scroll screen."); } return self; }
/** * Runs a command in the shell. The shell may be interactive, and CGDB * will be paused for the duration of the shell. Any leading stuff, like * 'shell ' or '!' should be removed prior to calling this function. * * \param command The command to run at the shell. Empty string or null * means to invoke an interactive shell. * * \return The exit status of the system() call. */ int run_shell_command(const char *command) { int rv; /* Cleanly scroll the screen up for a prompt */ scrl(1); move(LINES - 1, 0); printf("\n"); /* Put the terminal in cooked mode and turn on echo */ endwin(); tty_set_attributes(STDIN_FILENO, &term_attributes); /* NULL or empty string means invoke user's shell */ if (command == NULL || strlen(command) == 0) { /* Check for SHELL environment variable */ char *shell = getenv("SHELL"); if (shell == NULL) { /* Run /bin/sh instead */ rv = system("/bin/sh"); } else { rv = system(shell); } } else { /* Execute the command passed in via system() */ rv = system(command); } /* Press any key to continue... */ fprintf(stderr, "Hit ENTER to continue..."); while (fgetc(stdin) != '\n') { } /* Turn off echo and put the terminal back into raw mode */ tty_cbreak(STDIN_FILENO, &term_attributes); if_draw(); return rv; }
static TACommandVerdict scrl_cmd(TAThread thread, TAInputStream stream) { int n; int res; // Prepare n = readInt(&stream); START_TARGET_OPERATION(thread); // Execute res = scrl(n); END_TARGET_OPERATION(thread); // Response writeInt(thread, res); sendResponse(thread); return taDefaultVerdict; }
void cursormoved(file_t *file) { if(file->cursor_y >= file->scroll_y + h-1-3) { /* scroll screen up */ while(file->cursor_y >= file->scroll_y + h-1-h/3) { file->scroll_y++; if(current >= 0 && file == files[current]) { /* scroll screen */ scrollok(screen, TRUE); scrl(1); scrollok(screen, FALSE); /* draw bottom line */ if(h-2 + file->scroll_y < file->line_count) drawline(file, h-2 + file->scroll_y); drawmenu(); refresh(); napms(5); } } } if(file->cursor_y < file->scroll_y + 3 && file->scroll_y) { /* scroll screen down */ while(file->cursor_y < file->scroll_y + h/3 && file->scroll_y) { file->scroll_y--; if(current >= 0 && file == files[current]) { /* scroll screen */ scrollok(screen, TRUE); scrl(-1); scrollok(screen, FALSE); /* draw top line */ drawline(file, file->scroll_y); drawmenu(); refresh(); napms(5); } } } /* modify selection */ if(file->selected && ((file->cursor_x >= file->sel_begin_x && file->cursor_y == file->sel_begin_y) || file->cursor_y > file->sel_begin_y)) { file->sel_end_x = file->cursor_x; file->sel_end_y = file->cursor_y; if(current >= 0 && file == files[current]) drawscreen(); } if(current >= 0 && file == files[current]) drawpos(); }
cell pp_curs_scroll(cell x) { if (!Running) return UNSPECIFIC; scrl(integer_value("curs:scroll", car(x))); return UNSPECIFIC; }
int t_scrl(enum T_SCRL_DIR dir) { return scrl(dir); }
int main (void) { int x = 40, zufall, c = 0 , i; srand(79); initscr(); if (has_colors() == TRUE) start_color(); else exit(EXIT_FAILURE); keypad(stdscr, TRUE); noecho(); scrollok(stdscr, TRUE); scroll(stdscr); // color pairs init_pair(1, COLOR_YELLOW, COLOR_BLACK); init_pair(2, COLOR_RED, COLOR_RED); init_pair(3, COLOR_BLUE, COLOR_BLACK); init_pair(4, COLOR_BLACK, COLOR_BLUE); while (c != QUIT) { scrl(1); for (i = 0; i < 5; ++i) { zufall = rand() % 79; attrset(A_DIM | COLOR_PAIR(1)); mvaddch(20, zufall, '*'); attrset(A_UNDERLINE | A_BOLD | COLOR_PAIR(4)); mvprintw(0, 0, "'q' druecken fuer Quit | " "Taste fuer Start | " "<- nach links -> nach rechts"); mvprintw(1,0, "Position Raumschiff %d", x); } c = getch(); halfdelay(3); switch (c) { case LEFT: if (x < 1) x = 79; else --x; break; case RIGHT: if (x > 79) x = 1; else ++x; break; default: break; } print_raumschiff(x); } endwin(); return 0; }
void cob_field_accept (cob_field *f, cob_field *line, cob_field *column, cob_field *fgc, cob_field *bgc, cob_field *scroll, const int attr) { unsigned char *p; unsigned char *p2; size_t count; int keyp; int fret; int sline; int scolumn; int cline; int ccolumn; int rightpos; int ateof; int move_char; int prompt_char; /* Initialize the screen. */ if (!cob_screen_initialized) { cob_screen_init (); } if (scroll) { keyp = cob_get_int (scroll); if (attr & COB_SCREEN_SCROLL_DOWN) { keyp = -keyp; } scrollok (stdscr, 1); scrl (keyp); scrollok (stdscr, 0); refresh (); } cob_exception_code = 0; /* Start line and column. */ get_line_column (line, column, &sline, &scolumn); move (sline, scolumn); cob_screen_attr (fgc, bgc, attr); /* Prompt characters. */ p = f->data; for (count = 0; count < f->size; count++) { if (attr & COB_SCREEN_SECURE) { addch ('*'); } else if (attr & COB_SCREEN_UPDATE) { fret = *p++; addch ((unsigned int)fret); } else if (COB_FIELD_IS_NUMERIC (f)) { addch ('0'); } else if (attr & COB_SCREEN_PROMPT) { addch ('_'); } else { addch (' '); } } move (sline, scolumn); /* Initialize field. */ if (!(attr & COB_SCREEN_UPDATE)) { if (COB_FIELD_IS_NUMERIC (f)) { cob_move (&cob_zero, f); } else { memset (f->data, ' ', f->size); } } fret = 0; ateof = 0; rightpos = scolumn + f->size - 1; p = f->data; /* Get characters from keyboard, processing each one. */ for (; ;) { /* Get current line, column. */ getyx (stdscr, cline, ccolumn); /* Trailing prompts. */ if (COB_FIELD_IS_NUMERIC (f)) { prompt_char = '0'; } else if (attr & COB_SCREEN_PROMPT) { prompt_char = '_'; } else { prompt_char = ' '; } for (count = rightpos; count > scolumn - 1; count--) { /* Get character */ p2 = f->data + count - scolumn; move_char = *p2; /* Field prompts. */ if (COB_FIELD_IS_NUMERIC (f)) { /* Numeric prompt zeros. */ if (move_char == '0') { move (cline, count); addch (prompt_char); } else { /* Switch to remove prompts from within field. */ if (attr & COB_SCREEN_SECURE) { prompt_char = '*'; } else { prompt_char = '0'; } } } else { /* Alpha prompts. */ if (move_char == ' ') { move (cline, count); addch (prompt_char); } else { /* Switch to remove prompts from within field. */ if (attr & COB_SCREEN_SECURE) { prompt_char = '*'; } else { prompt_char = ' '; } } } } /* Cursor to current column. */ move (cline, ccolumn); /* Refresh screen. */ refresh (); errno = 0; /* Get a character. */ keyp = getch (); /* Key error. */ if (keyp == ERR) { fret = 8001; goto field_return; } /* Function keys F1 through F64 */ if (keyp > KEY_F0 && keyp < KEY_F(65)) { fret = 1000 + keyp - KEY_F0; goto field_return; } cob_convert_key (&keyp, 1U); if (keyp <= 0) { (void)flushinp (); beep (); continue; } switch (keyp) { case KEY_ENTER: goto field_return; case KEY_PPAGE: /* Page up. */ fret = 2001; goto field_return; case KEY_NPAGE: /* Page down. */ fret = 2002; goto field_return; case KEY_UP: /* Up arrow. */ fret = 2003; goto field_return; case KEY_DOWN: /* Down arrow. */ fret = 2004; goto field_return; case KEY_PRINT: /* Print key. */ /* pdcurses not returning this ? */ fret = 2006; goto field_return; case 033: /* Escape key. */ fret = 2005; goto field_return; case KEY_STAB: /* Tab key. */ fret = 2007; goto field_return; case KEY_BTAB: /* Back tab key. */ fret = 2008; goto field_return; default: break; } getyx (stdscr, cline, ccolumn); switch (keyp) { case KEY_IC: /* Insert key toggle. If off turn on, if on turn off. */ if (insert_mode == 0) { insert_mode = 1; /* on */ /* to do, needs vertical bar cursor */ /* this doesn't seem to work */ count = curs_set(1); } else { insert_mode = 0; /* off */ /* to do, needs square cursor */ /* this doesn't seem to work */ count = curs_set(2); } continue; case KEY_DC: /* Delete key. */ /* Delete character, move remainder left. */ for (count = ccolumn; count < rightpos; count++) { /* Get character one position to right. */ p2 = f->data + count - scolumn + 1; move_char = *p2; /* Move the character left. */ p2 = f->data + count - scolumn; *p2 = move_char; /* Update screen with moved character. */ move (cline, count); if (attr & COB_SCREEN_SECURE) { addch ('*'); } else { addch (move_char); } } /* Put space as the right most character. */ p2 = f->data + f->size - 1; if (COB_FIELD_IS_NUMERIC (f)) { *p2 = '0'; } else { *p2 = ' '; } /* Put cursor back to original position. */ move (cline, ccolumn); continue; case KEY_BACKSPACE: /* Backspace key. */ if (ccolumn > scolumn) { /* Shift remainder left with cursor. */ for (count = ccolumn; count < rightpos + 1; count++) { /* Get character. */ p2 = f->data + count - scolumn ; move_char = *p2; /* Move the character left. */ p2 = f->data + count - scolumn - 1; *p2 = move_char; /* Update screen with moved character. */ move (cline, count - 1); if (attr & COB_SCREEN_SECURE) { addch ('*'); } else { addch (move_char); } } /* Put space as the right most character. */ p2 = f->data + f->size - 1; if (COB_FIELD_IS_NUMERIC (f)) { *p2 = '0'; } else { *p2 = ' '; } /* Move cursor left one from current. */ ccolumn--; move (cline, ccolumn); p--; } ateof = 0; continue; case KEY_HOME: /* Home key, move to start of field. */ move (sline, scolumn); p = f->data; ateof = 0; continue; case KEY_END: /* End key. */ /* Prepare for empty field. */ ccolumn = scolumn; move_char = ' '; /* Find non blank from right. */ for (count = rightpos; count >= scolumn; count--) { /* Get character */ p2 = f->data + count - scolumn; move_char = *p2; /* Non blank stop. */ if (move_char != ' ') { ccolumn = count; count = scolumn; } } /* Cursor to first blank after. */ if (move_char != ' ' && ccolumn != rightpos) { ccolumn++; } move (cline, ccolumn); p = f->data + ccolumn - scolumn; ateof = 0; continue; case KEY_LEFT: /* Left arrow. */ if (ccolumn > scolumn) { ccolumn--; move (cline, ccolumn); p = f->data + ccolumn - scolumn; continue; } continue; case KEY_RIGHT: /* Right arrow. */ if (ccolumn < rightpos) { ccolumn++; move (cline, ccolumn); p = f->data + ccolumn - scolumn; continue; } continue; default: break; } /* Printable character. */ if (keyp > 037 && keyp < (int)A_CHARTEXT) { /* Numeric field check. */ if (COB_FIELD_IS_NUMERIC (f)) { if (keyp < '0' || keyp > '9') { beep (); continue; } } /* Insert character. */ if (insert_mode == 1) { /* Move remainder to the right. */ for (count = rightpos; count > ccolumn - 1; count--) { /* Get character */ p2 = f->data + count - scolumn - 1; move_char = *p2; /* Move character one right. */ p2 = f->data + count - scolumn; *p2 = move_char; /* Update screen with moved character. */ if (count > scolumn) { move (cline, count); if (move_char != ' ') { if (attr & COB_SCREEN_SECURE) { addch ('*'); } else { addch (move_char); } } } } move (cline, ccolumn); } *p = (unsigned char)keyp; /* Display character or '*' if secure. */ if (attr & COB_SCREEN_SECURE) { addch ('*'); } else { addch ((unsigned int)keyp); } if (ccolumn == rightpos) { /* Auto-skip at end of field. */ if (attr & COB_SCREEN_AUTO) { break; } move (cline, ccolumn); if (ateof) { beep (); } else { ateof = 1; } } else { p++; } continue; } beep (); } field_return: refresh (); cob_check_pos_status (fret); }