of trying to build one by hand.
// Draw the modeline
move(0, 0);
// Draw the modeline
move(0, 0);
if(with_colors) {
attron(COLOR_PAIR(1));
} else {
if(with_colors) {
attron(COLOR_PAIR(1));
} else {
+ // There must be a more elegant way of moving the cursor at a
+ // location met during display
+
+ int cursor_x = 0;
+
if(title) {
addstr(title);
addstr(" ");
if(title) {
addstr(title);
addstr(" ");
+ cursor_x += strlen(title) + 1;
- printw("%d/%d ", nb_printed_lines, nb_lines);
+ sprintf(buffer, "%d/%d ", nb_printed_lines, nb_lines);
+ addstr(buffer);
+ cursor_x += strlen(buffer);
addnstr(pattern, cursor_position);
addnstr(pattern, cursor_position);
-
- // Now we print the cursor. All that mess to have reverse video with
- // and without color.
-
- if(with_colors) {
- attroff(COLOR_PAIR(1));
- attron(COLOR_PAIR(3));
- } else {
- attroff(A_REVERSE);
- }
+ cursor_x += cursor_position;
if(pattern[cursor_position]) {
if(pattern[cursor_position]) {
- addnstr(&pattern[cursor_position], 1);
+ addstr(pattern + cursor_position);
- if(with_colors) {
- attroff(COLOR_PAIR(3));
- attron(COLOR_PAIR(1));
- } else {
- attron(A_REVERSE);
- }
-
- if(pattern[cursor_position]) {
- addstr(pattern + cursor_position + 1);
- }
-
- // Finished printing the cursor
-
if(use_regexp) {
addstr(" [regexp]");
}
if(use_regexp) {
addstr(" [regexp]");
}
if(with_colors) {
attroff(COLOR_PAIR(1));
} else {
if(with_colors) {
attroff(COLOR_PAIR(1));
} else {
noecho();
// Hide the cursor
noecho();
// Hide the cursor
// So that the arrow keys work
keypad(stdscr, TRUE);
// So that the arrow keys work
keypad(stdscr, TRUE);
color_fg_highlight < 0 || color_bg_highlight >= COLORS ||
color_bg_highlight < 0 || color_bg_highlight >= COLORS) {
echo();
color_fg_highlight < 0 || color_bg_highlight >= COLORS ||
color_bg_highlight < 0 || color_bg_highlight >= COLORS) {
echo();
endwin();
cerr << "Color numbers have to be between 0 and " << COLORS - 1 << "." << endl;
exit(1);
endwin();
cerr << "Color numbers have to be between 0 and " << COLORS - 1 << "." << endl;
exit(1);
}
else if(key == KEY_DOWN ||
}
else if(key == KEY_DOWN ||
motion = 1;
}
else if(key == KEY_UP ||
motion = 1;
}
else if(key == KEY_UP ||
} while(key != '\n' && key != KEY_ENTER && key != '\007'); // ^G
echo();
} while(key != '\n' && key != KEY_ENTER && key != '\007'); // ^G
echo();
endwin();
//////////////////////////////////////////////////////////////////////
endwin();
//////////////////////////////////////////////////////////////////////