1
0
Fork 0
mirror of https://github.com/vbatts/bvi.git synced 2025-10-04 05:31:01 +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:
Gerhard Bürgmann 2025-07-27 10:02:07 -04:00 committed by Vincent Batts
parent 75fc14b579
commit 50898d8d59
Signed by: vbatts
GPG key ID: E30EFAA812C6E5ED
28 changed files with 1936 additions and 1473 deletions

134
set.c
View file

@ -9,13 +9,14 @@
* 1999-07-02 V 1.2.0 beta
* 1999-08-14 V 1.2.0 final
* 2000-07-15 V 1.3.0 final
* 2001-10-10 V 1.3.1
* 2001-10-10 V 1.3.1
* 2003-07-03 V 1.3.2
* 2010-06-02 V 1.2.4
* 2014-09-30 V 1.4.0
* 2019-01-22 V 1.4.1
* 2025-07-19 V 1.5.0
*
* Copyright 1996-2019 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
@ -34,46 +35,47 @@
#include "bvi.h"
#include "set.h"
static int from_file = 0;
static int from_file = 0;
static FILE *ffp;
static char fbuf[MAXCMD+1];
static char buf[MAXCMD+1];
struct param params[] = {
{ "autowrite", "aw", FALSE, "", P_BOOL },
{ "columns", "cm", 16, "", P_NUM },
{ "columns", "cm", 0, "", P_NUM },
{ "errorbells", "eb", FALSE, "", P_BOOL },
{ "ignorecase", "ic", FALSE, "", P_BOOL },
{ "magic", "ma", TRUE, "", P_BOOL },
{ "magic", "ma", TRUE, "", P_BOOL },
{ "memmove", "mm", FALSE, "", P_BOOL },
{ "offset", "of", 0, "", P_NUM },
{ "offset", "of", 0, "", P_NUM },
{ "readonly", "ro", FALSE, "", P_BOOL },
{ "scroll", "scroll", 12, "", P_NUM },
{ "scroll", "scroll", 12, "", P_NUM },
{ "showmode", "mo", TRUE, "", P_BOOL },
{ "term", "term", 0, "", P_TEXT },
{ "terse", "terse", FALSE, "", P_BOOL },
{ "term", "term", 0, "", P_TEXT },
{ "terse", "terse", FALSE, "", P_BOOL },
{ "unixstyle", "us", FALSE, "", P_BOOL },
{ "window", "window", 25, "", P_NUM },
{ "wordlength", "wl", 4, "", P_NUM },
{ "window", "window", 0, "", P_NUM },
{ "wordlength", "wl", 4, "", P_NUM },
{ "wrapscan", "ws", TRUE, "", P_BOOL },
{ "highlight", "hl", TRUE, "", P_BOOL },
{ "reverse", "re", FALSE, "", P_BOOL },
{ "highlight", "hl", TRUE, "", P_BOOL },
{ "reverse", "re", FALSE, "", P_BOOL },
#if defined(__MSDOS__) && !defined(DJGPP)
{ "color", "co", 7, "", P_NUM },
{ "color", "co", 7, "", P_NUM },
#endif
{ "", "", 0, "", 0, } /* end marker */
{ "", "", 0, "", 0, } /* end marker */
};
int
doset(arg)
char *arg; /* parameter string */
doset(char *arg)
{
int i;
int i;
char *s;
int did_window = FALSE;
int state = TRUE; /* new state of boolean parms. */
int did_window = FALSE;
int state = TRUE; /* new state of boolean parms. */
char string[80];
off_t val;
if (arg == NULL) {
showparms(FALSE);
@ -111,20 +113,38 @@ doset(arg)
return 0;
}
if (!strcmp(params[i].fullname, "term")) {
emsg("Can't change type of terminal from within bvi");
emsg("Can't change@type of terminal from within bvi");
return 1;
}
if (params[i].flags & P_NUM) {
if ((i == P_LI) || (i == P_OF)) did_window++;
if ((i == P_LI) || (i == P_OF) || (i == P_CM)) did_window++;
if (arg[strlen(s)] != '=' || state == FALSE) {
sprintf(string, "Option %s is not a toggle",
params[i].fullname);
sprintf(string, "Option %s is not a toggle", params[i].fullname);
emsg(string);
return 1;
} else {
s = arg + strlen(s) + 1;
params[i].nvalue = strtoll(s, &s, 0);
val = strtoll(s, &s, 0);
if ((i == P_CM || i == P_LI) && (!strcmp("auto", s) || (val == 0))) {
if (i == P_CM) {
params[i].nvalue = 0;
Anzahl = ((COLS - AnzAdd - space) / 4);
} else {
params[i].nvalue = 0;
maxy = LINES - 1;
}
} else {
params[i].nvalue = val;
if (i == P_CM) {
Anzahl = val;
} else {
maxy = val;
}
}
params[i].flags |= P_CHANGED;
if (i == P_LI) params[P_SS].nvalue = val / 2;
#if defined(__MSDOS__) && !defined(DJGPP)
if (i == P_CO) {
textcolor(P(P_CO) & 0x07);
@ -134,22 +154,23 @@ doset(arg)
}
#endif
if (i == P_CM) {
/*
if (((COLS - AnzAdd - 1) / 4) >= P(P_CM)) {
Anzahl = P(P_CM);
} else {
Anzahl = P(P_CM) = ((COLS - AnzAdd - 1) / 4);
Anzahl = ((COLS - AnzAdd - 1) / 4);
}
maxx = Anzahl * 4 + AnzAdd + 1;
Anzahl3 = Anzahl * 3;
status = Anzahl3 + Anzahl - 17;
screen = Anzahl * (maxy - 1);
did_window++;
*/
maxx = Anzahl * 4 + AnzAdd + 1;
Anzahl3 = Anzahl * 3;
status = Anzahl3 + Anzahl - statsize;
screen = Anzahl * (maxy - 1);
stuffin("H"); /* set cursor at HOME */
}
}
} else { /* boolean */
if (arg[strlen(s)] == '=') {
emsg("Invalid set of boolean parameter");
emsg("Invalid set@of boolean parameter");
return 1;
} else {
params[i].nvalue = state;
@ -169,7 +190,10 @@ doset(arg)
}
if (did_window) {
/*
maxy = P(P_LI) - 1;
maxy = LINES - 1;
*/
new_screen();
}
@ -179,28 +203,33 @@ doset(arg)
/* show ALL parameters */
void
showparms(all)
int all;
showparms(int all)
{
struct param *p;
int n;
int n, i;
statusflag = 0;
n = 2;
i = -1;
msg("Parameters:\n");
for (p = &params[0]; p->fullname[0] != '\0' ;p++) {
i++;
if (!all && ((p->flags & P_CHANGED) == 0))
continue;
if (p->flags & P_BOOL)
sprintf(buf, " %s%s\n",
(p->nvalue ? " " : "no"), p->fullname);
else if (p->flags & P_TEXT)
if (p->flags & P_BOOL) {
sprintf(buf, " %s%s\n", (p->nvalue ? " " : "no"), p->fullname);
} else if (p->flags & P_TEXT) {
sprintf(buf, " %s=%s\n", p->fullname, p->svalue);
else
sprintf(buf, " %s=%lld\n", p->fullname, (long long)p->nvalue);
} else {
if ((p->nvalue == 0) && (i == P_CM || i == P_LI)) {
sprintf(buf, " %s=auto\n", p->fullname);
} else {
sprintf(buf, " %s=%lld\n", p->fullname, (long long)p->nvalue);
}
}
msg(buf);
n++;
if (n == params[P_LI].nvalue) {
if (n == maxy) {
if (wait_return(FALSE)) return;
n = 1;
}
@ -211,8 +240,7 @@ showparms(all)
/* reads the init file (.bvirc) */
int
read_rc(fn)
char *fn;
read_rc(char *fn)
{
int i;
@ -230,9 +258,7 @@ read_rc(fn)
int
do_logic(mode, str)
int mode;
char *str;
do_logic(int mode, char *str)
{
int a, b;
int value;
@ -289,13 +315,13 @@ do_logic(mode, str)
b = a >> 8;
a |= b;
break;
case RROTATE:
case RROTATE:
b = a << 8;
a |= b;
a >>= value;
a >>= value;
/*
b = a << (8 - value);
a >>= value;
a >>= value;
a |= b;
*/
break;
@ -303,7 +329,7 @@ do_logic(mode, str)
break;
case OR: a |= value;
break;
case XOR:
case XOR:
case NOT: a ^= value;
break;
case NEG: a ^= value;
@ -318,9 +344,7 @@ do_logic(mode, str)
int
getcmdstr(p, x)
char *p;
int x;
getcmdstr(char *p, int x)
{
int c;
int i, n;