mirror of
https://github.com/vbatts/bvi.git
synced 2025-08-03 16:10:28 +00:00
bvi-1.5.0.src.tar.gz
6540716a1a3b2b9711635108da14b26baea488881d4a682121c0bddbba6b74cb bvi-1.5.0.src.tar.gz Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
This commit is contained in:
parent
75fc14b579
commit
50898d8d59
28 changed files with 1936 additions and 1473 deletions
156
bvi.c
156
bvi.c
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* 1996-02-28 V 1.0.0
|
||||
* 1999-01-27 V 1.1.0
|
||||
* 1999-04-22 V 1.1.1
|
||||
* 1999-04-22 V 1.1.1
|
||||
* 1999-07-01 V 1.2.0 beta
|
||||
* 1999-10-22 V 1.2.0 final
|
||||
* 2000-05-10 V 1.3.0 alpha
|
||||
|
@ -14,10 +14,11 @@
|
|||
* 2014-10-07 V 1.4.0
|
||||
* 2019-10-12 V 1.4.1
|
||||
* 2023-03-06 V 1.4.2
|
||||
* 2025-07-19 V 1.5.0
|
||||
*
|
||||
* NOTE: Edit this file with tabstop=4 !
|
||||
*
|
||||
* Copyright 1996-2023 by Gerhard Buergmann
|
||||
* Copyright 1996-2025 by Gerhard Buergmann
|
||||
* gerhard@puon.at
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
|
@ -44,55 +45,56 @@
|
|||
#endif
|
||||
|
||||
|
||||
char *copyright = "(C) GPL 1996-2023 by Gerhard Buergmann";
|
||||
char *copyright = "(C) GPL 1996-2025 by Gerhard Buergmann";
|
||||
|
||||
jmp_buf env; /* context for `longjmp' function */
|
||||
|
||||
int loc;
|
||||
int maxx, maxy, x, xx, y;
|
||||
int screen, status, statsize;
|
||||
int loc;
|
||||
int maxx, maxy, x, xx, y;
|
||||
int screen, status, statsize;
|
||||
off_t size;
|
||||
PTR mem = NULL;
|
||||
PTR curpos;
|
||||
PTR maxpos;
|
||||
PTR pagepos;
|
||||
PTR spos;
|
||||
PTR mem = NULL;
|
||||
PTR curpos;
|
||||
PTR maxpos;
|
||||
PTR pagepos;
|
||||
PTR spos;
|
||||
char *name = NULL;
|
||||
char *shell;
|
||||
char string[MAXCMD+1];
|
||||
char cmdstr[MAXCMD+1] = "";
|
||||
FILE *Ausgabe_Datei;
|
||||
int edits = 0;
|
||||
int AnzAdd, Anzahl, Anzahl3;
|
||||
int edits = 0;
|
||||
int AnzAdd, Anzahl, Anzahl3;
|
||||
off_t filesize, memsize, undosize;
|
||||
|
||||
int statusflag = 1;
|
||||
int space = 2;
|
||||
|
||||
long precount = -1;
|
||||
|
||||
int block_flag = 0;
|
||||
int block_flag = 0;
|
||||
|
||||
|
||||
off_t block_begin, block_end, block_size;
|
||||
|
||||
|
||||
char **files; /* list of input files */
|
||||
int numfiles; /* number of input files */
|
||||
int curfile; /* number of the current file */
|
||||
int numfiles; /* number of input files */
|
||||
int curfile; /* number of the current file */
|
||||
|
||||
int arrnum = 0;
|
||||
int arrnum = 0;
|
||||
char numarr[MAXCMD+1]; /* string for collecting number */
|
||||
char rep_buf[BUFFER];
|
||||
|
||||
PTR current;
|
||||
PTR last_motion;
|
||||
PTR current_start;
|
||||
PTR undo_start;
|
||||
PTR current;
|
||||
PTR last_motion;
|
||||
PTR current_start;
|
||||
PTR undo_start;
|
||||
off_t undo_count;
|
||||
off_t yanked = 0L;
|
||||
char *yank_buf = NULL;
|
||||
char *undo_buf = NULL;
|
||||
char *fname_buf = NULL;
|
||||
PTR markbuf[26];
|
||||
PTR markbuf[26];
|
||||
|
||||
char addr_form[15];
|
||||
|
||||
|
@ -100,8 +102,8 @@ char *nobytes = "No bytes@in the buffer";
|
|||
|
||||
static char progname[8];
|
||||
static char line[MAXCMD+1];
|
||||
static int mark;
|
||||
static int wrstat = 1;
|
||||
static int mark;
|
||||
static int wrstat = 1;
|
||||
|
||||
|
||||
void
|
||||
|
@ -117,9 +119,7 @@ usage()
|
|||
|
||||
|
||||
int
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
int ch;
|
||||
int lflag;
|
||||
|
@ -248,7 +248,7 @@ main(argc, argv)
|
|||
break;
|
||||
case BLOCK_BEGIN|BLOCK_END|BLOCK_LEN:
|
||||
if (block_end - block_begin != block_size + 1) {
|
||||
fprintf(stderr, "Ambigous block data\n");
|
||||
fprintf(stderr, "Ambiguous block data\n");
|
||||
exit(1);
|
||||
}
|
||||
break;
|
||||
|
@ -267,7 +267,9 @@ main(argc, argv)
|
|||
maxy = LINES;
|
||||
if (params[P_LI].flags & P_CHANGED) maxy = P(P_LI);
|
||||
P(P_SS) = maxy / 2;
|
||||
/* We do not set P(P_LI) and P(P_CM) anymore, because 0 means "auto"
|
||||
P(P_LI) = maxy;
|
||||
*/
|
||||
maxy--;
|
||||
keypad(stdscr, TRUE);
|
||||
scrollok(stdscr, TRUE);
|
||||
|
@ -275,21 +277,21 @@ main(argc, argv)
|
|||
cbreak();
|
||||
noecho();
|
||||
|
||||
/* address column width */
|
||||
/* default is 8 + 2 blanks */
|
||||
/* if block_begin has 8 hex digits or more */
|
||||
/* reserve 1 hex digit more than required */
|
||||
char tmp[sizeof(block_begin) * 2 + 3];
|
||||
AnzAdd = sprintf(tmp, "%llX", (long long unsigned)block_begin) + 1;
|
||||
if (AnzAdd < 8)
|
||||
AnzAdd = 8;
|
||||
if (AnzAdd > sizeof(block_begin) * 2)
|
||||
AnzAdd = sizeof(block_begin) * 2;
|
||||
sprintf(addr_form, "%%0%dllX ", AnzAdd);
|
||||
AnzAdd = sprintf(tmp, addr_form, block_begin);
|
||||
/* address column width */
|
||||
/* default is 8 + 2 blanks */
|
||||
/* if block_begin has 8 hex digits or more */
|
||||
/* reserve 1 hex digit more than required */
|
||||
char tmp[sizeof(block_begin) * 2 + 3];
|
||||
AnzAdd = sprintf(tmp, "%llX", (long long unsigned)block_begin) + 1;
|
||||
if (AnzAdd < 8) AnzAdd = 8;
|
||||
if (AnzAdd > sizeof(block_begin) * 2) AnzAdd = sizeof(block_begin) * 2;
|
||||
sprintf(addr_form, "%%0%dllX ", AnzAdd);
|
||||
AnzAdd = sprintf(tmp, addr_form, block_begin);
|
||||
|
||||
Anzahl = ((COLS - AnzAdd - 1) / 16) * 4;
|
||||
Anzahl = ((COLS - AnzAdd - space) / 16) * 4;
|
||||
/*
|
||||
P(P_CM) = Anzahl;
|
||||
*/
|
||||
maxx = Anzahl * 4 + AnzAdd + 1;
|
||||
Anzahl3 = Anzahl * 3;
|
||||
statsize = 35;
|
||||
|
@ -310,7 +312,7 @@ main(argc, argv)
|
|||
if (*cmdstr != '\0')
|
||||
docmdline(cmdstr);
|
||||
msg(fname_buf);
|
||||
|
||||
|
||||
/* main loop */
|
||||
do {
|
||||
setjmp(env);
|
||||
|
@ -328,6 +330,10 @@ main(argc, argv)
|
|||
else precount = -1;
|
||||
lflag = arrnum = 0;
|
||||
|
||||
if (statusflag == 0) {
|
||||
statusflag = 1;
|
||||
clearstr();
|
||||
}
|
||||
switch (ch) {
|
||||
case '^': x = AnzAdd;
|
||||
loc = HEX;
|
||||
|
@ -426,7 +432,7 @@ main(argc, argv)
|
|||
x = AnzAdd - 1 + Anzahl3 + Anzahl;
|
||||
loc = ASCII; }
|
||||
break;
|
||||
case ':' : clearstr();
|
||||
case ':' : clearstr();
|
||||
addch(ch);
|
||||
refresh();
|
||||
getcmdstr(cmdstr, 1);
|
||||
|
@ -467,6 +473,18 @@ main(argc, argv)
|
|||
fileinfo(name);
|
||||
wrstat = 0;
|
||||
break;
|
||||
case KEY_RESIZE:
|
||||
if (P(P_CM) == 0) {
|
||||
Anzahl = ((COLS - AnzAdd - space) / 4);
|
||||
maxx = Anzahl * 4 + AnzAdd + 1;
|
||||
Anzahl3 = Anzahl * 3;
|
||||
status = Anzahl3 + Anzahl - statsize;
|
||||
}
|
||||
if (P(P_LI) == 0) {
|
||||
screen = Anzahl * (maxy - 1);
|
||||
maxy = LINES - 1;
|
||||
P(P_SS) = maxy / 2;
|
||||
}
|
||||
case BVICTRL('L'): /*** REDRAW SCREEN ***/
|
||||
new_screen();
|
||||
break;
|
||||
|
@ -491,9 +509,9 @@ main(argc, argv)
|
|||
break;
|
||||
case ';': do_ft(0, 0);
|
||||
break;
|
||||
case 'F':
|
||||
case 'f':
|
||||
case 't':
|
||||
case 'F':
|
||||
case 'f':
|
||||
case 't':
|
||||
case 'T': do_ft(ch, 0);
|
||||
break;
|
||||
case 'G': last_motion = current;
|
||||
|
@ -501,10 +519,10 @@ main(argc, argv)
|
|||
if ((precount < P(P_OF)) ||
|
||||
(precount - P(P_OF)) > (filesize - 1L)) {
|
||||
beep();
|
||||
} else {
|
||||
} else {
|
||||
setpage((PTR)(mem + precount - P(P_OF)));
|
||||
}
|
||||
} else {
|
||||
} else {
|
||||
setpage((PTR)(mem + filesize - 1L));
|
||||
}
|
||||
break;
|
||||
|
@ -735,8 +753,7 @@ main(argc, argv)
|
|||
|
||||
|
||||
off_t
|
||||
calc_size(arg)
|
||||
char *arg;
|
||||
calc_size(char *arg)
|
||||
{
|
||||
off_t val;
|
||||
extern int errno;
|
||||
|
@ -756,13 +773,13 @@ calc_size(arg)
|
|||
switch (*poi) {
|
||||
case 'k':
|
||||
case 'K': val *= 1024;
|
||||
break;
|
||||
break;
|
||||
case 'm':
|
||||
case 'M': val *= 1048576;
|
||||
break;
|
||||
break;
|
||||
case 'g':
|
||||
case 'G': val *= 1024*1024*1024LL;
|
||||
break;
|
||||
case 'G': val *= 1024*1024*1024LL;
|
||||
break;
|
||||
case '\0': break;
|
||||
default: usage();
|
||||
}
|
||||
|
@ -787,9 +804,7 @@ trunc_cur()
|
|||
|
||||
|
||||
int
|
||||
do_append(count, buf)
|
||||
off_t count;
|
||||
char *buf;
|
||||
do_append(off_t count, char *buf)
|
||||
{
|
||||
if (filesize + count > memsize) {
|
||||
if (enlarge(count + 100L)) return 1;
|
||||
|
@ -806,8 +821,7 @@ do_append(count, buf)
|
|||
|
||||
|
||||
void
|
||||
do_tilde(count)
|
||||
off_t count;
|
||||
do_tilde(off_t count)
|
||||
{
|
||||
if (filesize == 0L) return;
|
||||
undo_start = current;
|
||||
|
@ -893,10 +907,7 @@ do_undo()
|
|||
|
||||
|
||||
void
|
||||
do_over(loc, n, buf)
|
||||
PTR loc;
|
||||
off_t n;
|
||||
PTR buf;
|
||||
do_over(PTR loc, off_t n, PTR buf)
|
||||
{
|
||||
if (n < 1L) {
|
||||
emsg(nobytes);
|
||||
|
@ -918,10 +929,7 @@ do_over(loc, n, buf)
|
|||
|
||||
|
||||
void
|
||||
do_put(loc, n, buf)
|
||||
PTR loc;
|
||||
off_t n;
|
||||
PTR buf;
|
||||
do_put(PTR loc, off_t n, PTR buf)
|
||||
{
|
||||
if (n < 1L) {
|
||||
emsg(nobytes);
|
||||
|
@ -949,8 +957,7 @@ do_put(loc, n, buf)
|
|||
|
||||
/* argument sig not used, because only SIGINT will be catched */
|
||||
void
|
||||
jmpproc(sig)
|
||||
int sig;
|
||||
jmpproc(int sig)
|
||||
{
|
||||
if (P(P_EB)) beep();
|
||||
repaint();
|
||||
|
@ -961,8 +968,7 @@ jmpproc(sig)
|
|||
|
||||
|
||||
off_t
|
||||
range(ch)
|
||||
int ch;
|
||||
range(int ch)
|
||||
{
|
||||
int ch1;
|
||||
long count;
|
||||
|
@ -1033,7 +1039,7 @@ range(ch)
|
|||
- (off_t)P(P_OF)) > (filesize - 1L)) {
|
||||
beep();
|
||||
return 0;
|
||||
} else {
|
||||
} else {
|
||||
if (mem + count < current) {
|
||||
return(mem + count - current);
|
||||
} else {
|
||||
|
@ -1051,9 +1057,9 @@ range(ch)
|
|||
}
|
||||
end_addr = markbuf[mark - 'a'];
|
||||
if (end_addr == NULL) {
|
||||
beep();
|
||||
beep();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if (end_addr < current) {
|
||||
return(end_addr - current);
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue