Skip to content
This repository has been archived by the owner on Dec 10, 2023. It is now read-only.

Commit

Permalink
added line and col cursor to mode line
Browse files Browse the repository at this point in the history
  • Loading branch information
MorganPeterson committed Jan 14, 2022
1 parent 581c2a8 commit 498a39c
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ cursorpos(void)
void
undocmd(void)
{
int32_t continue_undo = 1;
int32_t continue_undo = 1;
undo_t *up = curbuf->undo;
curbuf->undo_cnt = -1;
char_t *input = NULL;
Expand Down
18 changes: 12 additions & 6 deletions src/display.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ extern window_t *curwin;
extern window_t *headwin;
extern buffer_t *curbuf;

int32_t ml_col = 0;

int32_t
line_start(buffer_t *b, int32_t offset)
{
Expand Down Expand Up @@ -83,16 +85,19 @@ line_up(buffer_t *b, int32_t offset)
static void
modeline(window_t *w)
{
int i;
int i;
char lch, mch;
static char modeline[256];

attron(COLOR_PAIR(HL_MODELINE));
int32_t current, last;
get_line_stats(&current, &last);

attron(COLOR_PAIR(HL_MODELINE));
move(w->top + w->rows, 0);
lch = (w == curwin ? '=' : '-');
mch = ((w->buf->flags & B_MODIFIED) ? '*' : lch);

sprintf(modeline, "%c%c mpe: %c%c %s ", lch,mch,lch,lch, w->buf->buf_name);
sprintf(modeline, "%c%c mpe: %c%c %d:%d/%d %c%c %s ", lch, mch, lch, lch, ml_col, current, last, lch, lch, w->buf->buf_name);
addstr(modeline);
for (i = strlen(modeline) + 1; i <= COLS; i++)
addch(lch);
Expand Down Expand Up @@ -157,9 +162,10 @@ display(window_t *w, int32_t flag)
set_parse_state(b, b->page_end);

while (1) {
if (b->point == b->page_end) {
b->row = i;
b->col = j;
if (b->point == b->page_end) {
b->row = i;
b->col = j;
ml_col = j + 1;
}
p = ptr(b, b->page_end);
nch = 1;
Expand Down
1 change: 1 addition & 0 deletions src/header.h
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ void queryreplace(void);
int32_t line_to_point(int32_t line);
int32_t goto_line(int32_t line);
void gotoline(void);
void get_line_stats(int32_t *curline, int32_t *lastline);
int32_t save(char_t *fn);
int32_t get_input(char *prompt, char_t *buf, int32_t nbuf, int32_t flag);
void writefile(void);
Expand Down
9 changes: 6 additions & 3 deletions src/syntax.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ int32_t state = HL_NORMAL;
int32_t next_state = HL_NORMAL;
int32_t skip_count = 0;
int32_t prev_sep = 1;
int32_t syntax_row = 0;
int32_t syntax_col = 0;

char *C_HL_extensions[] = { ".c", ".h", ".cpp", NULL };
char *JS_HL_extensions[] = { ".js", ".jsx", NULL };
Expand Down Expand Up @@ -224,13 +226,14 @@ parse_text(buffer_t *b, int32_t p)
void
set_parse_state(buffer_t * b, int32_t p)
{
register int32_t po;
state = HL_NORMAL;
register int32_t po;
state = HL_NORMAL;
next_state = HL_NORMAL;
skip_count = 0;

for (po=0; po < p; po++)
for (po=0; po < p; po++) {
parse_text(b, po);
}
}

void
Expand Down

0 comments on commit 498a39c

Please sign in to comment.