diff options
Diffstat (limited to 'src/mark.c')
-rw-r--r-- | src/mark.c | 170 |
1 files changed, 67 insertions, 103 deletions
diff --git a/src/mark.c b/src/mark.c index 67d962dc9e..db274cda50 100644 --- a/src/mark.c +++ b/src/mark.c @@ -12,6 +12,25 @@ */ #include "vim.h" +#include "mark.h" +#include "buffer.h" +#include "charset.h" +#include "diff.h" +#include "eval.h" +#include "ex_cmds.h" +#include "fileio.h" +#include "fold.h" +#include "mbyte.h" +#include "memline.h" +#include "message.h" +#include "misc1.h" +#include "misc2.h" +#include "option.h" +#include "quickfix.h" +#include "search.h" +#include "term.h" +#include "ui.h" +#include "os/os.h" /* * This file contains routines to maintain and manipulate marks. @@ -38,8 +57,7 @@ static void write_one_filemark __ARGS((FILE *fp, xfmark_T *fm, int c1, int c2)); * Set named mark "c" at current cursor position. * Returns OK on success, FAIL if bad name given. */ -int setmark(c) -int c; +int setmark(int c) { return setmark_pos(c, &curwin->w_cursor, curbuf->b_fnum); } @@ -49,10 +67,7 @@ int c; * When "c" is upper case use file "fnum". * Returns OK on success, FAIL if bad name given. */ -int setmark_pos(c, pos, fnum) -int c; -pos_T *pos; -int fnum; +int setmark_pos(int c, pos_T *pos, int fnum) { int i; @@ -120,7 +135,7 @@ int fnum; * Set the previous context mark to the current position and add it to the * jump list. */ -void setpcmark() { +void setpcmark(void) { int i; xfmark_T *fm; #ifdef JUMPLIST_ROTATE @@ -172,7 +187,7 @@ void setpcmark() { * context will only be changed if the cursor moved to a different line. * If pcmark was deleted (with "dG") the previous mark is restored. */ -void checkpcmark() { +void checkpcmark(void) { if (curwin->w_prev_pcmark.lnum != 0 && (equalpos(curwin->w_pcmark, curwin->w_cursor) || curwin->w_pcmark.lnum == 0)) { @@ -184,8 +199,7 @@ void checkpcmark() { /* * move "count" positions in the jump list (count may be negative) */ -pos_T * movemark(count) -int count; +pos_T *movemark(int count) { pos_T *pos; xfmark_T *jmp; @@ -238,8 +252,7 @@ int count; /* * Move "count" positions in the changelist (count may be negative). */ -pos_T * movechangelist(count) -int count; +pos_T *movechangelist(int count) { int n; @@ -272,26 +285,17 @@ int count; * - NULL if there is no mark called 'c'. * - -1 if mark is in other file and jumped there (only if changefile is TRUE) */ -pos_T * getmark_buf(buf, c, changefile) -buf_T *buf; -int c; -int changefile; +pos_T *getmark_buf(buf_T *buf, int c, int changefile) { return getmark_buf_fnum(buf, c, changefile, NULL); } -pos_T * getmark(c, changefile) -int c; -int changefile; +pos_T *getmark(int c, int changefile) { return getmark_buf_fnum(curbuf, c, changefile, NULL); } -pos_T * getmark_buf_fnum(buf, c, changefile, fnum) -buf_T *buf; -int c; -int changefile; -int *fnum; +pos_T *getmark_buf_fnum(buf_T *buf, int c, int changefile, int *fnum) { pos_T *posp; pos_T *startp, *endp; @@ -404,10 +408,12 @@ int *fnum; * * Returns pointer to pos_T of the next mark or NULL if no mark is found. */ -pos_T * getnextmark(startpos, dir, begin_line) -pos_T *startpos; /* where to start */ -int dir; /* direction for search */ -int begin_line; +pos_T * +getnextmark ( + pos_T *startpos, /* where to start */ + int dir, /* direction for search */ + int begin_line +) { int i; pos_T *result = NULL; @@ -446,8 +452,7 @@ int begin_line; * This is used for marks obtained from the .viminfo file. It's postponed * until the mark is used to avoid a long startup delay. */ -static void fname2fnum(fm) -xfmark_T *fm; +static void fname2fnum(xfmark_T *fm) { char_u *p; @@ -483,8 +488,7 @@ xfmark_T *fm; * May replace the name with an fnum. * Used for marks that come from the .viminfo file. */ -void fmarks_check_names(buf) -buf_T *buf; +void fmarks_check_names(buf_T *buf) { char_u *name; int i; @@ -509,10 +513,7 @@ buf_T *buf; vim_free(name); } -static void fmarks_check_one(fm, name, buf) -xfmark_T *fm; -char_u *name; -buf_T *buf; +static void fmarks_check_one(xfmark_T *fm, char_u *name, buf_T *buf) { if (fm->fmark.fnum == 0 && fm->fname != NULL @@ -527,8 +528,7 @@ buf_T *buf; * Check a if a position from a mark is valid. * Give and error message and return FAIL if not. */ -int check_mark(pos) -pos_T *pos; +int check_mark(pos_T *pos) { if (pos == NULL) { EMSG(_(e_umark)); @@ -553,8 +553,7 @@ pos_T *pos; * * Used mainly when trashing the entire buffer during ":e" type commands */ -void clrallmarks(buf) -buf_T *buf; +void clrallmarks(buf_T *buf) { static int i = -1; @@ -581,9 +580,7 @@ buf_T *buf; * When it's in the current buffer, return the text at the mark. * Returns an allocated string. */ -char_u * fm_getname(fmark, lead_len) -fmark_T *fmark; -int lead_len; +char_u *fm_getname(fmark_T *fmark, int lead_len) { if (fmark->fnum == curbuf->b_fnum) /* current buffer */ return mark_line(&(fmark->mark), lead_len); @@ -594,9 +591,7 @@ int lead_len; * Return the line at mark "mp". Truncate to fit in window. * The returned string has been allocated. */ -static char_u * mark_line(mp, lead_len) -pos_T *mp; -int lead_len; +static char_u *mark_line(pos_T *mp, int lead_len) { char_u *s, *p; int len; @@ -620,8 +615,7 @@ int lead_len; /* * print the marks */ -void do_marks(eap) -exarg_T *eap; +void do_marks(exarg_T *eap) { char_u *arg = eap->arg; int i; @@ -656,12 +650,14 @@ exarg_T *eap; show_one_mark(-1, arg, NULL, NULL, FALSE); } -static void show_one_mark(c, arg, p, name, current) -int c; -char_u *arg; -pos_T *p; -char_u *name; -int current; /* in current file */ +static void +show_one_mark ( + int c, + char_u *arg, + pos_T *p, + char_u *name, + int current /* in current file */ +) { static int did_title = FALSE; int mustfree = FALSE; @@ -706,8 +702,7 @@ int current; /* in current file */ /* * ":delmarks[!] [marks]" */ -void ex_delmarks(eap) -exarg_T *eap; +void ex_delmarks(exarg_T *eap) { char_u *p; int from, to; @@ -778,8 +773,7 @@ exarg_T *eap; /* * print the jumplist */ -void ex_jumps(eap) -exarg_T *eap UNUSED; +void ex_jumps(exarg_T *eap) { int i; char_u *name; @@ -822,8 +816,7 @@ exarg_T *eap UNUSED; /* * print the changelist */ -void ex_changes(eap) -exarg_T *eap UNUSED; +void ex_changes(exarg_T *eap) { int i; char_u *name; @@ -896,11 +889,7 @@ exarg_T *eap UNUSED; * Example: Insert two lines below 55: mark_adjust(56, MAXLNUM, 2, 0); * or: mark_adjust(56, 55, MAXLNUM, 2); */ -void mark_adjust(line1, line2, amount, amount_after) -linenr_T line1; -linenr_T line2; -long amount; -long amount_after; +void mark_adjust(linenr_T line1, linenr_T line2, long amount, long amount_after) { int i; int fnum = curbuf->b_fnum; @@ -1043,11 +1032,7 @@ long amount_after; * "lnum_amount" to the line number and add "col_amount" to the column * position. */ -void mark_col_adjust(lnum, mincol, lnum_amount, col_amount) -linenr_T lnum; -colnr_T mincol; -long lnum_amount; -long col_amount; +void mark_col_adjust(linenr_T lnum, colnr_T mincol, long lnum_amount, long col_amount) { int i; int fnum = curbuf->b_fnum; @@ -1118,7 +1103,7 @@ long col_amount; * When deleting lines, this may create duplicate marks in the * jumplist. They will be removed here for the current window. */ -static void cleanup_jumplist() { +static void cleanup_jumplist(void) { int i; int from, to; @@ -1146,9 +1131,7 @@ static void cleanup_jumplist() { /* * Copy the jumplist from window "from" to window "to". */ -void copy_jumplist(from, to) -win_T *from; -win_T *to; +void copy_jumplist(win_T *from, win_T *to) { int i; @@ -1164,8 +1147,7 @@ win_T *to; /* * Free items in the jumplist of window "wp". */ -void free_jumplist(wp) -win_T *wp; +void free_jumplist(win_T *wp) { int i; @@ -1173,15 +1155,14 @@ win_T *wp; vim_free(wp->w_jumplist[i].fname); } -void set_last_cursor(win) -win_T *win; +void set_last_cursor(win_T *win) { if (win->w_buffer != NULL) win->w_buffer->b_last_cursor = win->w_cursor; } #if defined(EXITFREE) || defined(PROTO) -void free_all_marks() { +void free_all_marks(void) { int i; for (i = 0; i < NMARKS + EXTRA_MARKS; i++) @@ -1191,9 +1172,7 @@ void free_all_marks() { #endif -int read_viminfo_filemark(virp, force) -vir_T *virp; -int force; +int read_viminfo_filemark(vir_T *virp, int force) { char_u *str; xfmark_T *fm; @@ -1239,8 +1218,7 @@ int force; return vim_fgets(virp->vir_line, LSIZE, virp->vir_fd); } -void write_viminfo_filemarks(fp) -FILE *fp; +void write_viminfo_filemarks(FILE *fp) { int i; char_u *name; @@ -1295,11 +1273,7 @@ FILE *fp; } } -static void write_one_filemark(fp, fm, c1, c2) -FILE *fp; -xfmark_T *fm; -int c1; -int c2; +static void write_one_filemark(FILE *fp, xfmark_T *fm, int c1, int c2) { char_u *name; @@ -1323,8 +1297,7 @@ int c2; /* * Return TRUE if "name" is on removable media (depending on 'viminfo'). */ -int removable(name) -char_u *name; +int removable(char_u *name) { char_u *p; char_u part[51]; @@ -1354,8 +1327,7 @@ static void write_one_mark __ARGS((FILE *fp_out, int c, pos_T *pos)); * Write all the named marks for all buffers. * Return the number of buffers for which marks have been written. */ -int write_viminfo_marks(fp_out) -FILE *fp_out; +int write_viminfo_marks(FILE *fp_out) { int count; buf_T *buf; @@ -1409,10 +1381,7 @@ FILE *fp_out; return count; } -static void write_one_mark(fp_out, c, pos) -FILE *fp_out; -int c; -pos_T *pos; +static void write_one_mark(FILE *fp_out, int c, pos_T *pos) { if (pos->lnum != 0) fprintf(fp_out, "\t%c\t%ld\t%d\n", c, (long)pos->lnum, (int)pos->col); @@ -1424,12 +1393,7 @@ pos_T *pos; * fp_out == NULL && (flags & VIF_WANT_MARKS): read marks for curbuf only * fp_out == NULL && (flags & VIF_GET_OLDFILES | VIF_FORCEIT): fill v:oldfiles */ -void copy_viminfo_marks(virp, fp_out, count, eof, flags) -vir_T *virp; -FILE *fp_out; -int count; -int eof; -int flags; +void copy_viminfo_marks(vir_T *virp, FILE *fp_out, int count, int eof, int flags) { char_u *line = virp->vir_line; buf_T *buf; |