add option_line_status and option_line_status_width.

if option_line_status = 1 then show line numbers
This commit is contained in:
Ilia Maslakov 2009-05-02 21:12:39 +00:00
parent 406e83eac4
commit 0bc82a444b
4 changed files with 28 additions and 16 deletions

View File

@ -66,6 +66,8 @@ int option_save_mode = EDIT_QUICK_SAVE;
int option_save_position = 1;
int option_max_undo = 32768;
int option_persistent_selections = 1;
int option_line_status = 0;
int option_line_status_width = 0;
int option_edit_right_extreme = 0;
int option_edit_left_extreme = 0;
@ -627,7 +629,11 @@ edit_init (WEdit *edit, int lines, int columns, const char *filename,
{
int to_free = 0;
option_auto_syntax = 1; /* Resetting to auto on every invokation */
if ( option_line_status ) {
option_line_status_width = LINE_STATUS_WIDTH;
} else {
option_line_status_width = 0;
}
if (!edit) {
#ifdef ENABLE_NLS
/*
@ -1483,7 +1489,7 @@ void edit_update_curs_row (WEdit * edit)
void edit_update_curs_col (WEdit * edit)
{
edit->curs_col = edit_move_forward3(edit, edit_bol(edit, edit->curs1), 0, edit->curs1) + 8;
edit->curs_col = edit_move_forward3(edit, edit_bol(edit, edit->curs1), 0, edit->curs1) + option_line_status_width;
}
/*moves the display start position up by i lines */

View File

@ -288,6 +288,8 @@ extern int option_return_does_auto_indent;
extern int option_backspace_through_tabs;
extern int option_fake_half_tabs;
extern int option_persistent_selections;
extern int option_line_status;
extern int option_line_status_width;
typedef enum {
EDIT_QUICK_SAVE = 0,

View File

@ -247,7 +247,7 @@ print_to_widget (WEdit *edit, long row, int start_col, int start_col_real,
{
struct line_s *p;
int x = start_col_real + EDIT_TEXT_HORIZONTAL_OFFSET;
int x1 = LINE_STATUS_WIDTH + start_col + EDIT_TEXT_HORIZONTAL_OFFSET;
int x1 = option_line_status_width + start_col + EDIT_TEXT_HORIZONTAL_OFFSET;
int y = row + EDIT_TEXT_VERTICAL_OFFSET;
int cols_to_skip = abs (x);
unsigned char str[6 + 1];
@ -256,14 +256,16 @@ print_to_widget (WEdit *edit, long row, int start_col, int start_col_real,
edit_move (x1, y);
hline (' ', end_col + 1 - EDIT_TEXT_HORIZONTAL_OFFSET - x1);
for (int i = 0; i < LINE_STATUS_WIDTH; i++) {
if ( status[i] == '\0' ) {
status[i] = ' ';
if ( option_line_status ) {
for (int i = 0; i < LINE_STATUS_WIDTH; i++) {
if ( status[i] == '\0' ) {
status[i] = ' ';
}
}
set_color (MENU_ENTRY_COLOR);
edit_move (x1 + FONT_OFFSET_X - option_line_status_width, y + FONT_OFFSET_Y);
addstr (status);
}
set_color (MENU_ENTRY_COLOR);
edit_move (x1 + FONT_OFFSET_X - LINE_STATUS_WIDTH, y + FONT_OFFSET_Y);
addstr (status);
set_color (EDITOR_NORMAL_COLOR);
edit_move (x1 + FONT_OFFSET_X, y + FONT_OFFSET_Y);
@ -354,14 +356,15 @@ edit_draw_this_line (WEdit *edit, long b, long row, long start_col,
c1 = min (edit->column1, edit->column2);
c2 = max (edit->column1, edit->column2);
unsigned long cur_line = edit->start_line + row;
if ( cur_line < edit->total_lines ) {
g_snprintf(line_stat, LINE_STATUS_WIDTH + 1, "%7ld ", cur_line + 1);
} else if ( cur_line == edit->total_lines ) {
g_snprintf(line_stat, LINE_STATUS_WIDTH + 1, " <EOF>");
} else {
line_stat[0] = '\0';
if ( option_line_status ) {
if ( cur_line < edit->total_lines ) {
g_snprintf(line_stat, LINE_STATUS_WIDTH + 1, "%7ld ", cur_line + 1);
} else if ( cur_line == edit->total_lines ) {
g_snprintf(line_stat, LINE_STATUS_WIDTH + 1, "eof");
} else {
line_stat[0] = '\0';
}
}
if (col + 16 > -edit->start_col) {
eval_marks (edit, &m1, &m2);

View File

@ -221,6 +221,7 @@ static const struct {
{ "editor_persistent_selections", &option_persistent_selections },
{ "editor_visible_tabs", &visible_tabs },
{ "editor_visible_spaces", &visible_tws },
{ "editor_line_status", &option_line_status },
#endif /* USE_INTERNAL_EDIT */
{ "nice_rotating_dash", &nice_rotating_dash },