Compare commits
2 Commits
37ff9197e0
...
37d73f63e3
| Author | SHA1 | Date | |
|---|---|---|---|
| 37d73f63e3 | |||
| a11b2103da |
15
ce/edit.c
15
ce/edit.c
@@ -23,6 +23,8 @@
|
||||
|
||||
#define STATUS_LINE_STYLE ANSIQ_GR_SEQ (ANSIQ_BG_RGB (240, 191, 88) ANSIQ_FG_BLACK)
|
||||
|
||||
#define TAB_INSERT " "
|
||||
|
||||
struct edit_line {
|
||||
struct list_node_link lines_link;
|
||||
struct gapbuffer gb;
|
||||
@@ -130,7 +132,7 @@ void edit_start (const char* file_path, const char* text) {
|
||||
list_foreach (editor.lines, line_link, tmp_line_link) editor.total_lines++;
|
||||
|
||||
size_t gutter_width = count_digits (editor.total_lines);
|
||||
size_t effective_cols = (cols > gutter_width + 1) ? cols - (gutter_width + 1) : cols;
|
||||
size_t effective_cols = (cols > gutter_width + 3) ? cols - (gutter_width + 3) : cols;
|
||||
|
||||
list_foreach (editor.lines, line_link, tmp_line_link) {
|
||||
if (current_idx < editor.row_offset) {
|
||||
@@ -147,7 +149,7 @@ void edit_start (const char* file_path, const char* text) {
|
||||
bbptr += w;
|
||||
bb_remaining -= w;
|
||||
|
||||
w = snprintf (bbptr, bb_remaining, LINE_NUMBERS_STYLE "%*zu " ANSIQ_GR_RESET,
|
||||
w = snprintf (bbptr, bb_remaining, LINE_NUMBERS_STYLE " %*zu " ANSIQ_GR_RESET " ",
|
||||
(int)gutter_width, current_idx + 1);
|
||||
bbptr += w;
|
||||
bb_remaining -= w;
|
||||
@@ -212,7 +214,7 @@ void edit_start (const char* file_path, const char* text) {
|
||||
|
||||
w = snprintf (bbptr, bb_remaining, ANSIQ_DYN_CUR_SET ANSIQ_CUR_VISIBLE,
|
||||
(int)(editor.cursor.line - editor.row_offset) + 1,
|
||||
(int)(editor.cursor.col - editor.col_offset) + 1 + (int)gutter_width + 1);
|
||||
(int)(editor.cursor.col - editor.col_offset) + 1 + (int)gutter_width + 3);
|
||||
bbptr += w;
|
||||
bb_remaining -= w;
|
||||
|
||||
@@ -229,6 +231,13 @@ void edit_start (const char* file_path, const char* text) {
|
||||
gapbuffer_backspace (&editor.current_line->gb);
|
||||
}
|
||||
break;
|
||||
case '\t':
|
||||
gapbuffer_move (&editor.current_line->gb, editor.cursor.col);
|
||||
for (size_t i = 0; i < sizeof (TAB_INSERT) - 1; i++)
|
||||
gapbuffer_insert (&wrealloc, NULL, &editor.current_line->gb, TAB_INSERT[i]);
|
||||
|
||||
editor.cursor.col += sizeof (TAB_INSERT) - 1;
|
||||
break;
|
||||
case '\n': {
|
||||
gapbuffer_move (&editor.current_line->gb, editor.cursor.col);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user