mirror of https://github.com/MidnightCommander/mc
lib/widget/input.c: reorder routines.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
bf0dd8efb1
commit
84ec30d05a
|
@ -148,23 +148,6 @@ input_eval_marks (WInput * in, long *start_mark, long *end_mark)
|
|||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static void
|
||||
delete_region (WInput * in, int start, int end)
|
||||
{
|
||||
int first = MIN (start, end);
|
||||
int last = MAX (start, end);
|
||||
|
||||
input_mark_cmd (in, FALSE);
|
||||
in->point = first;
|
||||
last = str_offset_to_pos (in->buffer->str, last);
|
||||
first = str_offset_to_pos (in->buffer->str, first);
|
||||
g_string_erase (in->buffer, first, last - first);
|
||||
in->charpoint = 0;
|
||||
in->need_push = TRUE;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static void
|
||||
do_show_hist (WInput * in)
|
||||
{
|
||||
|
@ -290,44 +273,6 @@ move_buffer_backward (WInput * in, int start, int end)
|
|||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static cb_ret_t
|
||||
insert_char (WInput * in, int c_code)
|
||||
{
|
||||
int res;
|
||||
long m1, m2;
|
||||
size_t ins_point;
|
||||
|
||||
if (input_eval_marks (in, &m1, &m2))
|
||||
delete_region (in, m1, m2);
|
||||
|
||||
if (c_code == -1)
|
||||
return MSG_NOT_HANDLED;
|
||||
|
||||
if (in->charpoint >= MB_LEN_MAX)
|
||||
return MSG_HANDLED;
|
||||
|
||||
in->charbuf[in->charpoint] = c_code;
|
||||
in->charpoint++;
|
||||
|
||||
res = str_is_valid_char (in->charbuf, in->charpoint);
|
||||
if (res < 0)
|
||||
{
|
||||
if (res != -2)
|
||||
in->charpoint = 0; /* broken multibyte char, skip */
|
||||
return MSG_HANDLED;
|
||||
}
|
||||
|
||||
in->need_push = TRUE;
|
||||
ins_point = str_offset_to_pos (in->buffer->str, in->point);
|
||||
g_string_insert_len (in->buffer, ins_point, in->charbuf, in->charpoint);
|
||||
in->point++;
|
||||
in->charpoint = 0;
|
||||
|
||||
return MSG_HANDLED;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static void
|
||||
beginning_of_line (WInput * in)
|
||||
{
|
||||
|
@ -440,21 +385,6 @@ backward_delete (WInput * in)
|
|||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static void
|
||||
delete_char (WInput * in)
|
||||
{
|
||||
const char *act;
|
||||
int end;
|
||||
|
||||
act = in->buffer->str + str_offset_to_pos (in->buffer->str, in->point);
|
||||
end = in->point + str_cnext_noncomb_char (&act);
|
||||
move_buffer_backward (in, in->point, end);
|
||||
in->charpoint = 0;
|
||||
in->need_push = TRUE;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static void
|
||||
copy_region (WInput * in, int start, int end)
|
||||
{
|
||||
|
@ -484,6 +414,76 @@ copy_region (WInput * in, int start, int end)
|
|||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static void
|
||||
delete_region (WInput * in, int start, int end)
|
||||
{
|
||||
int first = MIN (start, end);
|
||||
int last = MAX (start, end);
|
||||
|
||||
input_mark_cmd (in, FALSE);
|
||||
in->point = first;
|
||||
last = str_offset_to_pos (in->buffer->str, last);
|
||||
first = str_offset_to_pos (in->buffer->str, first);
|
||||
g_string_erase (in->buffer, first, last - first);
|
||||
in->charpoint = 0;
|
||||
in->need_push = TRUE;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static cb_ret_t
|
||||
insert_char (WInput * in, int c_code)
|
||||
{
|
||||
int res;
|
||||
long m1, m2;
|
||||
size_t ins_point;
|
||||
|
||||
if (input_eval_marks (in, &m1, &m2))
|
||||
delete_region (in, m1, m2);
|
||||
|
||||
if (c_code == -1)
|
||||
return MSG_NOT_HANDLED;
|
||||
|
||||
if (in->charpoint >= MB_LEN_MAX)
|
||||
return MSG_HANDLED;
|
||||
|
||||
in->charbuf[in->charpoint] = c_code;
|
||||
in->charpoint++;
|
||||
|
||||
res = str_is_valid_char (in->charbuf, in->charpoint);
|
||||
if (res < 0)
|
||||
{
|
||||
if (res != -2)
|
||||
in->charpoint = 0; /* broken multibyte char, skip */
|
||||
return MSG_HANDLED;
|
||||
}
|
||||
|
||||
in->need_push = TRUE;
|
||||
ins_point = str_offset_to_pos (in->buffer->str, in->point);
|
||||
g_string_insert_len (in->buffer, ins_point, in->charbuf, in->charpoint);
|
||||
in->point++;
|
||||
in->charpoint = 0;
|
||||
|
||||
return MSG_HANDLED;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static void
|
||||
delete_char (WInput * in)
|
||||
{
|
||||
const char *act;
|
||||
int end;
|
||||
|
||||
act = in->buffer->str + str_offset_to_pos (in->buffer->str, in->point);
|
||||
end = in->point + str_cnext_noncomb_char (&act);
|
||||
move_buffer_backward (in, in->point, end);
|
||||
in->charpoint = 0;
|
||||
in->need_push = TRUE;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static void
|
||||
kill_word (WInput * in)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue