luna draw_buffer(int id) { int SCR_W, SCR_H, line_number_offset; getmaxyx(stdscr, SCR_H, SCR_W); Buffer *target = get_buffer(id); if (target == NULL) { return INVALID_ID; } else { line_number_offset = floor(log10(abs(target->n_rows + 1))) + 2; char line_number[line_number_offset + 1]; int i = 0; int rawrow; for(rawrow = 0; rawrow < SCR_H; rawrow++) { if (i >= target->n_rows) { mvaddch(rawrow, 0, '~'); } else { sprintf(line_number, "%d", i + 1); mvaddch(rawrow, line_number_offset - 1, '|'); mvprintw(rawrow, 0, line_number); if (target->rows[i].length > 0) { mvprintw(rawrow, line_number_offset, target->rows[i].content); } if (target->rows[i].length > SCR_W) { rawrow++; } } i++; } draw_cursor(id, line_number_offset); draw_status_line(); } return SUCCESS; }
/*********************************************************************** ** draws an array passed to draw_array(...) from 0,0 to height,width ** ***********************************************************************/ void draw_array(struct gamehandle *myrill, struct cell *array, int height, int width) { int y, x; werase(mapwin); werase(statuswin); /* ** draw the array */ for (y = 0; y < height; y++) { for (x = 0; x < width; x++) { if ((array[y * width + x].flag & (F_MAPPED | F_VISIBLE)) != 0) mvwprintw(mapwin, y, x, "%c", array[y * width + x].type); } } /* ** draw status line */ draw_status_line(myrill); /* ** update the curses window */ move(0, 0); refresh(); wrefresh(mapwin); wrefresh(statuswin); }
void term_redisplay(void) { size_t topline; Window *wp; cur_topline = topline = 0; calculate_start_column(cur_wp); for (wp = head_wp; wp != NULL; wp = wp->next) { if (wp == cur_wp) cur_topline = topline; draw_window(topline, wp); /* Draw the status line only if there is available space after the buffer text space. */ if (wp->fheight - wp->eheight > 0) draw_status_line(topline + wp->eheight, wp); topline += wp->fheight; } term_redraw_cursor(); }
void status_line(EVENT_MSG *msg,T_EVENT_ROOT **user_data) { T_EVENT_ROOT **p; static char st_line[256],oldline[256]={"\0"}; EVENT_MSG tg; static char recurse=1; if(msg->msg==E_INIT) { if (recurse) { T_EVENT_ROOT *p; recurse=0; send_message(E_ADD,E_IDLE,status_idle); send_message(E_ADD,E_REDRAW,status_idle); p=NULL; *user_data=p; draw_status_line(NULL); recurse=1; return; } else return; } shift_msg(msg,tg); if (tg.msg==E_REDRAW) { draw_status_line(oldline); return; } p=user_data; if (tg.msg==E_IDLE) { EVENT_MSG msg; msg.msg=E_IDLE; msg.data=&st_line; enter_event(p,&msg); if (strcmp(st_line,oldline)) { draw_status_line(st_line); strcpy(oldline,st_line); } } else tree_basics(p,&tg); return; }
static void draw_window (size_t topline, Window wp) { size_t i, o; Region r; int highlight = calculate_highlight_region (wp, &r); /* Find the first line to display on the first screen line. */ for (o = buffer_start_of_line (get_window_bp (wp), window_o (wp)), i = get_window_topdelta (wp); i > 0 && o > 0; assert ((o = buffer_prev_line (get_window_bp (wp), o)) != SIZE_MAX), --i) ; /* Draw the window lines. */ size_t cur_tab_width = tab_width (get_window_bp (wp)); for (i = topline; i < get_window_eheight (wp) + topline; ++i) { /* Clear the line. */ term_move (i, 0); term_clrtoeol (); /* If at the end of the buffer, don't write any text. */ if (o == SIZE_MAX) continue; draw_line (i, get_window_start_column (wp), wp, o, r, highlight, cur_tab_width); if (get_window_start_column (wp) > 0) { term_move (i, 0); term_addstr("$"); } o = buffer_next_line (get_window_bp (wp), o); } set_window_all_displayed (wp, o >= get_buffer_size (get_window_bp (wp))); /* Draw the status line only if there is available space after the buffer text space. */ if (get_window_fheight (wp) - get_window_eheight (wp) > 0) draw_status_line (topline + get_window_eheight (wp), wp); }