void WDL_CursesEditor::draw(int lineidx) { attrset(A_NORMAL); if (lineidx >= 0) { int comment_state = GetCommentStateForLineStart(lineidx); WDL_FastString *s=m_text.Get(lineidx); if (s && lineidx >= m_offs_y && lineidx < m_offs_y+getVisibleLines()) { doDrawString(lineidx-m_offs_y+m_top_margin,0,lineidx,s->Get(),COLS,&comment_state, min(s->GetLength(),m_offs_x)); } return; } draw_top_line(); attrset(A_NORMAL); bkgdset(A_NORMAL); move(m_top_margin,0); clrtoeol(); int comment_state = GetCommentStateForLineStart(m_offs_y); const int VISIBLE_LINES = getVisibleLines(); for(int i=0;i<VISIBLE_LINES;i++) { int ln=i+m_offs_y; WDL_FastString *s=m_text.Get(ln); if(!s) { move(i+m_top_margin,0); clrtoeol(); continue; } doDrawString(i+m_top_margin,0,ln,s->Get(),COLS,&comment_state,min(m_offs_x,s->GetLength())); } // move(LINES-2,0); // clrtoeol(); if (m_bottom_margin>0) { attrset(m_color_bottomline); bkgdset(m_color_bottomline); if (m_selecting) { mvaddstr(LINES-1,0,"SELECTING - ESC-cancel, " "Ctrl+C,X,V, etc"); } else { draw_bottom_line(); } clrtoeol(); attrset(0); bkgdset(0); } }
void WDL_CursesEditor::draw(int lineidx) { const int VISIBLE_LINES = getVisibleLines(); int paney[2], paneh[2]; const int pane_divy=GetPaneDims(paney, paneh); #ifdef WDL_IS_FAKE_CURSES if (m_cursesCtx) { CURSES_INSTANCE->offs_y[0]=m_paneoffs_y[0]; CURSES_INSTANCE->offs_y[1]=m_paneoffs_y[1]; CURSES_INSTANCE->div_y=pane_divy; CURSES_INSTANCE->tot_y=m_text.GetSize(); CURSES_INSTANCE->scrollbar_topmargin = m_top_margin; CURSES_INSTANCE->scrollbar_botmargin = m_bottom_margin; } #endif attrset(A_NORMAL); if (lineidx >= 0) { int comment_state = GetCommentStateForLineStart(lineidx); WDL_FastString *s=m_text.Get(lineidx); if (s) { int y=lineidx-m_paneoffs_y[0]; if (y >= 0 && y < paneh[0]) { doDrawString(paney[0]+y, 0, lineidx, s->Get(), COLS, &comment_state, min(s->GetLength(), m_offs_x)); } y=lineidx-m_paneoffs_y[1]; if (y >= 0 && y < paneh[1]) { doDrawString(paney[1]+y, 0, lineidx, s->Get(), COLS, &comment_state, min(s->GetLength(), m_offs_x)); } } return; } __curses_invalidatefull((win32CursesCtx*)m_cursesCtx,false); draw_top_line(); attrset(A_NORMAL); bkgdset(A_NORMAL); move(m_top_margin,0); clrtoeol(); int pane, i; for (pane=0; pane < 2; ++pane) { int ln=m_paneoffs_y[pane]; int y=paney[pane]; int h=paneh[pane]; int comment_state=GetCommentStateForLineStart(ln); for(i=0; i < h; ++i, ++ln, ++y) { WDL_FastString *s=m_text.Get(ln); if (!s) { move(y,0); clrtoeol(); } else { doDrawString(y,0,ln,s->Get(),COLS,&comment_state,min(m_offs_x,s->GetLength())); } } } attrset(m_color_bottomline); bkgdset(m_color_bottomline); if (m_bottom_margin>0) { move(LINES-1, 0); #define BOLD(x) { attrset(m_color_bottomline|A_BOLD); addstr(x); attrset(m_color_bottomline&~A_BOLD); } if (m_selecting) { mvaddstr(LINES-1,0,"SELECTING ESC:cancel Ctrl+("); BOLD("C"); addstr("opy "); BOLD("X"); addstr(":cut "); BOLD("V"); addstr(":paste)"); } else { mvaddstr(LINES-1, 0, "Ctrl+("); if (m_pane_div <= 0.0 || m_pane_div >= 1.0) { BOLD("P"); addstr("ane "); } else { BOLD("O"); addstr("therpane "); addstr("no"); BOLD("P"); addstr("anes "); } BOLD("F"); addstr("ind "); addstr("ma"); BOLD("T"); addstr("ch"); draw_bottom_line(); addstr(")"); } #undef BOLD clrtoeol(); } attrset(0); bkgdset(0); __curses_invalidatefull((win32CursesCtx*)m_cursesCtx,true); }
static void menu_draw(struct Menu *menu) { int x, y, i, cur_page_start, total_page; int NEW_MAX_SCREEN_X = ((g_messages == g_messages_chs) || (g_messages == g_messages_cht)) ? (MAX_SCREEN_X+12) : (MAX_SCREEN_X);///+ int NEW_MAX_MENU_NUMBER_PER_PAGE = ((g_messages == g_messages_chs) || (g_messages == g_messages_cht)) ? (MAX_MENU_NUMBER_PER_PAGE-10) : (MAX_MENU_NUMBER_PER_PAGE);///+ x = 1, y = 1; set_screen_xy(x, y); write_string_with_color(g_messages[PRO_RECOVERY_MENU], 0xFF); x = 1, y = 2; set_screen_xy(x, y); write_string_with_color(g_messages[menu->banner_id], menu->banner_color); x = (cur_language == PSP_SYSTEMPARAM_LANGUAGE_FRENCH ? 0 : 3), y = 4; set_screen_xy(x, y); { char buf[10]; int color; if(menu->cur_sel == 0) { strcpy(buf, "> "); color = CUR_SEL_COLOR; } else { strcpy(buf, " "); color = 0; } strcat(buf, g_messages[BACK]); write_string_with_color(buf, color); } x = (cur_language == PSP_SYSTEMPARAM_LANGUAGE_FRENCH ? 0 : 3), y = 6; set_screen_xy(x, y); if(menu->cur_sel == 0) { cur_page_start = 0; } else { cur_page_start = (menu->cur_sel-1) / NEW_MAX_MENU_NUMBER_PER_PAGE * NEW_MAX_MENU_NUMBER_PER_PAGE;///|cur_page_start = (menu->cur_sel-1) / MAX_MENU_NUMBER_PER_PAGE * MAX_MENU_NUMBER_PER_PAGE; } for(i=cur_page_start; i<MIN(menu->submenu_size, cur_page_start+NEW_MAX_MENU_NUMBER_PER_PAGE); ++i) {///|for(i=cur_page_start; i<MIN(menu->submenu_size, cur_page_start+NEW_MAX_MENU_NUMBER_PER_PAGE); ++i) { char buf[256], *p; int color; struct MenuEntry* entry; entry = &menu->submenu[i]; if(menu->cur_sel == i+1) { set_line_backcolor(x, y, get_back_color(g_frame_count % (60 * 2 * MENU_BACK_COLOR_HALFTIME))); color = CUR_SEL_COLOR; strcpy(buf, "> "); } else { color = entry->color; strcpy(buf, " "); } p = buf + strlen(buf); if(entry->info_idx >= 0) { sprintf(p, "%s", g_messages[entry->info_idx]); } else { int (*display_callback)(struct MenuEntry* , char *, int); display_callback = (*entry->display_callback); if (display_callback != NULL) { (*display_callback)(entry, p, sizeof(buf) - (p - buf)); } else { strcpy(p, "FIXME"); } } if(entry->type == TYPE_SUBMENU) { strcat(p, " ->"); } write_string_with_color(buf, color); set_screen_xy(x, ++y); } total_page = (menu->submenu_size+NEW_MAX_MENU_NUMBER_PER_PAGE-1) / NEW_MAX_MENU_NUMBER_PER_PAGE;///|total_page = (menu->submenu_size+MAX_MENU_NUMBER_PER_PAGE-1) / MAX_MENU_NUMBER_PER_PAGE; if(total_page > 1) { char buf[20]; x = ((g_messages == g_messages_chs) || (g_messages == g_messages_cht)) ? (NEW_MAX_SCREEN_X - 20) : (NEW_MAX_SCREEN_X - 15);///|x = MAX_SCREEN_X - 15; y = 4; sprintf(buf, "%s %d/%d", g_messages[PAGE], (cur_page_start/NEW_MAX_MENU_NUMBER_PER_PAGE)+1, total_page);///|sprintf(buf, "%s %d/%d", g_messages[PAGE], (cur_page_start/MAX_MENU_NUMBER_PER_PAGE)+1, total_page); set_screen_xy(x, y); write_string_with_color(buf, 0); } write_bottom_info(); draw_bottom_line(); }