Merge branch '351_show_number_line'

* 351_show_number_line:
  fix hotkey menu entry "Toggle li&ne state" now highlighted "n"
  add call CK_Toggle_Line_State to edit menu
  show line number in left part of screen (hotkey alt-n)
This commit is contained in:
Ilia Maslakov 2009-05-14 07:57:51 +00:00
commit f8a487de01
12 changed files with 71 additions and 11 deletions

View File

@ -72,6 +72,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_state = 0;
int option_line_state_width = 0;
int option_edit_right_extreme = 0;
int option_edit_left_extreme = 0;
@ -634,7 +636,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_state ) {
option_line_state_width = LINE_STATE_WIDTH;
} else {
option_line_state_width = 0;
}
if (!edit) {
#ifdef ENABLE_NLS
/*
@ -1496,7 +1502,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);
edit->curs_col = edit_move_forward3(edit, edit_bol(edit, edit->curs1), 0, edit->curs1) + option_line_state_width;
}
/*moves the display start position up by i lines */
@ -2680,6 +2686,16 @@ edit_execute_cmd (WEdit *edit, int command, int char_for_insertion)
edit_mark_cmd (edit, 1);
break;
case CK_Toggle_Line_State:
option_line_state = !option_line_state;
if ( option_line_state ) {
option_line_state_width = LINE_STATE_WIDTH;
} else {
option_line_state_width = 0;
}
edit->force |= REDRAW_PAGE;
break;
case CK_Toggle_Bookmark:
book_mark_clear (edit, edit->curs_line, BOOK_MARK_FOUND_COLOR);
if (book_mark_query_color (edit, edit->curs_line, BOOK_MARK_COLOR))

View File

@ -110,6 +110,7 @@
/* max count stack files */
#define MAX_HISTORY_MOVETO 50
#define LINE_STATE_WIDTH 8
typedef struct edit_stack_type {
long line;
@ -295,6 +296,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_state;
extern int option_line_state_width;
typedef enum {
EDIT_QUICK_SAVE = 0,

View File

@ -118,6 +118,7 @@
#define CK_Maximize 458
#define CK_Toggle_Syntax 480
#define CK_Toggle_Line_State 490
/* macro */
#define CK_Begin_Record_Macro 501

View File

@ -248,12 +248,12 @@ struct line_s {
static void
print_to_widget (WEdit *edit, long row, int start_col, int start_col_real,
long end_col, struct line_s line[])
long end_col, struct line_s line[], char *status)
{
struct line_s *p;
int x = start_col_real + EDIT_TEXT_HORIZONTAL_OFFSET;
int x1 = start_col + EDIT_TEXT_HORIZONTAL_OFFSET;
int x1 = start_col + EDIT_TEXT_HORIZONTAL_OFFSET + option_line_state_width;
int y = row + EDIT_TEXT_VERTICAL_OFFSET;
int cols_to_skip = abs (x);
unsigned char str[6 + 1];
@ -261,6 +261,17 @@ 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);
if ( option_line_state ) {
for (int i = 0; i < LINE_STATE_WIDTH; i++) {
if ( status[i] == '\0' ) {
status[i] = ' ';
}
}
set_color (LINE_STATE_COLOR);
edit_move (x1 + FONT_OFFSET_X - option_line_state_width, y + FONT_OFFSET_Y);
addstr (status);
}
edit_move (x1 + FONT_OFFSET_X, y + FONT_OFFSET_Y);
p = line;
@ -339,6 +350,8 @@ edit_draw_this_line (WEdit *edit, long b, long row, long start_col,
int color;
int i;
int utf8lag = 0;
unsigned int cur_line = 0;
char line_stat[LINE_STATE_WIDTH + 1];
edit_get_syntax_color (edit, b - 1, &color);
q = edit_move_forward3 (edit, b, start_col - edit->start_col, 0);
@ -348,6 +361,16 @@ 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);
if ( option_line_state ) {
cur_line = edit->start_line + row;
if ( cur_line <= edit->total_lines ) {
g_snprintf (line_stat, LINE_STATE_WIDTH + 1, "%7i ", cur_line + 1);
} else {
memset(line_stat, ' ', LINE_STATE_WIDTH);
line_stat[LINE_STATE_WIDTH] = '\0';
}
}
if (col + 16 > -edit->start_col) {
eval_marks (edit, &m1, &m2);
@ -530,7 +553,7 @@ edit_draw_this_line (WEdit *edit, long b, long row, long start_col,
}
p->ch = 0;
print_to_widget (edit, row, start_col, start_col_real, end_col, line);
print_to_widget (edit, row, start_col, start_col_real, end_col, line, line_stat);
}
#define key_pending(x) (!is_idle())

View File

@ -118,6 +118,7 @@ static const edit_key_map_type common_key_map[] = {
{ ALT ('-'), CK_Load_Prev_File },
{ ALT ('='), CK_Load_Next_File },
{ ALT (KEY_BACKSPACE), CK_Delete_Word_Left },
{ ALT ('n'), CK_Toggle_Line_State },
{ XCTRL ('k'), CK_Delete_To_Line_End },
{ XCTRL ('l'), CK_Refresh },

View File

@ -265,6 +265,12 @@ menu_goto_line (void)
menu_cmd (CK_Goto);
}
static void
menu_toggle_line_state (void)
{
menu_cmd (CK_Toggle_Line_State);
}
static void
menu_goto_bracket (void)
{
@ -368,6 +374,7 @@ static menu_entry SearReplMenu[] =
static menu_entry CmdMenu[] =
{
{' ', N_("&Go to line... M-l"), NULL_HOTKEY, menu_goto_line},
{' ', N_("Toggle li&ne state M-n"), NULL_HOTKEY, menu_toggle_line_state},
{' ', N_("Go to matching &bracket M-b"), NULL_HOTKEY, menu_goto_bracket},
{' ', "", NULL_HOTKEY, 0},
{' ', N_("Insert &literal... C-q"), NULL_HOTKEY, menu_lit_cmd},
@ -392,6 +399,7 @@ static menu_entry CmdMenu[] =
static menu_entry CmdMenuEmacs[] =
{
{' ', N_("&Go to line... M-l"), NULL_HOTKEY, menu_goto_line},
{' ', N_("Toggle li&ne state M-n"), NULL_HOTKEY, menu_toggle_line_state},
{' ', N_("Go to matching &bracket M-b"), NULL_HOTKEY, menu_goto_bracket},
{' ', "", NULL_HOTKEY, 0},
{' ', N_("Insert &literal... C-q"), NULL_HOTKEY, menu_lit_cmd},

View File

@ -92,7 +92,7 @@ edit_event (WEdit * edit, Gpm_Event * event, int *result)
if (event->type & (GPM_DOWN | GPM_UP))
edit_push_key_press (edit);
edit->prev_col = event->x - edit->start_col - 1;
edit->prev_col = event->x - edit->start_col - 1 - option_line_state_width;
if (--event->y > (edit->curs_row + 1))
edit_move_down (edit, event->y - (edit->curs_row + 1), 0);

View File

@ -221,6 +221,7 @@ static const name_map_t command_names[] = {
{"Execute-Macro", CK_Execute_Macro},
{"Begin-or-End-Macro", CK_Begin_End_Macro},
{"Ext-mode", CK_Ext_Mode},
{"Toggle-Line-State", CK_Toggle_Line_State},
#if 0
{"Focus-Next", CK_Focus_Next},
{"Focus-Prev", CK_Focus_Prev},

View File

@ -105,9 +105,10 @@ static struct colorpair color_map [] = {
{ "editbold=", 0, 0 }, /* search->found */
{ "editmarked=", 0, 0 }, /* marked/selected */
{ "editwhitespace=", 0, 0 }, /* whitespace */
{ "editlinestate=", 0, 0 }, /* line number bar*/
/* error dialog colors start at 38 */
{ "errdhotnormal=", 0, 0 }, /* Error dialog normal/hot */ /* 38 */
/* error dialog colors start at 39 */
{ "errdhotnormal=", 0, 0 }, /* Error dialog normal/hot */ /* 39 */
{ "errdhotfocus=", 0, 0 }, /* Error dialog focused/hot */
};
@ -259,6 +260,7 @@ static void configure_colors (void)
"editbold=yellow,blue:"
"editmarked=black,cyan:"
"editwhitespace=brightblue,blue:"
"editlinestate=white,cyan:"
"errdhotnormal=yellow,red:"
"errdhotfocus=yellow,lightgray", NULL);

View File

@ -86,9 +86,12 @@ extern int alarm_colors[4];
#define EDITOR_MARKED_COLOR IF_COLOR (36, A_REVERSE)
#define EDITOR_WHITESPACE_COLOR IF_COLOR (37, 0 /* irrelevant */)
/* color of left 8 char status per line */
#define LINE_STATE_COLOR IF_COLOR (38, 0)
/* Error dialog colors */
#define ERROR_HOT_NORMAL IF_COLOR (38, 0)
#define ERROR_HOT_FOCUS IF_COLOR (39, 0)
#define ERROR_HOT_NORMAL IF_COLOR (39, 0)
#define ERROR_HOT_FOCUS IF_COLOR (40, 0)
#ifdef HAVE_SLANG
# define CTYPE const char *

View File

@ -1911,7 +1911,8 @@ print_color_usage (void)
" Dialog boxes: dnormal, dfocus, dhotnormal, dhotfocus, errdhotnormal,\n"
" errdhotfocus\n"
" Menus: menu, menuhot, menusel, menuhotsel\n"
" Editor: editnormal, editbold, editmarked\n"), stdout);
" Editor: editnormal, editbold, editmarked, editwhitespace,\n"
" editlinestate\n"), stdout);
fputs (_
(
" Help: helpnormal, helpitalic, helpbold, helplink, helpslink\n"

View File

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