add gitignore, clang-format, build script; merge src's patch for spaces in filenames
This commit is contained in:
parent
cf57dbe235
commit
5540d37849
38 changed files with 15300 additions and 15770 deletions
23
.clang-format
Normal file
23
.clang-format
Normal file
|
@ -0,0 +1,23 @@
|
|||
TabWidth: 2
|
||||
IndentWidth: 2
|
||||
ContinuationIndentWidth: 2
|
||||
UseTab: Never
|
||||
AllowShortBlocksOnASingleLine: Always
|
||||
AllowShortCaseLabelsOnASingleLine: false
|
||||
AllowShortEnumsOnASingleLine: true
|
||||
AllowShortIfStatementsOnASingleLine: false
|
||||
AllowShortLoopsOnASingleLine: false
|
||||
AlwaysBreakAfterDefinitionReturnType: None
|
||||
PenaltyReturnTypeOnItsOwnLine: 255
|
||||
IndentCaseLabels: true
|
||||
SpaceBeforeParens: ControlStatements
|
||||
AlignAfterOpenBracket: AlwaysBreak
|
||||
BinPackArguments: false
|
||||
BinPackArguments: false
|
||||
PointerAlignment: Left
|
||||
BreakBeforeBraces: Attach
|
||||
SortIncludes: false
|
||||
AllowAllArgumentsOnNextLine: false
|
||||
AllowAllParametersOfDeclarationOnNextLine: false
|
||||
AlignEscapedNewlines: Left
|
||||
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,2 +1,3 @@
|
|||
**/*.o
|
||||
**/o.*
|
||||
acme
|
||||
|
|
295
acme.c
295
acme.c
|
@ -37,11 +37,9 @@ enum{
|
|||
};
|
||||
Rune snarfrune[NSnarf + 1];
|
||||
|
||||
char *fontnames[2] =
|
||||
{
|
||||
char* fontnames[2] = {
|
||||
"/lib/font/bit/lucsans/typeunicode.7.font",
|
||||
"/lib/font/bit/lucm/unicode.9.font"
|
||||
};
|
||||
"/lib/font/bit/lucm/unicode.9.font"};
|
||||
|
||||
Command* command;
|
||||
|
||||
|
@ -50,16 +48,12 @@ void acmeerrorinit(void);
|
|||
void readfile(Column*, char*);
|
||||
static int shutdown(void*, char*);
|
||||
|
||||
void
|
||||
derror(Display *d, char *errorstr)
|
||||
{
|
||||
void derror(Display* d, char* errorstr) {
|
||||
USED(d);
|
||||
error(errorstr);
|
||||
}
|
||||
|
||||
void
|
||||
threadmain(int argc, char *argv[])
|
||||
{
|
||||
void threadmain(int argc, char* argv[]) {
|
||||
int i;
|
||||
char *p, *loadfile;
|
||||
Column* c;
|
||||
|
@ -72,11 +66,10 @@ threadmain(int argc, char *argv[])
|
|||
|
||||
loadfile = nil;
|
||||
ARGBEGIN {
|
||||
case 'D':
|
||||
{extern int _threaddebuglevel;
|
||||
case 'D': {
|
||||
extern int _threaddebuglevel;
|
||||
_threaddebuglevel = ~0;
|
||||
}
|
||||
break;
|
||||
} break;
|
||||
case 'a':
|
||||
globalindent[AUTOINDENT] = TRUE;
|
||||
break;
|
||||
|
@ -124,9 +117,13 @@ threadmain(int argc, char *argv[])
|
|||
break;
|
||||
default:
|
||||
Usage:
|
||||
fprint(2, "usage: acme -aib -c ncol -f fontname -F fixedwidthfontname -l loadfile -W winsize\n");
|
||||
fprint(
|
||||
2,
|
||||
"usage: acme -aib -c ncol -f fontname -F fixedwidthfontname -l "
|
||||
"loadfile -W winsize\n");
|
||||
threadexitsall("usage");
|
||||
}ARGEND
|
||||
}
|
||||
ARGEND
|
||||
|
||||
fontnames[0] = estrdup(fontnames[0]);
|
||||
fontnames[1] = estrdup(fontnames[1]);
|
||||
|
@ -197,7 +194,9 @@ threadmain(int argc, char *argv[])
|
|||
cedit = chancreate(sizeof(int), 0);
|
||||
cexit = chancreate(sizeof(int), 0);
|
||||
cwarn = chancreate(sizeof(void*), 1);
|
||||
if(cwait==nil || ccommand==nil || ckill==nil || cxfidalloc==nil || cxfidfree==nil || cerr==nil || cexit==nil || cwarn==nil){
|
||||
if (
|
||||
cwait == nil || ccommand == nil || ckill == nil || cxfidalloc == nil ||
|
||||
cxfidfree == nil || cerr == nil || cexit == nil || cwarn == nil) {
|
||||
fprint(2, "acme: can't create initial channels: %r\n");
|
||||
threadexitsall("channels");
|
||||
}
|
||||
|
@ -284,9 +283,7 @@ threadmain(int argc, char *argv[])
|
|||
threadexitsall(nil);
|
||||
}
|
||||
|
||||
void
|
||||
readfile(Column *c, char *s)
|
||||
{
|
||||
void readfile(Column* c, char* s) {
|
||||
Window* w;
|
||||
Rune rb[256];
|
||||
int nr;
|
||||
|
@ -310,27 +307,14 @@ readfile(Column *c, char *s)
|
|||
xfidlog(w, "new");
|
||||
}
|
||||
|
||||
char *ignotes[] = {
|
||||
"sys: write on closed pipe",
|
||||
"sys: ttin",
|
||||
"sys: ttou",
|
||||
"sys: tstp",
|
||||
nil
|
||||
};
|
||||
char* ignotes[] =
|
||||
{"sys: write on closed pipe", "sys: ttin", "sys: ttou", "sys: tstp", nil};
|
||||
|
||||
char *oknotes[] ={
|
||||
"delete",
|
||||
"hangup",
|
||||
"kill",
|
||||
"exit",
|
||||
nil
|
||||
};
|
||||
char* oknotes[] = {"delete", "hangup", "kill", "exit", nil};
|
||||
|
||||
int dumping;
|
||||
|
||||
static int
|
||||
shutdown(void *v, char *msg)
|
||||
{
|
||||
static int shutdown(void* v, char* msg) {
|
||||
int i;
|
||||
|
||||
USED(v);
|
||||
|
@ -340,7 +324,9 @@ shutdown(void *v, char *msg)
|
|||
return 1;
|
||||
|
||||
killprocs();
|
||||
if(!dumping && strcmp(msg, "kill")!=0 && strcmp(msg, "exit")!=0 && getpid()==mainpid){
|
||||
if (
|
||||
!dumping && strcmp(msg, "kill") != 0 && strcmp(msg, "exit") != 0 &&
|
||||
getpid() == mainpid) {
|
||||
dumping = TRUE;
|
||||
rowdump(&row, nil);
|
||||
}
|
||||
|
@ -367,9 +353,7 @@ shutdownthread(void *v)
|
|||
}
|
||||
*/
|
||||
|
||||
void
|
||||
killprocs(void)
|
||||
{
|
||||
void killprocs(void) {
|
||||
Command* c;
|
||||
|
||||
fsysclose();
|
||||
|
@ -383,9 +367,7 @@ killprocs(void)
|
|||
static int errorfd;
|
||||
int erroutfd;
|
||||
|
||||
void
|
||||
acmeerrorproc(void *v)
|
||||
{
|
||||
void acmeerrorproc(void* v) {
|
||||
char *buf, *s;
|
||||
int n;
|
||||
|
||||
|
@ -401,9 +383,7 @@ acmeerrorproc(void *v)
|
|||
free(buf);
|
||||
}
|
||||
|
||||
void
|
||||
acmeerrorinit(void)
|
||||
{
|
||||
void acmeerrorinit(void) {
|
||||
int pfd[2];
|
||||
|
||||
if (pipe(pfd) < 0)
|
||||
|
@ -450,9 +430,7 @@ plumbproc(void *v)
|
|||
}
|
||||
*/
|
||||
|
||||
void
|
||||
keyboardthread(void *v)
|
||||
{
|
||||
void keyboardthread(void* v) {
|
||||
Rune r;
|
||||
Timer* timer;
|
||||
Text* t;
|
||||
|
@ -489,7 +467,10 @@ keyboardthread(void *v)
|
|||
casekeyboard:
|
||||
typetext = rowtype(&row, r, mouse->xy);
|
||||
t = typetext;
|
||||
if(t!=nil && t->col!=nil && !(r==Kdown || r==Kleft || r==Kright)) /* scrolling doesn't change activecol */
|
||||
if (
|
||||
t != nil && t->col != nil &&
|
||||
!(r == Kdown || r == Kleft ||
|
||||
r == Kright)) /* scrolling doesn't change activecol */
|
||||
activecol = t->col;
|
||||
if (t != nil && t->w != nil)
|
||||
t->w->body.file->curtext = &t->w->body;
|
||||
|
@ -512,9 +493,7 @@ keyboardthread(void *v)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
mousethread(void *v)
|
||||
{
|
||||
void mousethread(void* v) {
|
||||
Text *t, *argt;
|
||||
int but;
|
||||
uint q0, q1;
|
||||
|
@ -552,7 +531,12 @@ mousethread(void *v)
|
|||
case MResize:
|
||||
if (getwindow(display, Refnone) < 0)
|
||||
error("attach to window");
|
||||
draw(screen, screen->r, allocimage(display, Rect(0,0,1,1), screen->chan, 1, 0x222222FF), nil, ZP);
|
||||
draw(
|
||||
screen,
|
||||
screen->r,
|
||||
allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, 0x222222FF),
|
||||
nil,
|
||||
ZP);
|
||||
iconinit();
|
||||
scrlresize();
|
||||
rowresize(&row, screen->clipr);
|
||||
|
@ -579,8 +563,10 @@ mousethread(void *v)
|
|||
qlock(&row.lk);
|
||||
t = rowwhich(&row, m.xy);
|
||||
|
||||
if((t!=mousetext && t!=nil && t->w!=nil) &&
|
||||
(mousetext==nil || mousetext->w==nil || t->w->id!=mousetext->w->id)) {
|
||||
if (
|
||||
(t != mousetext && t != nil && t->w != nil) &&
|
||||
(mousetext == nil || mousetext->w == nil ||
|
||||
t->w->id != mousetext->w->id)) {
|
||||
xfidlog(t->w, "focus");
|
||||
}
|
||||
|
||||
|
@ -682,20 +668,18 @@ mousethread(void *v)
|
|||
}
|
||||
|
||||
/*
|
||||
* There is a race between process exiting and our finding out it was ever created.
|
||||
* This structure keeps a list of processes that have exited we haven't heard of.
|
||||
* There is a race between process exiting and our finding out it was ever
|
||||
* created. This structure keeps a list of processes that have exited we haven't
|
||||
* heard of.
|
||||
*/
|
||||
typedef struct Pid Pid;
|
||||
struct Pid
|
||||
{
|
||||
struct Pid {
|
||||
int pid;
|
||||
char msg[ERRMAX];
|
||||
Pid* next;
|
||||
};
|
||||
|
||||
void
|
||||
waitthread(void *v)
|
||||
{
|
||||
void waitthread(void* v) {
|
||||
Waitmsg* w;
|
||||
Command *c, *lc;
|
||||
uint pid;
|
||||
|
@ -825,9 +809,7 @@ waitthread(void *v)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
xfidallocthread(void *v)
|
||||
{
|
||||
void xfidallocthread(void* v) {
|
||||
Xfid *xfree, *x;
|
||||
enum { Alloc, Free, N };
|
||||
static Alt alts[N + 1];
|
||||
|
@ -866,10 +848,9 @@ xfidallocthread(void *v)
|
|||
}
|
||||
}
|
||||
|
||||
/* this thread, in the main proc, allows fsysproc to get a window made without doing graphics */
|
||||
void
|
||||
newwindowthread(void *v)
|
||||
{
|
||||
/* this thread, in the main proc, allows fsysproc to get a window made without
|
||||
* doing graphics */
|
||||
void newwindowthread(void* v) {
|
||||
Window* w;
|
||||
|
||||
USED(v);
|
||||
|
@ -885,9 +866,7 @@ newwindowthread(void *v)
|
|||
}
|
||||
}
|
||||
|
||||
Reffont*
|
||||
rfget(int fix, int save, int setfont, char *name)
|
||||
{
|
||||
Reffont* rfget(int fix, int save, int setfont, char* name) {
|
||||
Reffont* r;
|
||||
Font* f;
|
||||
int i;
|
||||
|
@ -937,9 +916,7 @@ rfget(int fix, int save, int setfont, char *name)
|
|||
return r;
|
||||
}
|
||||
|
||||
void
|
||||
rfclose(Reffont *r)
|
||||
{
|
||||
void rfclose(Reffont* r) {
|
||||
int i;
|
||||
|
||||
if (decref(&r->ref) == 0) {
|
||||
|
@ -950,7 +927,10 @@ rfclose(Reffont *r)
|
|||
warning(nil, "internal error: can't find font in cache\n");
|
||||
else {
|
||||
nfontcache--;
|
||||
memmove(fontcache+i, fontcache+i+1, (nfontcache-i)*sizeof(Reffont*));
|
||||
memmove(
|
||||
fontcache + i,
|
||||
fontcache + i + 1,
|
||||
(nfontcache - i) * sizeof(Reffont*));
|
||||
}
|
||||
freefont(r->f);
|
||||
free(r);
|
||||
|
@ -959,103 +939,61 @@ rfclose(Reffont *r)
|
|||
|
||||
Cursor boxcursor = {
|
||||
{-7, -7},
|
||||
{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xF8, 0x1F, 0xF8, 0x1F, 0xF8, 0x1F,
|
||||
0xF8, 0x1F, 0xF8, 0x1F, 0xF8, 0x1F, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF},
|
||||
{0x00, 0x00, 0x7F, 0xFE, 0x7F, 0xFE, 0x7F, 0xFE,
|
||||
0x70, 0x0E, 0x70, 0x0E, 0x70, 0x0E, 0x70, 0x0E,
|
||||
0x70, 0x0E, 0x70, 0x0E, 0x70, 0x0E, 0x70, 0x0E,
|
||||
0x7F, 0xFE, 0x7F, 0xFE, 0x7F, 0xFE, 0x00, 0x00}
|
||||
};
|
||||
{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF8,
|
||||
0x1F, 0xF8, 0x1F, 0xF8, 0x1F, 0xF8, 0x1F, 0xF8, 0x1F, 0xF8, 0x1F,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF},
|
||||
{0x00, 0x00, 0x7F, 0xFE, 0x7F, 0xFE, 0x7F, 0xFE, 0x70, 0x0E, 0x70,
|
||||
0x0E, 0x70, 0x0E, 0x70, 0x0E, 0x70, 0x0E, 0x70, 0x0E, 0x70, 0x0E,
|
||||
0x70, 0x0E, 0x7F, 0xFE, 0x7F, 0xFE, 0x7F, 0xFE, 0x00, 0x00}};
|
||||
|
||||
Cursor2 boxcursor2 = {
|
||||
{-15, -15},
|
||||
{0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xC0, 0x03, 0xFF,
|
||||
0xFF, 0xC0, 0x03, 0xFF,
|
||||
0xFF, 0xC0, 0x03, 0xFF,
|
||||
0xFF, 0xC0, 0x03, 0xFF,
|
||||
0xFF, 0xC0, 0x03, 0xFF,
|
||||
0xFF, 0xC0, 0x03, 0xFF,
|
||||
0xFF, 0xC0, 0x03, 0xFF,
|
||||
0xFF, 0xC0, 0x03, 0xFF,
|
||||
0xFF, 0xC0, 0x03, 0xFF,
|
||||
0xFF, 0xC0, 0x03, 0xFF,
|
||||
0xFF, 0xC0, 0x03, 0xFF,
|
||||
0xFF, 0xC0, 0x03, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF},
|
||||
{0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x3F, 0xFF, 0xFF, 0xFC,
|
||||
0x3F, 0xFF, 0xFF, 0xFC,
|
||||
0x3F, 0xFF, 0xFF, 0xFC,
|
||||
0x3F, 0xFF, 0xFF, 0xFC,
|
||||
0x3F, 0xFF, 0xFF, 0xFC,
|
||||
0x3F, 0xFF, 0xFF, 0xFC,
|
||||
0x3F, 0x00, 0x00, 0xFC,
|
||||
0x3F, 0x00, 0x00, 0xFC,
|
||||
0x3F, 0x00, 0x00, 0xFC,
|
||||
0x3F, 0x00, 0x00, 0xFC,
|
||||
0x3F, 0x00, 0x00, 0xFC,
|
||||
0x3F, 0x00, 0x00, 0xFC,
|
||||
0x3F, 0x00, 0x00, 0xFC,
|
||||
0x3F, 0x00, 0x00, 0xFC,
|
||||
0x3F, 0x00, 0x00, 0xFC,
|
||||
0x3F, 0x00, 0x00, 0xFC,
|
||||
0x3F, 0x00, 0x00, 0xFC,
|
||||
0x3F, 0x00, 0x00, 0xFC,
|
||||
0x3F, 0x00, 0x00, 0xFC,
|
||||
0x3F, 0x00, 0x00, 0xFC,
|
||||
0x3F, 0x00, 0x00, 0xFC,
|
||||
0x3F, 0x00, 0x00, 0xFC,
|
||||
0x3F, 0xFF, 0xFF, 0xFC,
|
||||
0x3F, 0xFF, 0xFF, 0xFC,
|
||||
0x3F, 0xFF, 0xFF, 0xFC,
|
||||
0x3F, 0xFF, 0xFF, 0xFC,
|
||||
0x3F, 0xFF, 0xFF, 0xFC,
|
||||
0x3F, 0xFF, 0xFF, 0xFC,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00}
|
||||
};
|
||||
{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xC0, 0x03, 0xFF, 0xFF, 0xC0, 0x03, 0xFF, 0xFF, 0xC0, 0x03, 0xFF,
|
||||
0xFF, 0xC0, 0x03, 0xFF, 0xFF, 0xC0, 0x03, 0xFF, 0xFF, 0xC0, 0x03, 0xFF, 0xFF,
|
||||
0xC0, 0x03, 0xFF, 0xFF, 0xC0, 0x03, 0xFF, 0xFF, 0xC0, 0x03, 0xFF, 0xFF, 0xC0,
|
||||
0x03, 0xFF, 0xFF, 0xC0, 0x03, 0xFF, 0xFF, 0xC0, 0x03, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF},
|
||||
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xFF, 0xFF, 0xFC, 0x3F,
|
||||
0xFF, 0xFF, 0xFC, 0x3F, 0xFF, 0xFF, 0xFC, 0x3F, 0xFF, 0xFF, 0xFC, 0x3F, 0xFF,
|
||||
0xFF, 0xFC, 0x3F, 0xFF, 0xFF, 0xFC, 0x3F, 0x00, 0x00, 0xFC, 0x3F, 0x00, 0x00,
|
||||
0xFC, 0x3F, 0x00, 0x00, 0xFC, 0x3F, 0x00, 0x00, 0xFC, 0x3F, 0x00, 0x00, 0xFC,
|
||||
0x3F, 0x00, 0x00, 0xFC, 0x3F, 0x00, 0x00, 0xFC, 0x3F, 0x00, 0x00, 0xFC, 0x3F,
|
||||
0x00, 0x00, 0xFC, 0x3F, 0x00, 0x00, 0xFC, 0x3F, 0x00, 0x00, 0xFC, 0x3F, 0x00,
|
||||
0x00, 0xFC, 0x3F, 0x00, 0x00, 0xFC, 0x3F, 0x00, 0x00, 0xFC, 0x3F, 0x00, 0x00,
|
||||
0xFC, 0x3F, 0x00, 0x00, 0xFC, 0x3F, 0xFF, 0xFF, 0xFC, 0x3F, 0xFF, 0xFF, 0xFC,
|
||||
0x3F, 0xFF, 0xFF, 0xFC, 0x3F, 0xFF, 0xFF, 0xFC, 0x3F, 0xFF, 0xFF, 0xFC, 0x3F,
|
||||
0xFF, 0xFF, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}};
|
||||
|
||||
void
|
||||
iconinit(void)
|
||||
{
|
||||
void iconinit(void) {
|
||||
Rectangle r;
|
||||
Image* tmp;
|
||||
|
||||
if (tagcols[BACK] == nil) {
|
||||
/* Black */
|
||||
tagcols[BACK] = allocimage(display, Rect(0,0,1,1), screen->chan, 1, DBlack);
|
||||
tagcols[HIGH] = allocimage(display, Rect(0,0,1,1), screen->chan, 1, 0x1F9B92FF);
|
||||
tagcols[BORD] = allocimage(display, Rect(0,0,1,1), screen->chan, 1, 0x797979FF);
|
||||
tagcols[TEXT] = allocimage(display, Rect(0,0,1,1), screen->chan, 1, 0x797979FF);
|
||||
tagcols[BACK] =
|
||||
allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, DBlack);
|
||||
tagcols[HIGH] =
|
||||
allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, 0x1F9B92FF);
|
||||
tagcols[BORD] =
|
||||
allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, 0x797979FF);
|
||||
tagcols[TEXT] =
|
||||
allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, 0x797979FF);
|
||||
tagcols[HTEXT] = display->black;
|
||||
|
||||
/* Blue */
|
||||
textcols[BACK] = allocimage(display, Rect(0,0,1,1), screen->chan, 1, 0x000F19FF);
|
||||
textcols[HIGH] = allocimage(display, Rect(0,0,1,1), screen->chan, 1, 0x1F9B92FF);
|
||||
textcols[BORD] = allocimage(display, Rect(0,0,1,1), screen->chan, 1, 0x93A1A1FF);
|
||||
textcols[TEXT] = allocimage(display, Rect(0,0,1,1), screen->chan, 1, 0x93A1A1FF);
|
||||
textcols[BACK] =
|
||||
allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, 0x000F19FF);
|
||||
textcols[HIGH] =
|
||||
allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, 0x1F9B92FF);
|
||||
textcols[BORD] =
|
||||
allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, 0x93A1A1FF);
|
||||
textcols[TEXT] =
|
||||
allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, 0x93A1A1FF);
|
||||
textcols[HTEXT] = display->black;
|
||||
}
|
||||
|
||||
|
@ -1101,9 +1039,7 @@ iconinit(void)
|
|||
|
||||
#define MAXSNARF 100 * 1024
|
||||
|
||||
void
|
||||
acmeputsnarf(void)
|
||||
{
|
||||
void acmeputsnarf(void) {
|
||||
int i, n;
|
||||
Fmt f;
|
||||
char* s;
|
||||
|
@ -1128,9 +1064,7 @@ acmeputsnarf(void)
|
|||
free(s);
|
||||
}
|
||||
|
||||
void
|
||||
acmegetsnarf(void)
|
||||
{
|
||||
void acmegetsnarf(void) {
|
||||
char* s;
|
||||
int nb, nr, nulls, len;
|
||||
Rune* r;
|
||||
|
@ -1150,9 +1084,7 @@ acmegetsnarf(void)
|
|||
free(s);
|
||||
}
|
||||
|
||||
int
|
||||
ismtpt(char *file)
|
||||
{
|
||||
int ismtpt(char* file) {
|
||||
int n;
|
||||
|
||||
if (mtpt == nil)
|
||||
|
@ -1160,16 +1092,21 @@ ismtpt(char *file)
|
|||
|
||||
/* This is not foolproof, but it will stop a lot of them. */
|
||||
n = strlen(mtpt);
|
||||
return strncmp(file, mtpt, n) == 0 && ((n > 0 && mtpt[n-1] == '/') || file[n] == '/' || file[n] == 0);
|
||||
return strncmp(file, mtpt, n) == 0 &&
|
||||
((n > 0 && mtpt[n - 1] == '/') || file[n] == '/' || file[n] == 0);
|
||||
}
|
||||
|
||||
int
|
||||
timefmt(Fmt *f)
|
||||
{
|
||||
int timefmt(Fmt* f) {
|
||||
Tm* tm;
|
||||
|
||||
tm = localtime(va_arg(f->args, ulong));
|
||||
return fmtprint(f, "%04d/%02d/%02d %02d:%02d:%02d",
|
||||
tm->year+1900, tm->mon+1, tm->mday, tm->hour, tm->min, tm->sec);
|
||||
return fmtprint(
|
||||
f,
|
||||
"%04d/%02d/%02d %02d:%02d:%02d",
|
||||
tm->year + 1900,
|
||||
tm->mon + 1,
|
||||
tm->mday,
|
||||
tm->hour,
|
||||
tm->min,
|
||||
tm->sec);
|
||||
}
|
||||
|
||||
|
|
62
addr.c
62
addr.c
|
@ -12,34 +12,22 @@
|
|||
#include "dat.h"
|
||||
#include "fns.h"
|
||||
|
||||
enum
|
||||
{
|
||||
None = 0,
|
||||
Fore = '+',
|
||||
Back = '-'
|
||||
};
|
||||
enum { None = 0, Fore = '+', Back = '-' };
|
||||
|
||||
enum
|
||||
{
|
||||
Char,
|
||||
Line
|
||||
};
|
||||
enum { Char, Line };
|
||||
|
||||
int
|
||||
isaddrc(int r)
|
||||
{
|
||||
int isaddrc(int r) {
|
||||
if (r && utfrune("0123456789+-/$.#,;?", r) != nil)
|
||||
return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
* quite hard: could be almost anything but white space, but we are a little conservative,
|
||||
* aiming for regular expressions of alphanumerics and no white space
|
||||
* quite hard: could be almost anything but white space, but we are a little
|
||||
* conservative, aiming for regular expressions of alphanumerics and no white
|
||||
* space
|
||||
*/
|
||||
int
|
||||
isregexc(int r)
|
||||
{
|
||||
int isregexc(int r) {
|
||||
if (r == 0)
|
||||
return FALSE;
|
||||
if (isalnum(r))
|
||||
|
@ -54,9 +42,7 @@ isregexc(int r)
|
|||
// and then nr chars, being careful not to walk past
|
||||
// the end of the current line.
|
||||
// It returns the final position.
|
||||
long
|
||||
nlcounttopos(Text *t, long q0, long nl, long nr)
|
||||
{
|
||||
long nlcounttopos(Text* t, long q0, long nl, long nr) {
|
||||
while (nl > 0 && q0 < t->file->b.nc) {
|
||||
if (textreadc(t, q0++) == '\n')
|
||||
nl--;
|
||||
|
@ -70,9 +56,8 @@ nlcounttopos(Text *t, long q0, long nl, long nr)
|
|||
return q0;
|
||||
}
|
||||
|
||||
Range
|
||||
number(uint showerr, Text *t, Range r, int line, int dir, int size, int *evalp)
|
||||
{
|
||||
Range number(
|
||||
uint showerr, Text* t, Range r, int line, int dir, int size, int* evalp) {
|
||||
uint q0, q1;
|
||||
|
||||
if (size == Char) {
|
||||
|
@ -138,10 +123,8 @@ number(uint showerr, Text *t, Range r, int line, int dir, int size, int *evalp)
|
|||
return r;
|
||||
}
|
||||
|
||||
|
||||
Range
|
||||
regexp(uint showerr, Text *t, Range lim, Range r, Rune *pat, int dir, int *foundp)
|
||||
{
|
||||
Range regexp(
|
||||
uint showerr, Text* t, Range lim, Range r, Rune* pat, int dir, int* foundp) {
|
||||
int found;
|
||||
Rangeset sel;
|
||||
int q;
|
||||
|
@ -171,9 +154,9 @@ regexp(uint showerr, Text *t, Range lim, Range r, Rune *pat, int dir, int *found
|
|||
return sel.r[0];
|
||||
}
|
||||
|
||||
Range
|
||||
address(uint showerr, Text *t, Range lim, Range ar, void *a, uint q0, uint q1, int (*getc)(void*, uint), int *evalp, uint *qp)
|
||||
{
|
||||
Range address(
|
||||
uint showerr, Text* t, Range lim, Range ar, void* a, uint q0, uint q1,
|
||||
int (*getc)(void*, uint), int* evalp, uint* qp) {
|
||||
int dir, size, npat;
|
||||
int prevc, c, nc, n;
|
||||
uint q;
|
||||
|
@ -210,7 +193,8 @@ address(uint showerr, Text *t, Range lim, Range ar, void *a, uint q0, uint q1, i
|
|||
case '-':
|
||||
if (*evalp && (prevc == '+' || prevc == '-'))
|
||||
if ((nc = (*getc)(a, q)) != '#' && nc != '/' && nc != '?')
|
||||
r = number(showerr, t, r, 1, prevc, Line, evalp); /* do previous one */
|
||||
r = number(showerr, t, r, 1, prevc, Line, evalp); /* do previous one
|
||||
*/
|
||||
dir = c;
|
||||
break;
|
||||
case '.':
|
||||
|
@ -236,8 +220,16 @@ address(uint showerr, Text *t, Range lim, Range ar, void *a, uint q0, uint q1, i
|
|||
}
|
||||
size = Char;
|
||||
/* fall through */
|
||||
case '0': case '1': case '2': case '3': case '4':
|
||||
case '5': case '6': case '7': case '8': case '9':
|
||||
case '0':
|
||||
case '1':
|
||||
case '2':
|
||||
case '3':
|
||||
case '4':
|
||||
case '5':
|
||||
case '6':
|
||||
case '7':
|
||||
case '8':
|
||||
case '9':
|
||||
n = c - '0';
|
||||
while (q < q1) {
|
||||
nc = (*getc)(a, q++);
|
||||
|
|
62
buff.c
62
buff.c
|
@ -12,25 +12,18 @@
|
|||
#include "dat.h"
|
||||
#include "fns.h"
|
||||
|
||||
enum
|
||||
{
|
||||
enum {
|
||||
Slop = 100 /* room to grow with reallocation */
|
||||
};
|
||||
|
||||
static
|
||||
void
|
||||
sizecache(Buffer *b, uint n)
|
||||
{
|
||||
static void sizecache(Buffer* b, uint n) {
|
||||
if (n <= b->cmax)
|
||||
return;
|
||||
b->cmax = n + Slop;
|
||||
b->c = runerealloc(b->c, b->cmax);
|
||||
}
|
||||
|
||||
static
|
||||
void
|
||||
addblock(Buffer *b, uint i, uint n)
|
||||
{
|
||||
static void addblock(Buffer* b, uint i, uint n) {
|
||||
if (i > b->nbl)
|
||||
error("internal error: addblock");
|
||||
|
||||
|
@ -41,10 +34,7 @@ addblock(Buffer *b, uint i, uint n)
|
|||
b->nbl++;
|
||||
}
|
||||
|
||||
static
|
||||
void
|
||||
delblock(Buffer *b, uint i)
|
||||
{
|
||||
static void delblock(Buffer* b, uint i) {
|
||||
if (i >= b->nbl)
|
||||
error("internal error: delblock");
|
||||
|
||||
|
@ -60,10 +50,7 @@ delblock(Buffer *b, uint i)
|
|||
* If at very end, q0 will fall on end of cache block.
|
||||
*/
|
||||
|
||||
static
|
||||
void
|
||||
flush(Buffer *b)
|
||||
{
|
||||
static void flush(Buffer* b) {
|
||||
if (b->cdirty || b->cnc == 0) {
|
||||
if (b->cnc == 0)
|
||||
delblock(b, b->cbi);
|
||||
|
@ -73,10 +60,7 @@ flush(Buffer *b)
|
|||
}
|
||||
}
|
||||
|
||||
static
|
||||
void
|
||||
setcache(Buffer *b, uint q0)
|
||||
{
|
||||
static void setcache(Buffer* b, uint q0) {
|
||||
Block **blp, *bl;
|
||||
uint i, q;
|
||||
|
||||
|
@ -119,9 +103,7 @@ setcache(Buffer *b, uint q0)
|
|||
diskread(disk, bl, b->c, b->cnc);
|
||||
}
|
||||
|
||||
void
|
||||
bufinsert(Buffer *b, uint q0, Rune *s, uint n)
|
||||
{
|
||||
void bufinsert(Buffer* b, uint q0, Rune* s, uint n) {
|
||||
uint i, m, t, off;
|
||||
|
||||
if (q0 > b->nc)
|
||||
|
@ -200,9 +182,7 @@ bufinsert(Buffer *b, uint q0, Rune *s, uint n)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
bufdelete(Buffer *b, uint q0, uint q1)
|
||||
{
|
||||
void bufdelete(Buffer* b, uint q0, uint q1) {
|
||||
uint m, n, off;
|
||||
|
||||
if (!(q0 <= q1 && q0 <= b->nc && q1 <= b->nc))
|
||||
|
@ -224,16 +204,14 @@ bufdelete(Buffer *b, uint q0, uint q1)
|
|||
}
|
||||
}
|
||||
|
||||
static int
|
||||
bufloader(void *v, uint q0, Rune *r, int nr)
|
||||
{
|
||||
static int bufloader(void* v, uint q0, Rune* r, int nr) {
|
||||
bufinsert(v, q0, r, nr);
|
||||
return nr;
|
||||
}
|
||||
|
||||
uint
|
||||
loadfile(int fd, uint q0, int *nulls, int(*f)(void*, uint, Rune*, int), void *arg, DigestState *h)
|
||||
{
|
||||
uint loadfile(
|
||||
int fd, uint q0, int* nulls, int (*f)(void*, uint, Rune*, int), void* arg,
|
||||
DigestState* h) {
|
||||
char* p;
|
||||
Rune* r;
|
||||
int l, m, n, nb, nr;
|
||||
|
@ -271,17 +249,13 @@ loadfile(int fd, uint q0, int *nulls, int(*f)(void*, uint, Rune*, int), void *ar
|
|||
return q1 - q0;
|
||||
}
|
||||
|
||||
uint
|
||||
bufload(Buffer *b, uint q0, int fd, int *nulls, DigestState *h)
|
||||
{
|
||||
uint bufload(Buffer* b, uint q0, int fd, int* nulls, DigestState* h) {
|
||||
if (q0 > b->nc)
|
||||
error("internal error: bufload");
|
||||
return loadfile(fd, q0, nulls, bufloader, b, h);
|
||||
}
|
||||
|
||||
void
|
||||
bufread(Buffer *b, uint q0, Rune *s, uint n)
|
||||
{
|
||||
void bufread(Buffer* b, uint q0, Rune* s, uint n) {
|
||||
uint m;
|
||||
|
||||
if (!(q0 <= b->nc && q0 + n <= b->nc))
|
||||
|
@ -297,9 +271,7 @@ bufread(Buffer *b, uint q0, Rune *s, uint n)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
bufreset(Buffer *b)
|
||||
{
|
||||
void bufreset(Buffer* b) {
|
||||
int i;
|
||||
|
||||
b->nc = 0;
|
||||
|
@ -312,9 +284,7 @@ bufreset(Buffer *b)
|
|||
delblock(b, i);
|
||||
}
|
||||
|
||||
void
|
||||
bufclose(Buffer *b)
|
||||
{
|
||||
void bufclose(Buffer* b) {
|
||||
bufreset(b);
|
||||
free(b->c);
|
||||
b->c = nil;
|
||||
|
|
8
build.sh
Executable file
8
build.sh
Executable file
|
@ -0,0 +1,8 @@
|
|||
#!/bin/sh
|
||||
|
||||
clang-format -i ./*.c
|
||||
clang-format -i ./mail/*.c
|
||||
|
||||
mk
|
||||
|
||||
mv o.acme acme
|
153
cols.c
153
cols.c
|
@ -12,24 +12,21 @@
|
|||
#include "dat.h"
|
||||
#include "fns.h"
|
||||
|
||||
static Rune Lheader[] = {
|
||||
'N', 'e', 'w', ' ',
|
||||
'C', 'u', 't', ' ',
|
||||
'P', 'a', 's', 't', 'e', ' ',
|
||||
'S', 'n', 'a', 'r', 'f', ' ',
|
||||
'S', 'o', 'r', 't', ' ',
|
||||
'Z', 'e', 'r', 'o', 'x', ' ',
|
||||
'D', 'e', 'l', 'c', 'o', 'l', ' ',
|
||||
0
|
||||
};
|
||||
static Rune Lheader[] = {'N', 'e', 'w', ' ', 'C', 'u', 't', ' ', 'P', 'a',
|
||||
's', 't', 'e', ' ', 'S', 'n', 'a', 'r', 'f', ' ',
|
||||
'S', 'o', 'r', 't', ' ', 'Z', 'e', 'r', 'o', 'x',
|
||||
' ', 'D', 'e', 'l', 'c', 'o', 'l', ' ', 0};
|
||||
|
||||
void
|
||||
colinit(Column *c, Rectangle r)
|
||||
{
|
||||
void colinit(Column* c, Rectangle r) {
|
||||
Rectangle r1;
|
||||
Text* t;
|
||||
|
||||
draw(screen, r, allocimage(display,Rect(0,0,1,1), screen->chan, 1, 0x222222FF), nil, ZP);
|
||||
draw(
|
||||
screen,
|
||||
r,
|
||||
allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, 0x222222FF),
|
||||
nil,
|
||||
ZP);
|
||||
c->r = r;
|
||||
c->w = nil;
|
||||
c->nw = 0;
|
||||
|
@ -42,16 +39,19 @@ colinit(Column *c, Rectangle r)
|
|||
t->what = Columntag;
|
||||
r1.min.y = r1.max.y;
|
||||
r1.max.y += Border;
|
||||
draw(screen, r1, allocimage(display, Rect(0,0,1,1), screen->chan, 1, 0x222222FF), nil, ZP);
|
||||
draw(
|
||||
screen,
|
||||
r1,
|
||||
allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, 0x222222FF),
|
||||
nil,
|
||||
ZP);
|
||||
textinsert(t, 0, Lheader, 38, TRUE);
|
||||
textsetselect(t, t->file->b.nc, t->file->b.nc);
|
||||
draw(screen, t->scrollr, colbutton, nil, colbutton->r.min);
|
||||
c->safe = TRUE;
|
||||
}
|
||||
|
||||
Window*
|
||||
coladd(Column *c, Window *w, Window *clone, int y)
|
||||
{
|
||||
Window* coladd(Column* c, Window* w, Window* clone, int y) {
|
||||
Rectangle r, r1;
|
||||
Window* v;
|
||||
int i, j, minht, ymax, buggered;
|
||||
|
@ -113,11 +113,20 @@ coladd(Column *c, Window *w, Window *clone, int y)
|
|||
r.max.y = ymax;
|
||||
draw(screen, r, textcols[BACK], nil, ZP);
|
||||
r1 = r;
|
||||
y = min(y, ymax-(v->tag.fr.font->height*v->taglines+v->body.fr.font->height+Border+1));
|
||||
r1.max.y = min(y, v->body.fr.r.min.y+v->body.fr.nlines*v->body.fr.font->height);
|
||||
y = min(
|
||||
y,
|
||||
ymax - (v->tag.fr.font->height * v->taglines + v->body.fr.font->height +
|
||||
Border + 1));
|
||||
r1.max.y =
|
||||
min(y, v->body.fr.r.min.y + v->body.fr.nlines * v->body.fr.font->height);
|
||||
r1.min.y = winresize(v, r1, FALSE, FALSE);
|
||||
r1.max.y = r1.min.y + Border;
|
||||
draw(screen, r1, allocimage(display, Rect(0,0,1,1), screen->chan, 1, 0x222222FF), nil, ZP);
|
||||
draw(
|
||||
screen,
|
||||
r1,
|
||||
allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, 0x222222FF),
|
||||
nil,
|
||||
ZP);
|
||||
|
||||
/*
|
||||
* leave r with w's coordinates
|
||||
|
@ -154,9 +163,7 @@ coladd(Column *c, Window *w, Window *clone, int y)
|
|||
return w;
|
||||
}
|
||||
|
||||
void
|
||||
colclose(Column *c, Window *w, int dofree)
|
||||
{
|
||||
void colclose(Column* c, Window* w, int dofree) {
|
||||
Rectangle r;
|
||||
int i, didmouse, up;
|
||||
|
||||
|
@ -181,7 +188,12 @@ colclose(Column *c, Window *w, int dofree)
|
|||
memmove(c->w + i, c->w + i + 1, (c->nw - i) * sizeof(Window*));
|
||||
c->w = realloc(c->w, c->nw * sizeof(Window*));
|
||||
if (c->nw == 0) {
|
||||
draw(screen, r, allocimage(display, Rect(0,0,1,1), screen->chan, 1, 0x222222FF), nil, ZP);
|
||||
draw(
|
||||
screen,
|
||||
r,
|
||||
allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, 0x222222FF),
|
||||
nil,
|
||||
ZP);
|
||||
return;
|
||||
}
|
||||
up = 0;
|
||||
|
@ -204,9 +216,7 @@ colclose(Column *c, Window *w, int dofree)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
colcloseall(Column *c)
|
||||
{
|
||||
void colcloseall(Column* c) {
|
||||
int i;
|
||||
Window* w;
|
||||
|
||||
|
@ -223,15 +233,11 @@ colcloseall(Column *c)
|
|||
clearmouse();
|
||||
}
|
||||
|
||||
void
|
||||
colmousebut(Column *c)
|
||||
{
|
||||
void colmousebut(Column* c) {
|
||||
moveto(mousectl, divpt(addpt(c->tag.scrollr.min, c->tag.scrollr.max), 2));
|
||||
}
|
||||
|
||||
void
|
||||
colresize(Column *c, Rectangle r)
|
||||
{
|
||||
void colresize(Column* c, Rectangle r) {
|
||||
int i;
|
||||
Rectangle r1, r2;
|
||||
Window* w;
|
||||
|
@ -243,7 +249,12 @@ colresize(Column *c, Rectangle r)
|
|||
draw(screen, c->tag.scrollr, colbutton, nil, colbutton->r.min);
|
||||
r1.min.y = r1.max.y;
|
||||
r1.max.y += Border;
|
||||
draw(screen, r1, allocimage(display, Rect(0,0,1,1), screen->chan, 1, 0x222222FF), nil, ZP);
|
||||
draw(
|
||||
screen,
|
||||
r1,
|
||||
allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, 0x222222FF),
|
||||
nil,
|
||||
ZP);
|
||||
r1.max.y = r.max.y;
|
||||
for (i = 0; i < c->nw; i++) {
|
||||
w = c->w[i];
|
||||
|
@ -259,17 +270,19 @@ colresize(Column *c, Rectangle r)
|
|||
r1.max.y = max(r1.max.y, r1.min.y + Border + font->height);
|
||||
r2 = r1;
|
||||
r2.max.y = r2.min.y + Border;
|
||||
draw(screen, r2, allocimage(display, Rect(0,0,1,1), screen->chan, 1, 0x222222FF), nil, ZP);
|
||||
draw(
|
||||
screen,
|
||||
r2,
|
||||
allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, 0x222222FF),
|
||||
nil,
|
||||
ZP);
|
||||
r1.min.y = r2.max.y;
|
||||
r1.min.y = winresize(w, r1, FALSE, i == c->nw - 1);
|
||||
}
|
||||
c->r = r;
|
||||
}
|
||||
|
||||
static
|
||||
int
|
||||
colcmp(const void *a, const void *b)
|
||||
{
|
||||
static int colcmp(const void* a, const void* b) {
|
||||
Rune *r1, *r2;
|
||||
int i, nr1, nr2;
|
||||
|
||||
|
@ -286,9 +299,7 @@ colcmp(const void *a, const void *b)
|
|||
return nr1 - nr2;
|
||||
}
|
||||
|
||||
void
|
||||
colsort(Column *c)
|
||||
{
|
||||
void colsort(Column* c) {
|
||||
int i, y;
|
||||
Rectangle r, r1, *rp;
|
||||
Window **wp, *w;
|
||||
|
@ -315,7 +326,12 @@ colsort(Column *c)
|
|||
r.max.y = r.min.y + Dy(w->r) + Border;
|
||||
r1 = r;
|
||||
r1.max.y = r1.min.y + Border;
|
||||
draw(screen, r1, allocimage(display, Rect(0,0,1,1), screen->chan, 1, 0x222222FF), nil, ZP);
|
||||
draw(
|
||||
screen,
|
||||
r1,
|
||||
allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, 0x222222FF),
|
||||
nil,
|
||||
ZP);
|
||||
r.min.y = r1.max.y;
|
||||
y = winresize(w, r, FALSE, i == c->nw - 1);
|
||||
}
|
||||
|
@ -324,9 +340,7 @@ colsort(Column *c)
|
|||
c->w = wp;
|
||||
}
|
||||
|
||||
void
|
||||
colgrow(Column *c, Window *w, int but)
|
||||
{
|
||||
void colgrow(Column* c, Window* w, int but) {
|
||||
Rectangle r, cr;
|
||||
int i, j, k, l, y1, y2, *nl, *ny, tot, nnl, onl, dnl, h;
|
||||
Window* v;
|
||||
|
@ -413,7 +427,12 @@ colgrow(Column *c, Window *w, int but)
|
|||
r.max.y += 1 + nl[j] * v->body.fr.font->height;
|
||||
r.min.y = winresize(v, r, c->safe, FALSE);
|
||||
r.max.y += Border;
|
||||
draw(screen, r, allocimage(display, Rect(0,0,1,1), screen->chan, 1, 0x222222FF), nil, ZP);
|
||||
draw(
|
||||
screen,
|
||||
r,
|
||||
allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, 0x222222FF),
|
||||
nil,
|
||||
ZP);
|
||||
y1 = r.max.y;
|
||||
}
|
||||
/* scan to see new size of everyone below */
|
||||
|
@ -440,7 +459,12 @@ colgrow(Column *c, Window *w, int but)
|
|||
if (i < c->nw - 1) {
|
||||
r.min.y = r.max.y;
|
||||
r.max.y += Border;
|
||||
draw(screen, r, allocimage(display, Rect(0,0,1,1), screen->chan, 1, 0x222222FF), nil, ZP);
|
||||
draw(
|
||||
screen,
|
||||
r,
|
||||
allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, 0x222222FF),
|
||||
nil,
|
||||
ZP);
|
||||
for (j = i + 1; j < c->nw; j++)
|
||||
ny[j] -= (y2 - r.max.y);
|
||||
}
|
||||
|
@ -457,7 +481,12 @@ colgrow(Column *c, Window *w, int but)
|
|||
if (j < c->nw - 1) { /* no border on last window */
|
||||
r.min.y = y1;
|
||||
r.max.y += Border;
|
||||
draw(screen, r, allocimage(display, Rect(0,0,1,1), screen->chan, 1, 0x222222FF), nil, ZP);
|
||||
draw(
|
||||
screen,
|
||||
r,
|
||||
allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, 0x222222FF),
|
||||
nil,
|
||||
ZP);
|
||||
y1 = r.max.y;
|
||||
}
|
||||
}
|
||||
|
@ -467,9 +496,7 @@ colgrow(Column *c, Window *w, int but)
|
|||
winmousebut(w);
|
||||
}
|
||||
|
||||
void
|
||||
coldragwin(Column *c, Window *w, int but)
|
||||
{
|
||||
void coldragwin(Column* c, Window* w, int but) {
|
||||
Rectangle r;
|
||||
int i, b;
|
||||
Point p, op;
|
||||
|
@ -515,8 +542,9 @@ coldragwin(Column *c, Window *w, int but)
|
|||
}
|
||||
if (i == 0 && c->nw == 1)
|
||||
return; /* can't do it */
|
||||
if((i>0 && p.y<c->w[i-1]->r.min.y) || (i<c->nw-1 && p.y>w->r.max.y)
|
||||
|| (i==0 && p.y>w->r.max.y)){
|
||||
if (
|
||||
(i > 0 && p.y < c->w[i - 1]->r.min.y) ||
|
||||
(i < c->nw - 1 && p.y > w->r.max.y) || (i == 0 && p.y > w->r.max.y)) {
|
||||
/* shuffle */
|
||||
colclose(c, w, FALSE);
|
||||
coladd(c, w, nil, p.y);
|
||||
|
@ -539,7 +567,12 @@ coldragwin(Column *c, Window *w, int but)
|
|||
}
|
||||
r.min.y = winresize(v, r, c->safe, FALSE);
|
||||
r.max.y = r.min.y + Border;
|
||||
draw(screen, r, allocimage(display, Rect(0,0,1,1), screen->chan, 1, 0x222222FF), nil, ZP);
|
||||
draw(
|
||||
screen,
|
||||
r,
|
||||
allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, 0x222222FF),
|
||||
nil,
|
||||
ZP);
|
||||
r.min.y = r.max.y;
|
||||
if (i == c->nw - 1)
|
||||
r.max.y = c->r.max.y;
|
||||
|
@ -550,9 +583,7 @@ coldragwin(Column *c, Window *w, int but)
|
|||
winmousebut(w);
|
||||
}
|
||||
|
||||
Text*
|
||||
colwhich(Column *c, Point p)
|
||||
{
|
||||
Text* colwhich(Column* c, Point p) {
|
||||
int i;
|
||||
Window* w;
|
||||
|
||||
|
@ -574,9 +605,7 @@ colwhich(Column *c, Point p)
|
|||
return nil;
|
||||
}
|
||||
|
||||
int
|
||||
colclean(Column *c)
|
||||
{
|
||||
int colclean(Column* c) {
|
||||
int i, clean;
|
||||
|
||||
clean = TRUE;
|
||||
|
|
29
disk.c
29
disk.c
|
@ -14,9 +14,7 @@
|
|||
|
||||
static Block* blist;
|
||||
|
||||
int
|
||||
tempfile(void)
|
||||
{
|
||||
int tempfile(void) {
|
||||
char buf[128];
|
||||
int i, fd;
|
||||
|
||||
|
@ -32,9 +30,7 @@ tempfile(void)
|
|||
return -1;
|
||||
}
|
||||
|
||||
Disk*
|
||||
diskinit()
|
||||
{
|
||||
Disk* diskinit() {
|
||||
Disk* d;
|
||||
|
||||
d = emalloc(sizeof(Disk));
|
||||
|
@ -46,10 +42,7 @@ diskinit()
|
|||
return d;
|
||||
}
|
||||
|
||||
static
|
||||
uint
|
||||
ntosize(uint n, uint *ip)
|
||||
{
|
||||
static uint ntosize(uint n, uint* ip) {
|
||||
uint size;
|
||||
|
||||
if (n > Maxblock)
|
||||
|
@ -63,9 +56,7 @@ ntosize(uint n, uint *ip)
|
|||
return size * sizeof(Rune);
|
||||
}
|
||||
|
||||
Block*
|
||||
disknewblock(Disk *d, uint n)
|
||||
{
|
||||
Block* disknewblock(Disk* d, uint n) {
|
||||
uint i, j, size;
|
||||
Block* b;
|
||||
|
||||
|
@ -92,9 +83,7 @@ disknewblock(Disk *d, uint n)
|
|||
return b;
|
||||
}
|
||||
|
||||
void
|
||||
diskrelease(Disk *d, Block *b)
|
||||
{
|
||||
void diskrelease(Disk* d, Block* b) {
|
||||
uint i;
|
||||
|
||||
ntosize(b->u.n, &i);
|
||||
|
@ -102,9 +91,7 @@ diskrelease(Disk *d, Block *b)
|
|||
d->free[i] = b;
|
||||
}
|
||||
|
||||
void
|
||||
diskwrite(Disk *d, Block **bp, Rune *r, uint n)
|
||||
{
|
||||
void diskwrite(Disk* d, Block** bp, Rune* r, uint n) {
|
||||
int size, nsize;
|
||||
Block* b;
|
||||
|
||||
|
@ -121,9 +108,7 @@ diskwrite(Disk *d, Block **bp, Rune *r, uint n)
|
|||
b->u.n = n;
|
||||
}
|
||||
|
||||
void
|
||||
diskread(Disk *d, Block *b, Rune *r, uint n)
|
||||
{
|
||||
void diskread(Disk* d, Block* b, Rune* r, uint n) {
|
||||
if (n > b->u.n)
|
||||
error("internal error: diskread");
|
||||
|
||||
|
|
268
ecmd.c
268
ecmd.c
|
@ -36,32 +36,24 @@ File *tofile(String*);
|
|||
Rune* cmdname(File* f, String* s, int);
|
||||
void runpipe(Text*, int, Rune*, int, int);
|
||||
|
||||
void
|
||||
clearcollection(void)
|
||||
{
|
||||
void clearcollection(void) {
|
||||
free(collection);
|
||||
collection = nil;
|
||||
ncollection = 0;
|
||||
}
|
||||
|
||||
void
|
||||
resetxec(void)
|
||||
{
|
||||
void resetxec(void) {
|
||||
Glooping = nest = 0;
|
||||
clearcollection();
|
||||
}
|
||||
|
||||
void
|
||||
mkaddr(Address *a, File *f)
|
||||
{
|
||||
void mkaddr(Address* a, File* f) {
|
||||
a->r.q0 = f->curtext->q0;
|
||||
a->r.q1 = f->curtext->q1;
|
||||
a->f = f;
|
||||
}
|
||||
|
||||
int
|
||||
cmdexec(Text *t, Cmd *cp)
|
||||
{
|
||||
int cmdexec(Text* t, Cmd* cp) {
|
||||
int i;
|
||||
Addr* ap;
|
||||
File* f;
|
||||
|
@ -72,9 +64,9 @@ cmdexec(Text *t, Cmd *cp)
|
|||
w = nil;
|
||||
else
|
||||
w = t->w;
|
||||
if(w==nil && (cp->addr==0 || cp->addr->type!='"') &&
|
||||
!utfrune("bBnqUXY!", cp->cmdc) &&
|
||||
!(cp->cmdc=='D' && cp->u.text))
|
||||
if (
|
||||
w == nil && (cp->addr == 0 || cp->addr->type != '"') &&
|
||||
!utfrune("bBnqUXY!", cp->cmdc) && !(cp->cmdc == 'D' && cp->u.text))
|
||||
editerror("no current window");
|
||||
i = cmdlookup(cp->cmdc); /* will be -1 for '{' */
|
||||
f = nil;
|
||||
|
@ -128,9 +120,7 @@ cmdexec(Text *t, Cmd *cp)
|
|||
return 1;
|
||||
}
|
||||
|
||||
char*
|
||||
edittext(Window *w, int q, Rune *r, int nr)
|
||||
{
|
||||
char* edittext(Window* w, int q, Rune* r, int nr) {
|
||||
File* f;
|
||||
|
||||
f = w->body.file;
|
||||
|
@ -152,9 +142,7 @@ edittext(Window *w, int q, Rune *r, int nr)
|
|||
}
|
||||
|
||||
/* string is known to be NUL-terminated */
|
||||
Rune*
|
||||
filelist(Text *t, Rune *r, int nr)
|
||||
{
|
||||
Rune* filelist(Text* t, Rune* r, int nr) {
|
||||
if (nr == 0)
|
||||
return nil;
|
||||
r = skipbl(r, nr, &nr);
|
||||
|
@ -166,15 +154,9 @@ filelist(Text *t, Rune *r, int nr)
|
|||
return collection;
|
||||
}
|
||||
|
||||
int
|
||||
a_cmd(Text *t, Cmd *cp)
|
||||
{
|
||||
return append(t->file, cp, addr.r.q1);
|
||||
}
|
||||
int a_cmd(Text* t, Cmd* cp) { return append(t->file, cp, addr.r.q1); }
|
||||
|
||||
int
|
||||
b_cmd(Text *t, Cmd *cp)
|
||||
{
|
||||
int b_cmd(Text* t, Cmd* cp) {
|
||||
File* f;
|
||||
|
||||
USED(t);
|
||||
|
@ -185,9 +167,7 @@ b_cmd(Text *t, Cmd *cp)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
int
|
||||
B_cmd(Text *t, Cmd *cp)
|
||||
{
|
||||
int B_cmd(Text* t, Cmd* cp) {
|
||||
Rune *list, *r, *s;
|
||||
int nr;
|
||||
|
||||
|
@ -199,7 +179,8 @@ B_cmd(Text *t, Cmd *cp)
|
|||
r = skipbl(r, nr, &nr);
|
||||
if (nr == 0)
|
||||
new (t, t, nil, 0, 0, r, 0);
|
||||
else while(nr > 0){
|
||||
else
|
||||
while (nr > 0) {
|
||||
s = findbl(r, nr, &nr);
|
||||
*s = '\0';
|
||||
new (t, t, nil, 0, 0, r, runestrlen(r));
|
||||
|
@ -210,18 +191,14 @@ B_cmd(Text *t, Cmd *cp)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
int
|
||||
c_cmd(Text *t, Cmd *cp)
|
||||
{
|
||||
int c_cmd(Text* t, Cmd* cp) {
|
||||
elogreplace(t->file, addr.r.q0, addr.r.q1, cp->u.text->r, cp->u.text->n);
|
||||
t->q0 = addr.r.q0;
|
||||
t->q1 = addr.r.q1;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int
|
||||
d_cmd(Text *t, Cmd *cp)
|
||||
{
|
||||
int d_cmd(Text* t, Cmd* cp) {
|
||||
USED(cp);
|
||||
if (addr.r.q1 > addr.r.q0)
|
||||
elogdelete(t->file, addr.r.q0, addr.r.q1);
|
||||
|
@ -230,16 +207,12 @@ d_cmd(Text *t, Cmd *cp)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
D1(Text *t)
|
||||
{
|
||||
void D1(Text* t) {
|
||||
if (t->w->body.file->ntext > 1 || winclean(t->w, FALSE))
|
||||
colclose(t->col, t->w, TRUE);
|
||||
}
|
||||
|
||||
int
|
||||
D_cmd(Text *t, Cmd *cp)
|
||||
{
|
||||
int D_cmd(Text* t, Cmd* cp) {
|
||||
Rune *list, *r, *s, *n;
|
||||
int nr, nn;
|
||||
Window* w;
|
||||
|
@ -258,7 +231,8 @@ D_cmd(Text *t, Cmd *cp)
|
|||
do {
|
||||
s = findbl(r, nr, &nr);
|
||||
*s = '\0';
|
||||
/* first time through, could be empty string, meaning delete file empty name */
|
||||
/* first time through, could be empty string, meaning delete file empty name
|
||||
*/
|
||||
nn = runestrlen(r);
|
||||
if (r[0] == '/' || nn == 0 || dir.nr == 0) {
|
||||
rs.r = runestrdup(r);
|
||||
|
@ -286,17 +260,13 @@ D_cmd(Text *t, Cmd *cp)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static int
|
||||
readloader(void *v, uint q0, Rune *r, int nr)
|
||||
{
|
||||
static int readloader(void* v, uint q0, Rune* r, int nr) {
|
||||
if (nr > 0)
|
||||
eloginsert(v, q0, r, nr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
e_cmd(Text *t, Cmd *cp)
|
||||
{
|
||||
int e_cmd(Text* t, Cmd* cp) {
|
||||
Rune* name;
|
||||
File* f;
|
||||
int i, isdir, q0, q1, fd, nulls, samename, allreplaced;
|
||||
|
@ -348,9 +318,7 @@ e_cmd(Text *t, Cmd *cp)
|
|||
}
|
||||
|
||||
static Rune Lempty[] = {0};
|
||||
int
|
||||
f_cmd(Text *t, Cmd *cp)
|
||||
{
|
||||
int f_cmd(Text* t, Cmd* cp) {
|
||||
Rune* name;
|
||||
String* str;
|
||||
String empty;
|
||||
|
@ -367,9 +335,7 @@ f_cmd(Text *t, Cmd *cp)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
int
|
||||
g_cmd(Text *t, Cmd *cp)
|
||||
{
|
||||
int g_cmd(Text* t, Cmd* cp) {
|
||||
if (t->file != addr.f) {
|
||||
warning(nil, "internal error: g_cmd f!=addr.f\n");
|
||||
return FALSE;
|
||||
|
@ -384,15 +350,9 @@ g_cmd(Text *t, Cmd *cp)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
int
|
||||
i_cmd(Text *t, Cmd *cp)
|
||||
{
|
||||
return append(t->file, cp, addr.r.q0);
|
||||
}
|
||||
int i_cmd(Text* t, Cmd* cp) { return append(t->file, cp, addr.r.q0); }
|
||||
|
||||
void
|
||||
copy(File *f, Address addr2)
|
||||
{
|
||||
void copy(File* f, Address addr2) {
|
||||
long p;
|
||||
int ni;
|
||||
Rune* buf;
|
||||
|
@ -408,9 +368,7 @@ copy(File *f, Address addr2)
|
|||
fbuffree(buf);
|
||||
}
|
||||
|
||||
void
|
||||
move(File *f, Address addr2)
|
||||
{
|
||||
void move(File* f, Address addr2) {
|
||||
if (addr.f != addr2.f || addr.r.q1 <= addr2.r.q0) {
|
||||
elogdelete(f, addr.r.q0, addr.r.q1);
|
||||
copy(f, addr2);
|
||||
|
@ -423,9 +381,7 @@ move(File *f, Address addr2)
|
|||
editerror("move overlaps itself");
|
||||
}
|
||||
|
||||
int
|
||||
m_cmd(Text *t, Cmd *cp)
|
||||
{
|
||||
int m_cmd(Text* t, Cmd* cp) {
|
||||
Address dot, addr2;
|
||||
|
||||
mkaddr(&dot, t->file);
|
||||
|
@ -437,16 +393,12 @@ m_cmd(Text *t, Cmd *cp)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
int
|
||||
p_cmd(Text *t, Cmd *cp)
|
||||
{
|
||||
int p_cmd(Text* t, Cmd* cp) {
|
||||
USED(cp);
|
||||
return pdisplay(t->file);
|
||||
}
|
||||
|
||||
int
|
||||
s_cmd(Text *t, Cmd *cp)
|
||||
{
|
||||
int s_cmd(Text* t, Cmd* cp) {
|
||||
int i, j, k, c, m, n, nrp, didsub;
|
||||
long p1, op, delta;
|
||||
String* buf;
|
||||
|
@ -462,7 +414,8 @@ s_cmd(Text *t, Cmd *cp)
|
|||
rp = nil;
|
||||
delta = 0;
|
||||
didsub = FALSE;
|
||||
for(p1 = addr.r.q0; p1<=addr.r.q1 && rxexecute(t, nil, p1, addr.r.q1, &sel); ){
|
||||
for (p1 = addr.r.q0;
|
||||
p1 <= addr.r.q1 && rxexecute(t, nil, p1, addr.r.q1, &sel);) {
|
||||
if (sel.r[0].q0 == sel.r[0].q1) { /* empty match? */
|
||||
if (sel.r[0].q0 == op) {
|
||||
p1++;
|
||||
|
@ -533,9 +486,7 @@ Err:
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
int
|
||||
u_cmd(Text *t, Cmd *cp)
|
||||
{
|
||||
int u_cmd(Text* t, Cmd* cp) {
|
||||
int n, oseq, flag;
|
||||
|
||||
n = cp->num;
|
||||
|
@ -552,9 +503,7 @@ u_cmd(Text *t, Cmd *cp)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
int
|
||||
w_cmd(Text *t, Cmd *cp)
|
||||
{
|
||||
int w_cmd(Text* t, Cmd* cp) {
|
||||
Rune* r;
|
||||
File* f;
|
||||
|
||||
|
@ -569,9 +518,7 @@ w_cmd(Text *t, Cmd *cp)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
int
|
||||
x_cmd(Text *t, Cmd *cp)
|
||||
{
|
||||
int x_cmd(Text* t, Cmd* cp) {
|
||||
if (cp->re)
|
||||
looper(t->file, cp, cp->cmdc == 'x');
|
||||
else
|
||||
|
@ -579,18 +526,14 @@ x_cmd(Text *t, Cmd *cp)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
int
|
||||
X_cmd(Text *t, Cmd *cp)
|
||||
{
|
||||
int X_cmd(Text* t, Cmd* cp) {
|
||||
USED(t);
|
||||
|
||||
filelooper(cp, cp->cmdc == 'X');
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
runpipe(Text *t, int cmd, Rune *cr, int ncr, int state)
|
||||
{
|
||||
void runpipe(Text* t, int cmd, Rune* cr, int ncr, int state) {
|
||||
Rune *r, *s;
|
||||
int n;
|
||||
Runestr dir;
|
||||
|
@ -653,16 +596,12 @@ runpipe(Text *t, int cmd, Rune *cr, int ncr, int state)
|
|||
winlock(t->w, 'M');
|
||||
}
|
||||
|
||||
int
|
||||
pipe_cmd(Text *t, Cmd *cp)
|
||||
{
|
||||
int pipe_cmd(Text* t, Cmd* cp) {
|
||||
runpipe(t, cp->cmdc, cp->u.text->r, cp->u.text->n, Inserting);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
long
|
||||
nlcount(Text *t, long q0, long q1, long *pnr)
|
||||
{
|
||||
long nlcount(Text* t, long q0, long q1, long* pnr) {
|
||||
long nl, start;
|
||||
Rune* buf;
|
||||
int i, nbuf;
|
||||
|
@ -697,9 +636,7 @@ enum {
|
|||
PosnLineChars = 2,
|
||||
};
|
||||
|
||||
void
|
||||
printposn(Text *t, int mode)
|
||||
{
|
||||
void printposn(Text* t, int mode) {
|
||||
long l1, l2, r1, r2;
|
||||
|
||||
if (t != nil && t->file != nil && t->file->name != nil)
|
||||
|
@ -718,7 +655,9 @@ printposn(Text *t, int mode)
|
|||
l1 = 1 + nlcount(t, 0, addr.r.q0, nil);
|
||||
l2 = l1 + nlcount(t, addr.r.q0, addr.r.q1, nil);
|
||||
/* check if addr ends with '\n' */
|
||||
if(addr.r.q1>0 && addr.r.q1>addr.r.q0 && textreadc(t, addr.r.q1-1)=='\n')
|
||||
if (
|
||||
addr.r.q1 > 0 && addr.r.q1 > addr.r.q0 &&
|
||||
textreadc(t, addr.r.q1 - 1) == '\n')
|
||||
--l2;
|
||||
warning(nil, "%lud", l1);
|
||||
if (l2 != l1)
|
||||
|
@ -739,9 +678,7 @@ printposn(Text *t, int mode)
|
|||
}
|
||||
}
|
||||
|
||||
int
|
||||
eq_cmd(Text *t, Cmd *cp)
|
||||
{
|
||||
int eq_cmd(Text* t, Cmd* cp) {
|
||||
int mode;
|
||||
|
||||
switch (cp->u.text->n) {
|
||||
|
@ -765,9 +702,7 @@ eq_cmd(Text *t, Cmd *cp)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
int
|
||||
nl_cmd(Text *t, Cmd *cp)
|
||||
{
|
||||
int nl_cmd(Text* t, Cmd* cp) {
|
||||
Address a;
|
||||
File* f;
|
||||
|
||||
|
@ -787,9 +722,7 @@ nl_cmd(Text *t, Cmd *cp)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
int
|
||||
append(File *f, Cmd *cp, long p)
|
||||
{
|
||||
int append(File* f, Cmd* cp, long p) {
|
||||
if (cp->u.text->n > 0)
|
||||
eloginsert(f, p, cp->u.text->r, cp->u.text->n);
|
||||
f->curtext->q0 = p;
|
||||
|
@ -797,9 +730,7 @@ append(File *f, Cmd *cp, long p)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
int
|
||||
pdisplay(File *f)
|
||||
{
|
||||
int pdisplay(File* f) {
|
||||
long p1, p2;
|
||||
int np;
|
||||
Rune* buf;
|
||||
|
@ -824,22 +755,24 @@ pdisplay(File *f)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
pfilename(File *f)
|
||||
{
|
||||
void pfilename(File* f) {
|
||||
int dirty;
|
||||
Window* w;
|
||||
|
||||
w = f->curtext->w;
|
||||
/* same check for dirty as in settag, but we know ncache==0 */
|
||||
dirty = !w->isdir && !w->isscratch && f->mod;
|
||||
warning(nil, "%c%c%c %.*S\n", " '"[dirty],
|
||||
'+', " ."[curtext!=nil && curtext->file==f], f->nname, f->name);
|
||||
warning(
|
||||
nil,
|
||||
"%c%c%c %.*S\n",
|
||||
" '"[dirty],
|
||||
'+',
|
||||
" ."[curtext != nil && curtext->file == f],
|
||||
f -> nname,
|
||||
f -> name);
|
||||
}
|
||||
|
||||
void
|
||||
loopcmd(File *f, Cmd *cp, Range *rp, long nrp)
|
||||
{
|
||||
void loopcmd(File* f, Cmd* cp, Range* rp, long nrp) {
|
||||
long i;
|
||||
|
||||
for (i = 0; i < nrp; i++) {
|
||||
|
@ -849,9 +782,7 @@ loopcmd(File *f, Cmd *cp, Range *rp, long nrp)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
looper(File *f, Cmd *cp, int xy)
|
||||
{
|
||||
void looper(File* f, Cmd* cp, int xy) {
|
||||
long p, op, nrp;
|
||||
Range r, tr;
|
||||
Range* rp;
|
||||
|
@ -864,7 +795,8 @@ looper(File *f, Cmd *cp, int xy)
|
|||
nrp = 0;
|
||||
rp = nil;
|
||||
for (p = r.q0; p <= r.q1;) {
|
||||
if(!rxexecute(f->curtext, nil, p, r.q1, &sel)){ /* no match, but y should still run */
|
||||
if (!rxexecute(f->curtext, nil, p, r.q1, &sel)) { /* no match, but y should
|
||||
still run */
|
||||
if (xy || op > r.q1)
|
||||
break;
|
||||
tr.q0 = op, tr.q1 = r.q1;
|
||||
|
@ -893,9 +825,7 @@ looper(File *f, Cmd *cp, int xy)
|
|||
--nest;
|
||||
}
|
||||
|
||||
void
|
||||
linelooper(File *f, Cmd *cp)
|
||||
{
|
||||
void linelooper(File* f, Cmd* cp) {
|
||||
long nrp, p;
|
||||
Range r, linesel;
|
||||
Address a, a3;
|
||||
|
@ -934,17 +864,14 @@ linelooper(File *f, Cmd *cp)
|
|||
--nest;
|
||||
}
|
||||
|
||||
struct Looper
|
||||
{
|
||||
struct Looper {
|
||||
Cmd* cp;
|
||||
int XY;
|
||||
Window** w;
|
||||
int nw;
|
||||
} loopstruct; /* only one; X and Y can't nest */
|
||||
|
||||
void
|
||||
alllooper(Window *w, void *v)
|
||||
{
|
||||
void alllooper(Window* w, void* v) {
|
||||
Text* t;
|
||||
struct Looper* lp;
|
||||
Cmd* cp;
|
||||
|
@ -968,18 +895,14 @@ alllooper(Window *w, void *v)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
alllocker(Window *w, void *v)
|
||||
{
|
||||
void alllocker(Window* w, void* v) {
|
||||
if (v)
|
||||
incref(&w->ref);
|
||||
else
|
||||
winclose(w);
|
||||
}
|
||||
|
||||
void
|
||||
filelooper(Cmd *cp, int XY)
|
||||
{
|
||||
void filelooper(Cmd* cp, int XY) {
|
||||
int i;
|
||||
|
||||
if (Glooping++)
|
||||
|
@ -1012,9 +935,7 @@ filelooper(Cmd *cp, int XY)
|
|||
--nest;
|
||||
}
|
||||
|
||||
void
|
||||
nextmatch(File *f, String *r, long p, int sign)
|
||||
{
|
||||
void nextmatch(File* f, String* r, long p, int sign) {
|
||||
if (rxcompile(r->r) == FALSE)
|
||||
editerror("bad regexp in command address");
|
||||
if (sign >= 0) {
|
||||
|
@ -1042,9 +963,7 @@ File *matchfile(String*);
|
|||
Address charaddr(long, Address, int);
|
||||
Address lineaddr(long, Address, int);
|
||||
|
||||
Address
|
||||
cmdaddress(Addr *ap, Address a, int sign)
|
||||
{
|
||||
Address cmdaddress(Addr* ap, Address a, int sign) {
|
||||
File* f = a.f;
|
||||
Address a1, a2;
|
||||
|
||||
|
@ -1131,9 +1050,7 @@ struct Tofile{
|
|||
String* r;
|
||||
};
|
||||
|
||||
void
|
||||
alltofile(Window *w, void *v)
|
||||
{
|
||||
void alltofile(Window* w, void* v) {
|
||||
Text* t;
|
||||
struct Tofile* tp;
|
||||
|
||||
|
@ -1152,9 +1069,7 @@ alltofile(Window *w, void *v)
|
|||
tp->f = t->file;
|
||||
}
|
||||
|
||||
File*
|
||||
tofile(String *r)
|
||||
{
|
||||
File* tofile(String* r) {
|
||||
struct Tofile t;
|
||||
String rr;
|
||||
|
||||
|
@ -1167,9 +1082,7 @@ tofile(String *r)
|
|||
return t.f;
|
||||
}
|
||||
|
||||
void
|
||||
allmatchfile(Window *w, void *v)
|
||||
{
|
||||
void allmatchfile(Window* w, void* v) {
|
||||
struct Tofile* tp;
|
||||
Text* t;
|
||||
|
||||
|
@ -1189,9 +1102,7 @@ allmatchfile(Window *w, void *v)
|
|||
}
|
||||
}
|
||||
|
||||
File*
|
||||
matchfile(String *r)
|
||||
{
|
||||
File* matchfile(String* r) {
|
||||
struct Tofile tf;
|
||||
|
||||
tf.f = nil;
|
||||
|
@ -1203,9 +1114,7 @@ matchfile(String *r)
|
|||
return tf.f;
|
||||
}
|
||||
|
||||
int
|
||||
filematch(File *f, String *r)
|
||||
{
|
||||
int filematch(File* f, String* r) {
|
||||
char* buf;
|
||||
Rune* rbuf;
|
||||
Window* w;
|
||||
|
@ -1219,8 +1128,15 @@ filematch(File *f, String *r)
|
|||
w = f->curtext->w;
|
||||
/* same check for dirty as in settag, but we know ncache==0 */
|
||||
dirty = !w->isdir && !w->isscratch && f->mod;
|
||||
snprint(buf, BUFSIZE, "%c%c%c %.*S\n", " '"[dirty],
|
||||
'+', " ."[curtext!=nil && curtext->file==f], f->nname, f->name);
|
||||
snprint(
|
||||
buf,
|
||||
BUFSIZE,
|
||||
"%c%c%c %.*S\n",
|
||||
" '"[dirty],
|
||||
'+',
|
||||
" ."[curtext != nil && curtext->file == f],
|
||||
f -> nname,
|
||||
f -> name);
|
||||
rbuf = bytetorune(buf, &i);
|
||||
fbuffree(buf);
|
||||
match = rxexecute(nil, rbuf, 0, i, &s);
|
||||
|
@ -1228,9 +1144,7 @@ filematch(File *f, String *r)
|
|||
return match;
|
||||
}
|
||||
|
||||
Address
|
||||
charaddr(long l, Address addr, int sign)
|
||||
{
|
||||
Address charaddr(long l, Address addr, int sign) {
|
||||
if (sign == 0)
|
||||
addr.r.q0 = addr.r.q1 = l;
|
||||
else if (sign < 0)
|
||||
|
@ -1242,9 +1156,7 @@ charaddr(long l, Address addr, int sign)
|
|||
return addr;
|
||||
}
|
||||
|
||||
Address
|
||||
lineaddr(long l, Address addr, int sign)
|
||||
{
|
||||
Address lineaddr(long l, Address addr, int sign) {
|
||||
int n;
|
||||
int c;
|
||||
File* f = addr.f;
|
||||
|
@ -1298,23 +1210,21 @@ lineaddr(long l, Address addr, int sign)
|
|||
if (p > 0)
|
||||
p--;
|
||||
}
|
||||
while(p > 0 && textreadc(f->curtext, p-1)!='\n') /* lines start after a newline */
|
||||
while (p > 0 && textreadc(f->curtext, p - 1) !=
|
||||
'\n') /* lines start after a newline */
|
||||
p--;
|
||||
a.r.q0 = p;
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
struct Filecheck
|
||||
{
|
||||
struct Filecheck {
|
||||
File* f;
|
||||
Rune* r;
|
||||
int nr;
|
||||
};
|
||||
|
||||
void
|
||||
allfilecheck(Window *w, void *v)
|
||||
{
|
||||
void allfilecheck(Window* w, void* v) {
|
||||
struct Filecheck* fp;
|
||||
File* f;
|
||||
|
||||
|
@ -1326,9 +1236,7 @@ allfilecheck(Window *w, void *v)
|
|||
warning(nil, "warning: duplicate file name \"%.*S\"\n", fp->nr, fp->r);
|
||||
}
|
||||
|
||||
Rune*
|
||||
cmdname(File *f, String *str, int set)
|
||||
{
|
||||
Rune* cmdname(File* f, String* str, int set) {
|
||||
Rune *r, *s;
|
||||
int n;
|
||||
struct Filecheck fc;
|
||||
|
|
432
edit.c
432
edit.c
|
@ -17,41 +17,263 @@ static char linex[]="\n";
|
|||
static char wordx[] = " \t\n";
|
||||
struct cmdtab cmdtab[] = {
|
||||
/* cmdc text regexp addr defcmd defaddr count token fn */
|
||||
'\n', 0, 0, 0, 0, aDot, 0, 0, nl_cmd,
|
||||
'a', 1, 0, 0, 0, aDot, 0, 0, a_cmd,
|
||||
'b', 0, 0, 0, 0, aNo, 0, linex, b_cmd,
|
||||
'c', 1, 0, 0, 0, aDot, 0, 0, c_cmd,
|
||||
'd', 0, 0, 0, 0, aDot, 0, 0, d_cmd,
|
||||
'e', 0, 0, 0, 0, aNo, 0, wordx, e_cmd,
|
||||
'f', 0, 0, 0, 0, aNo, 0, wordx, f_cmd,
|
||||
'g', 0, 1, 0, 'p', aDot, 0, 0, g_cmd,
|
||||
'i', 1, 0, 0, 0, aDot, 0, 0, i_cmd,
|
||||
'm', 0, 0, 1, 0, aDot, 0, 0, m_cmd,
|
||||
'p', 0, 0, 0, 0, aDot, 0, 0, p_cmd,
|
||||
'r', 0, 0, 0, 0, aDot, 0, wordx, e_cmd,
|
||||
's', 0, 1, 0, 0, aDot, 1, 0, s_cmd,
|
||||
't', 0, 0, 1, 0, aDot, 0, 0, m_cmd,
|
||||
'u', 0, 0, 0, 0, aNo, 2, 0, u_cmd,
|
||||
'v', 0, 1, 0, 'p', aDot, 0, 0, g_cmd,
|
||||
'w', 0, 0, 0, 0, aAll, 0, wordx, w_cmd,
|
||||
'x', 0, 1, 0, 'p', aDot, 0, 0, x_cmd,
|
||||
'y', 0, 1, 0, 'p', aDot, 0, 0, x_cmd,
|
||||
'=', 0, 0, 0, 0, aDot, 0, linex, eq_cmd,
|
||||
'B', 0, 0, 0, 0, aNo, 0, linex, B_cmd,
|
||||
'D', 0, 0, 0, 0, aNo, 0, linex, D_cmd,
|
||||
'X', 0, 1, 0, 'f', aNo, 0, 0, X_cmd,
|
||||
'Y', 0, 1, 0, 'f', aNo, 0, 0, X_cmd,
|
||||
'<', 0, 0, 0, 0, aDot, 0, linex, pipe_cmd,
|
||||
'|', 0, 0, 0, 0, aDot, 0, linex, pipe_cmd,
|
||||
'>', 0, 0, 0, 0, aDot, 0, linex, pipe_cmd,
|
||||
'\n',
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
aDot,
|
||||
0,
|
||||
0,
|
||||
nl_cmd,
|
||||
'a',
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
aDot,
|
||||
0,
|
||||
0,
|
||||
a_cmd,
|
||||
'b',
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
aNo,
|
||||
0,
|
||||
linex,
|
||||
b_cmd,
|
||||
'c',
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
aDot,
|
||||
0,
|
||||
0,
|
||||
c_cmd,
|
||||
'd',
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
aDot,
|
||||
0,
|
||||
0,
|
||||
d_cmd,
|
||||
'e',
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
aNo,
|
||||
0,
|
||||
wordx,
|
||||
e_cmd,
|
||||
'f',
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
aNo,
|
||||
0,
|
||||
wordx,
|
||||
f_cmd,
|
||||
'g',
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
'p',
|
||||
aDot,
|
||||
0,
|
||||
0,
|
||||
g_cmd,
|
||||
'i',
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
aDot,
|
||||
0,
|
||||
0,
|
||||
i_cmd,
|
||||
'm',
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
aDot,
|
||||
0,
|
||||
0,
|
||||
m_cmd,
|
||||
'p',
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
aDot,
|
||||
0,
|
||||
0,
|
||||
p_cmd,
|
||||
'r',
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
aDot,
|
||||
0,
|
||||
wordx,
|
||||
e_cmd,
|
||||
's',
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
aDot,
|
||||
1,
|
||||
0,
|
||||
s_cmd,
|
||||
't',
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
aDot,
|
||||
0,
|
||||
0,
|
||||
m_cmd,
|
||||
'u',
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
aNo,
|
||||
2,
|
||||
0,
|
||||
u_cmd,
|
||||
'v',
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
'p',
|
||||
aDot,
|
||||
0,
|
||||
0,
|
||||
g_cmd,
|
||||
'w',
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
aAll,
|
||||
0,
|
||||
wordx,
|
||||
w_cmd,
|
||||
'x',
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
'p',
|
||||
aDot,
|
||||
0,
|
||||
0,
|
||||
x_cmd,
|
||||
'y',
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
'p',
|
||||
aDot,
|
||||
0,
|
||||
0,
|
||||
x_cmd,
|
||||
'=',
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
aDot,
|
||||
0,
|
||||
linex,
|
||||
eq_cmd,
|
||||
'B',
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
aNo,
|
||||
0,
|
||||
linex,
|
||||
B_cmd,
|
||||
'D',
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
aNo,
|
||||
0,
|
||||
linex,
|
||||
D_cmd,
|
||||
'X',
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
'f',
|
||||
aNo,
|
||||
0,
|
||||
0,
|
||||
X_cmd,
|
||||
'Y',
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
'f',
|
||||
aNo,
|
||||
0,
|
||||
0,
|
||||
X_cmd,
|
||||
'<',
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
aDot,
|
||||
0,
|
||||
linex,
|
||||
pipe_cmd,
|
||||
'|',
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
aDot,
|
||||
0,
|
||||
linex,
|
||||
pipe_cmd,
|
||||
'>',
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
aDot,
|
||||
0,
|
||||
linex,
|
||||
pipe_cmd,
|
||||
/* deliberately unimplemented:
|
||||
'k', 0, 0, 0, 0, aDot, 0, 0, k_cmd,
|
||||
'n', 0, 0, 0, 0, aNo, 0, 0, n_cmd,
|
||||
'q', 0, 0, 0, 0, aNo, 0, 0, q_cmd,
|
||||
'!', 0, 0, 0, 0, aNo, 0, linex, plan9_cmd,
|
||||
*/
|
||||
0, 0, 0, 0, 0, 0, 0, 0
|
||||
};
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0};
|
||||
|
||||
Cmd* parsecmd(int);
|
||||
Addr* compoundaddr(void);
|
||||
|
@ -75,9 +297,7 @@ int editing = Inactive;
|
|||
|
||||
String* newstring(int);
|
||||
|
||||
void
|
||||
editthread(void *v)
|
||||
{
|
||||
void editthread(void* v) {
|
||||
Cmd* cmdp;
|
||||
|
||||
USED(v);
|
||||
|
@ -90,25 +310,19 @@ editthread(void *v)
|
|||
sendp(editerrc, nil);
|
||||
}
|
||||
|
||||
void
|
||||
allelogterm(Window *w, void *x)
|
||||
{
|
||||
void allelogterm(Window* w, void* x) {
|
||||
USED(x);
|
||||
elogterm(w->body.file);
|
||||
}
|
||||
|
||||
void
|
||||
alleditinit(Window *w, void *x)
|
||||
{
|
||||
void alleditinit(Window* w, void* x) {
|
||||
USED(x);
|
||||
textcommit(&w->tag, TRUE);
|
||||
textcommit(&w->body, TRUE);
|
||||
w->body.file->editclean = FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
allupdate(Window *w, void *x)
|
||||
{
|
||||
void allupdate(Window* w, void* x) {
|
||||
Text* t;
|
||||
int i;
|
||||
File* f;
|
||||
|
@ -133,9 +347,7 @@ allupdate(Window *w, void *x)
|
|||
winsettag(w);
|
||||
}
|
||||
|
||||
void
|
||||
editerror(char *fmt, ...)
|
||||
{
|
||||
void editerror(char* fmt, ...) {
|
||||
va_list arg;
|
||||
char* s;
|
||||
|
||||
|
@ -148,9 +360,7 @@ editerror(char *fmt, ...)
|
|||
threadexits(nil);
|
||||
}
|
||||
|
||||
void
|
||||
editcmd(Text *ct, Rune *r, uint n)
|
||||
{
|
||||
void editcmd(Text* ct, Rune* r, uint n) {
|
||||
char* err;
|
||||
|
||||
if (n == 0)
|
||||
|
@ -193,32 +403,24 @@ editcmd(Text *ct, Rune *r, uint n)
|
|||
allwindows(allupdate, nil);
|
||||
}
|
||||
|
||||
int
|
||||
getch(void)
|
||||
{
|
||||
int getch(void) {
|
||||
if (cmdp == cmdendp)
|
||||
return -1;
|
||||
return *cmdp++;
|
||||
}
|
||||
|
||||
int
|
||||
nextc(void)
|
||||
{
|
||||
int nextc(void) {
|
||||
if (cmdp == cmdendp)
|
||||
return -1;
|
||||
return *cmdp;
|
||||
}
|
||||
|
||||
void
|
||||
ungetch(void)
|
||||
{
|
||||
void ungetch(void) {
|
||||
if (--cmdp < cmdstartp)
|
||||
error("ungetch");
|
||||
}
|
||||
|
||||
long
|
||||
getnum(int signok)
|
||||
{
|
||||
long getnum(int signok) {
|
||||
long n;
|
||||
int c, sign;
|
||||
|
||||
|
@ -236,9 +438,7 @@ getnum(int signok)
|
|||
return sign * n;
|
||||
}
|
||||
|
||||
int
|
||||
cmdskipbl(void)
|
||||
{
|
||||
int cmdskipbl(void) {
|
||||
int c;
|
||||
do
|
||||
c = getch();
|
||||
|
@ -251,9 +451,7 @@ cmdskipbl(void)
|
|||
/*
|
||||
* Check that list has room for one more element.
|
||||
*/
|
||||
void
|
||||
growlist(List *l)
|
||||
{
|
||||
void growlist(List* l) {
|
||||
if (l->u.listptr == 0 || l->nalloc == 0) {
|
||||
l->nalloc = INCR;
|
||||
l->u.listptr = emalloc(INCR * sizeof(void*));
|
||||
|
@ -268,9 +466,7 @@ growlist(List *l)
|
|||
/*
|
||||
* Remove the ith element from the list
|
||||
*/
|
||||
void
|
||||
dellist(List *l, int i)
|
||||
{
|
||||
void dellist(List* l, int i) {
|
||||
memmove(&l->u.ptr[i], &l->u.ptr[i + 1], (l->nused - (i + 1)) * sizeof(void*));
|
||||
l->nused--;
|
||||
}
|
||||
|
@ -278,25 +474,19 @@ dellist(List *l, int i)
|
|||
/*
|
||||
* Add a new element, whose position is i, to the list
|
||||
*/
|
||||
void
|
||||
inslist(List *l, int i, void *v)
|
||||
{
|
||||
void inslist(List* l, int i, void* v) {
|
||||
growlist(l);
|
||||
memmove(&l->u.ptr[i + 1], &l->u.ptr[i], (l->nused - i) * sizeof(void*));
|
||||
l->u.ptr[i] = v;
|
||||
l->nused++;
|
||||
}
|
||||
|
||||
void
|
||||
listfree(List *l)
|
||||
{
|
||||
void listfree(List* l) {
|
||||
free(l->u.listptr);
|
||||
free(l);
|
||||
}
|
||||
|
||||
String*
|
||||
allocstring(int n)
|
||||
{
|
||||
String* allocstring(int n) {
|
||||
String* s;
|
||||
|
||||
s = emalloc(sizeof(String));
|
||||
|
@ -307,15 +497,12 @@ allocstring(int n)
|
|||
return s;
|
||||
}
|
||||
|
||||
void
|
||||
freestring(String *s)
|
||||
{
|
||||
void freestring(String* s) {
|
||||
free(s->r);
|
||||
free(s);
|
||||
}
|
||||
|
||||
Cmd*
|
||||
newcmd(void){
|
||||
Cmd* newcmd(void) {
|
||||
Cmd* p;
|
||||
|
||||
p = emalloc(sizeof(Cmd));
|
||||
|
@ -323,9 +510,7 @@ newcmd(void){
|
|||
return p;
|
||||
}
|
||||
|
||||
String*
|
||||
newstring(int n)
|
||||
{
|
||||
String* newstring(int n) {
|
||||
String* p;
|
||||
|
||||
p = allocstring(n);
|
||||
|
@ -333,9 +518,7 @@ newstring(int n)
|
|||
return p;
|
||||
}
|
||||
|
||||
Addr*
|
||||
newaddr(void)
|
||||
{
|
||||
Addr* newaddr(void) {
|
||||
Addr* p;
|
||||
|
||||
p = emalloc(sizeof(Addr));
|
||||
|
@ -343,9 +526,7 @@ newaddr(void)
|
|||
return p;
|
||||
}
|
||||
|
||||
void
|
||||
freecmd(void)
|
||||
{
|
||||
void freecmd(void) {
|
||||
int i;
|
||||
|
||||
while (cmdlist.nused > 0)
|
||||
|
@ -358,17 +539,14 @@ freecmd(void)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
okdelim(int c)
|
||||
{
|
||||
if(c=='\\' || ('a'<=c && c<='z')
|
||||
|| ('A'<=c && c<='Z') || ('0'<=c && c<='9'))
|
||||
void okdelim(int c) {
|
||||
if (
|
||||
c == '\\' || ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z') ||
|
||||
('0' <= c && c <= '9'))
|
||||
editerror("bad delimiter %c\n", c);
|
||||
}
|
||||
|
||||
void
|
||||
atnl(void)
|
||||
{
|
||||
void atnl(void) {
|
||||
int c;
|
||||
|
||||
cmdskipbl();
|
||||
|
@ -377,9 +555,7 @@ atnl(void)
|
|||
editerror("newline expected (saw %C)", c);
|
||||
}
|
||||
|
||||
void
|
||||
Straddc(String *s, int c)
|
||||
{
|
||||
void Straddc(String* s, int c) {
|
||||
if (s->n + 1 >= s->nalloc) {
|
||||
s->nalloc += 10;
|
||||
s->r = erealloc(s->r, s->nalloc * sizeof(Rune));
|
||||
|
@ -388,9 +564,7 @@ Straddc(String *s, int c)
|
|||
s->r[s->n] = '\0';
|
||||
}
|
||||
|
||||
void
|
||||
getrhs(String *s, int delim, int cmd)
|
||||
{
|
||||
void getrhs(String* s, int delim, int cmd) {
|
||||
int c;
|
||||
|
||||
while ((c = getch()) > 0 && c != delim && c != '\n') {
|
||||
|
@ -410,9 +584,7 @@ getrhs(String *s, int delim, int cmd)
|
|||
ungetch(); /* let client read whether delimiter, '\n' or whatever */
|
||||
}
|
||||
|
||||
String *
|
||||
collecttoken(char *end)
|
||||
{
|
||||
String* collecttoken(char* end) {
|
||||
String* s = newstring(0);
|
||||
int c;
|
||||
|
||||
|
@ -425,9 +597,7 @@ collecttoken(char *end)
|
|||
return s;
|
||||
}
|
||||
|
||||
String *
|
||||
collecttext(void)
|
||||
{
|
||||
String* collecttext(void) {
|
||||
String* s;
|
||||
int begline, i, c, delim;
|
||||
|
||||
|
@ -456,9 +626,7 @@ collecttext(void)
|
|||
return s;
|
||||
}
|
||||
|
||||
int
|
||||
cmdlookup(int c)
|
||||
{
|
||||
int cmdlookup(int c) {
|
||||
int i;
|
||||
|
||||
for (i = 0; cmdtab[i].cmdc; i++)
|
||||
|
@ -467,9 +635,7 @@ cmdlookup(int c)
|
|||
return -1;
|
||||
}
|
||||
|
||||
Cmd*
|
||||
parsecmd(int nest)
|
||||
{
|
||||
Cmd* parsecmd(int nest) {
|
||||
int i, c;
|
||||
struct cmdtab* ct;
|
||||
Cmd *cp, *ncp;
|
||||
|
@ -500,7 +666,8 @@ parsecmd(int nest)
|
|||
if (ct->regexp) {
|
||||
/* x without pattern -> .*\n, indicated by cmd.re==0 */
|
||||
/* X without pattern is all files */
|
||||
if((ct->cmdc!='x' && ct->cmdc!='X') ||
|
||||
if (
|
||||
(ct->cmdc != 'x' && ct->cmdc != 'X') ||
|
||||
((c = nextc()) != ' ' && c != '\t' && c != '\n')) {
|
||||
cmdskipbl();
|
||||
if ((c = getch()) == '\n' || c < 0)
|
||||
|
@ -515,7 +682,6 @@ parsecmd(int nest)
|
|||
if (nextc() == 'g')
|
||||
cmd.flag = getch();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -562,9 +728,7 @@ parsecmd(int nest)
|
|||
return cp;
|
||||
}
|
||||
|
||||
String*
|
||||
getregexp(int delim)
|
||||
{
|
||||
String* getregexp(int delim) {
|
||||
String *buf, *r;
|
||||
int i, c;
|
||||
|
||||
|
@ -598,9 +762,7 @@ getregexp(int delim)
|
|||
return r;
|
||||
}
|
||||
|
||||
Addr *
|
||||
simpleaddr(void)
|
||||
{
|
||||
Addr* simpleaddr(void) {
|
||||
Addr addr;
|
||||
Addr *ap, *nap;
|
||||
|
||||
|
@ -612,12 +774,22 @@ simpleaddr(void)
|
|||
addr.type = getch();
|
||||
addr.num = getnum(1);
|
||||
break;
|
||||
case '0': case '1': case '2': case '3': case '4':
|
||||
case '5': case '6': case '7': case '8': case '9':
|
||||
case '0':
|
||||
case '1':
|
||||
case '2':
|
||||
case '3':
|
||||
case '4':
|
||||
case '5':
|
||||
case '6':
|
||||
case '7':
|
||||
case '8':
|
||||
case '9':
|
||||
addr.num = getnum(1);
|
||||
addr.type = 'l';
|
||||
break;
|
||||
case '/': case '?': case '"':
|
||||
case '/':
|
||||
case '?':
|
||||
case '"':
|
||||
addr.u.re = getregexp(addr.type = getch());
|
||||
break;
|
||||
case '.':
|
||||
|
@ -665,9 +837,7 @@ simpleaddr(void)
|
|||
return ap;
|
||||
}
|
||||
|
||||
Addr *
|
||||
compoundaddr(void)
|
||||
{
|
||||
Addr* compoundaddr(void) {
|
||||
Addr addr;
|
||||
Addr *ap, *next;
|
||||
|
||||
|
|
87
elog.c
87
elog.c
|
@ -27,32 +27,25 @@ static int warned = FALSE;
|
|||
*/
|
||||
|
||||
typedef struct Buflog Buflog;
|
||||
struct Buflog
|
||||
{
|
||||
struct Buflog {
|
||||
short type; /* Replace, Filename */
|
||||
uint q0; /* location of change (unused in f) */
|
||||
uint nd; /* # runes to delete */
|
||||
uint nr; /* # runes in string or file name */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
Buflogsize = sizeof(Buflog)/sizeof(Rune)
|
||||
};
|
||||
enum { Buflogsize = sizeof(Buflog) / sizeof(Rune) };
|
||||
|
||||
/*
|
||||
* Minstring shouldn't be very big or we will do lots of I/O for small changes.
|
||||
* Maxstring is RBUFSIZE so we can fbufalloc() once and not realloc elog.r.
|
||||
*/
|
||||
enum
|
||||
{
|
||||
enum {
|
||||
Minstring = 16, /* distance beneath which we merge changes */
|
||||
Maxstring = RBUFSIZE /* maximum length of change we will merge into one */
|
||||
};
|
||||
|
||||
void
|
||||
eloginit(File *f)
|
||||
{
|
||||
void eloginit(File* f) {
|
||||
if (f->elog.type != Empty)
|
||||
return;
|
||||
f->elog.type = Null;
|
||||
|
@ -63,9 +56,7 @@ eloginit(File *f)
|
|||
bufreset(f->elogbuf);
|
||||
}
|
||||
|
||||
void
|
||||
elogclose(File *f)
|
||||
{
|
||||
void elogclose(File* f) {
|
||||
if (f->elogbuf) {
|
||||
bufclose(f->elogbuf);
|
||||
free(f->elogbuf);
|
||||
|
@ -73,17 +64,13 @@ elogclose(File *f)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
elogreset(File *f)
|
||||
{
|
||||
void elogreset(File* f) {
|
||||
f->elog.type = Null;
|
||||
f->elog.nd = 0;
|
||||
f->elog.nr = 0;
|
||||
}
|
||||
|
||||
void
|
||||
elogterm(File *f)
|
||||
{
|
||||
void elogterm(File* f) {
|
||||
elogreset(f);
|
||||
if (f->elogbuf)
|
||||
bufreset(f->elogbuf);
|
||||
|
@ -93,9 +80,7 @@ elogterm(File *f)
|
|||
warned = FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
elogflush(File *f)
|
||||
{
|
||||
void elogflush(File* f) {
|
||||
Buflog b;
|
||||
|
||||
b.type = f->elog.type;
|
||||
|
@ -120,9 +105,7 @@ elogflush(File *f)
|
|||
elogreset(f);
|
||||
}
|
||||
|
||||
void
|
||||
elogreplace(File *f, int q0, int q1, Rune *r, int nr)
|
||||
{
|
||||
void elogreplace(File* f, int q0, int q1, Rune* r, int nr) {
|
||||
uint gap;
|
||||
|
||||
if (q0 == q1 && nr == 0)
|
||||
|
@ -157,9 +140,7 @@ elogreplace(File *f, int q0, int q1, Rune *r, int nr)
|
|||
runemove(f->elog.r, r, nr);
|
||||
}
|
||||
|
||||
void
|
||||
eloginsert(File *f, int q0, Rune *r, int nr)
|
||||
{
|
||||
void eloginsert(File* f, int q0, Rune* r, int nr) {
|
||||
int n;
|
||||
|
||||
if (nr == 0)
|
||||
|
@ -171,7 +152,8 @@ eloginsert(File *f, int q0, Rune *r, int nr)
|
|||
elogflush(f);
|
||||
}
|
||||
/* try to merge with previous */
|
||||
if(f->elog.type==Insert && q0==f->elog.q0 && f->elog.nr+nr<Maxstring){
|
||||
if (
|
||||
f->elog.type == Insert && q0 == f->elog.q0 && f->elog.nr + nr < Maxstring) {
|
||||
runemove(f->elog.r + f->elog.nr, r, nr);
|
||||
f->elog.nr += nr;
|
||||
return;
|
||||
|
@ -190,9 +172,7 @@ eloginsert(File *f, int q0, Rune *r, int nr)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
elogdelete(File *f, int q0, int q1)
|
||||
{
|
||||
void elogdelete(File* f, int q0, int q1) {
|
||||
if (q0 == q1)
|
||||
return;
|
||||
eloginit(f);
|
||||
|
@ -213,9 +193,7 @@ elogdelete(File *f, int q0, int q1)
|
|||
}
|
||||
|
||||
#define tracelog 0
|
||||
void
|
||||
elogapply(File *f)
|
||||
{
|
||||
void elogapply(File* f) {
|
||||
Buflog b;
|
||||
Rune* buf;
|
||||
uint i, n, up, mod;
|
||||
|
@ -240,11 +218,11 @@ elogapply(File *f)
|
|||
|
||||
/*
|
||||
* The edit commands have already updated the selection in t->q0, t->q1,
|
||||
* but using coordinates relative to the unmodified buffer. As we apply the log,
|
||||
* we have to update the coordinates to be relative to the modified buffer.
|
||||
* Textinsert and textdelete will do this for us; our only work is to apply the
|
||||
* convention that an insertion at t->q0==t->q1 is intended to select the
|
||||
* inserted text.
|
||||
* but using coordinates relative to the unmodified buffer. As we apply the
|
||||
* log, we have to update the coordinates to be relative to the modified
|
||||
* buffer. Textinsert and textdelete will do this for us; our only work is to
|
||||
* apply the convention that an insertion at t->q0==t->q1 is intended to
|
||||
* select the inserted text.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
@ -265,8 +243,13 @@ elogapply(File *f)
|
|||
|
||||
case Replace:
|
||||
if (tracelog)
|
||||
warning(nil, "elog replace %d %d (%d %d)\n",
|
||||
b.q0, b.q0+b.nd, t->q0, t->q1);
|
||||
warning(
|
||||
nil,
|
||||
"elog replace %d %d (%d %d)\n",
|
||||
b.q0,
|
||||
b.q0 + b.nd,
|
||||
t->q0,
|
||||
t->q1);
|
||||
if (!mod) {
|
||||
mod = TRUE;
|
||||
filemark(f);
|
||||
|
@ -287,8 +270,13 @@ elogapply(File *f)
|
|||
|
||||
case Delete:
|
||||
if (tracelog)
|
||||
warning(nil, "elog delete %d %d (%d %d)\n",
|
||||
b.q0, b.q0+b.nd, t->q0, t->q1);
|
||||
warning(
|
||||
nil,
|
||||
"elog delete %d %d (%d %d)\n",
|
||||
b.q0,
|
||||
b.q0 + b.nd,
|
||||
t->q0,
|
||||
t->q1);
|
||||
if (!mod) {
|
||||
mod = TRUE;
|
||||
filemark(f);
|
||||
|
@ -299,8 +287,13 @@ elogapply(File *f)
|
|||
|
||||
case Insert:
|
||||
if (tracelog)
|
||||
warning(nil, "elog insert %d %d (%d %d)\n",
|
||||
b.q0, b.q0+b.nr, t->q0, t->q1);
|
||||
warning(
|
||||
nil,
|
||||
"elog insert %d %d (%d %d)\n",
|
||||
b.q0,
|
||||
b.q0 + b.nr,
|
||||
t->q0,
|
||||
t->q1);
|
||||
if (!mod) {
|
||||
mod = TRUE;
|
||||
filemark(f);
|
||||
|
|
232
exec.c
232
exec.c
|
@ -57,8 +57,7 @@ void tab(Text*, Text*, Text*, int, int, Rune*, int);
|
|||
void zeroxx(Text*, Text*, Text*, int, int, Rune*, int);
|
||||
|
||||
typedef struct Exectab Exectab;
|
||||
struct Exectab
|
||||
{
|
||||
struct Exectab {
|
||||
Rune* name;
|
||||
void (*fn)(Text*, Text*, Text*, int, int, Rune*, int);
|
||||
int mark;
|
||||
|
@ -98,7 +97,13 @@ static Rune LUndo[] = { 'U', 'n', 'd', 'o', 0 };
|
|||
static Rune LZerox[] = {'Z', 'e', 'r', 'o', 'x', 0};
|
||||
|
||||
Exectab exectab[] = {
|
||||
{ LAbort, doabort, FALSE, XXX, XXX, },
|
||||
{
|
||||
LAbort,
|
||||
doabort,
|
||||
FALSE,
|
||||
XXX,
|
||||
XXX,
|
||||
},
|
||||
{LCut, cut, TRUE, TRUE, TRUE},
|
||||
{LDel, del, FALSE, FALSE, XXX},
|
||||
{LDelcol, delcol, FALSE, XXX, XXX},
|
||||
|
@ -128,12 +133,9 @@ Exectab exectab[] = {
|
|||
{LTab, tab, FALSE, XXX, XXX},
|
||||
{LUndo, undo, FALSE, TRUE, XXX},
|
||||
{LZerox, zeroxx, FALSE, XXX, XXX},
|
||||
{ nil, 0, 0, 0, 0 }
|
||||
};
|
||||
{nil, 0, 0, 0, 0}};
|
||||
|
||||
Exectab*
|
||||
lookup(Rune *r, int n)
|
||||
{
|
||||
Exectab* lookup(Rune* r, int n) {
|
||||
Exectab* e;
|
||||
int nr;
|
||||
|
||||
|
@ -148,17 +150,13 @@ lookup(Rune *r, int n)
|
|||
return nil;
|
||||
}
|
||||
|
||||
int
|
||||
isexecc(int c)
|
||||
{
|
||||
int isexecc(int c) {
|
||||
if (isfilec(c))
|
||||
return 1;
|
||||
return c == '<' || c == '|' || c == '>';
|
||||
}
|
||||
|
||||
void
|
||||
execute(Text *t, uint aq0, uint aq1, int external, Text *argt)
|
||||
{
|
||||
void execute(Text* t, uint aq0, uint aq1, int external, Text* argt) {
|
||||
uint q0, q1;
|
||||
Rune *r, *s;
|
||||
char *b, *a, *aa;
|
||||
|
@ -260,9 +258,7 @@ execute(Text *t, uint aq0, uint aq1, int external, Text *argt)
|
|||
run(t->w, b, dir.r, dir.nr, TRUE, aa, a, FALSE);
|
||||
}
|
||||
|
||||
char*
|
||||
printarg(Text *argt, uint q0, uint q1)
|
||||
{
|
||||
char* printarg(Text* argt, uint q0, uint q1) {
|
||||
char* buf;
|
||||
|
||||
if (argt->what != Body || argt->file->name == nil)
|
||||
|
@ -275,9 +271,7 @@ printarg(Text *argt, uint q0, uint q1)
|
|||
return buf;
|
||||
}
|
||||
|
||||
char*
|
||||
getarg(Text *argt, int doaddr, int dofile, Rune **rp, int *nrp)
|
||||
{
|
||||
char* getarg(Text* argt, int doaddr, int dofile, Rune** rp, int* nrp) {
|
||||
int n;
|
||||
Expand e;
|
||||
char* a;
|
||||
|
@ -312,9 +306,7 @@ getarg(Text *argt, int doaddr, int dofile, Rune **rp, int *nrp)
|
|||
return a;
|
||||
}
|
||||
|
||||
char*
|
||||
getbytearg(Text *argt, int doaddr, int dofile, char **bp)
|
||||
{
|
||||
char* getbytearg(Text* argt, int doaddr, int dofile, char** bp) {
|
||||
Rune* r;
|
||||
int n;
|
||||
char* aa;
|
||||
|
@ -328,9 +320,7 @@ getbytearg(Text *argt, int doaddr, int dofile, char **bp)
|
|||
return aa;
|
||||
}
|
||||
|
||||
void
|
||||
doabort(Text *__0, Text *_0, Text *_1, int _2, int _3, Rune *_4, int _5)
|
||||
{
|
||||
void doabort(Text* __0, Text* _0, Text* _1, int _2, int _3, Rune* _4, int _5) {
|
||||
static int n;
|
||||
|
||||
USED(__0);
|
||||
|
@ -347,9 +337,7 @@ doabort(Text *__0, Text *_0, Text *_1, int _2, int _3, Rune *_4, int _5)
|
|||
abort();
|
||||
}
|
||||
|
||||
void
|
||||
newcol(Text *et, Text *_0, Text *_1, int _2, int _3, Rune *_4, int _5)
|
||||
{
|
||||
void newcol(Text* et, Text* _0, Text* _1, int _2, int _3, Rune* _4, int _5) {
|
||||
Column* c;
|
||||
Window* w;
|
||||
|
||||
|
@ -368,9 +356,7 @@ newcol(Text *et, Text *_0, Text *_1, int _2, int _3, Rune *_4, int _5)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
delcol(Text *et, Text *_0, Text *_1, int _2, int _3, Rune *_4, int _5)
|
||||
{
|
||||
void delcol(Text* et, Text* _0, Text* _1, int _2, int _3, Rune* _4, int _5) {
|
||||
int i;
|
||||
Column* c;
|
||||
Window* w;
|
||||
|
@ -387,17 +373,22 @@ delcol(Text *et, Text *_0, Text *_1, int _2, int _3, Rune *_4, int _5)
|
|||
return;
|
||||
for (i = 0; i < c->nw; i++) {
|
||||
w = c->w[i];
|
||||
if(w->nopen[QWevent]+w->nopen[QWaddr]+w->nopen[QWdata]+w->nopen[QWxdata] > 0){
|
||||
warning(nil, "can't delete column; %.*S is running an external command\n", w->body.file->nname, w->body.file->name);
|
||||
if (
|
||||
w->nopen[QWevent] + w->nopen[QWaddr] + w->nopen[QWdata] +
|
||||
w->nopen[QWxdata] >
|
||||
0) {
|
||||
warning(
|
||||
nil,
|
||||
"can't delete column; %.*S is running an external command\n",
|
||||
w->body.file->nname,
|
||||
w->body.file->name);
|
||||
return;
|
||||
}
|
||||
}
|
||||
rowclose(et->col->row, et->col, TRUE);
|
||||
}
|
||||
|
||||
void
|
||||
del(Text *et, Text *_0, Text *_1, int flag1, int _2, Rune *_3, int _4)
|
||||
{
|
||||
void del(Text* et, Text* _0, Text* _1, int flag1, int _2, Rune* _3, int _4) {
|
||||
USED(_0);
|
||||
USED(_1);
|
||||
USED(_2);
|
||||
|
@ -410,9 +401,7 @@ del(Text *et, Text *_0, Text *_1, int flag1, int _2, Rune *_3, int _4)
|
|||
colclose(et->col, et->w, TRUE);
|
||||
}
|
||||
|
||||
void
|
||||
sort(Text *et, Text *_0, Text *_1, int _2, int _3, Rune *_4, int _5)
|
||||
{
|
||||
void sort(Text* et, Text* _0, Text* _1, int _2, int _3, Rune* _4, int _5) {
|
||||
USED(_0);
|
||||
USED(_1);
|
||||
USED(_2);
|
||||
|
@ -424,9 +413,7 @@ sort(Text *et, Text *_0, Text *_1, int _2, int _3, Rune *_4, int _5)
|
|||
colsort(et->col);
|
||||
}
|
||||
|
||||
uint
|
||||
seqof(Window *w, int isundo)
|
||||
{
|
||||
uint seqof(Window* w, int isundo) {
|
||||
/* if it's undo, see who changed with us */
|
||||
if (isundo)
|
||||
return w->body.file->seq;
|
||||
|
@ -434,9 +421,7 @@ seqof(Window *w, int isundo)
|
|||
return fileredoseq(w->body.file);
|
||||
}
|
||||
|
||||
void
|
||||
undo(Text *et, Text *_0, Text *_1, int flag1, int _2, Rune *_3, int _4)
|
||||
{
|
||||
void undo(Text* et, Text* _0, Text* _1, int flag1, int _2, Rune* _3, int _4) {
|
||||
int i, j;
|
||||
Column* c;
|
||||
Window* w;
|
||||
|
@ -457,8 +442,8 @@ undo(Text *et, Text *_0, Text *_1, int flag1, int _2, Rune *_3, int _4)
|
|||
}
|
||||
/*
|
||||
* Undo the executing window first. Its display will update. other windows
|
||||
* in the same file will not call show() and jump to a different location in the file.
|
||||
* Simultaneous changes to other files will be chaotic, however.
|
||||
* in the same file will not call show() and jump to a different location in
|
||||
* the file. Simultaneous changes to other files will be chaotic, however.
|
||||
*/
|
||||
winundo(et->w, flag1);
|
||||
for (i = 0; i < row.ncol; i++) {
|
||||
|
@ -473,9 +458,7 @@ undo(Text *et, Text *_0, Text *_1, int flag1, int _2, Rune *_3, int _4)
|
|||
}
|
||||
}
|
||||
|
||||
char*
|
||||
getname(Text *t, Text *argt, Rune *arg, int narg, int isput)
|
||||
{
|
||||
char* getname(Text* t, Text* argt, Rune* arg, int narg, int isput) {
|
||||
char* s;
|
||||
Rune* r;
|
||||
int i, n, promote;
|
||||
|
@ -539,9 +522,7 @@ getname(Text *t, Text *argt, Rune *arg, int narg, int isput)
|
|||
return s;
|
||||
}
|
||||
|
||||
void
|
||||
zeroxx(Text *et, Text *t, Text *_1, int _2, int _3, Rune *_4, int _5)
|
||||
{
|
||||
void zeroxx(Text* et, Text* t, Text* _1, int _2, int _3, Rune* _4, int _5) {
|
||||
Window* nw;
|
||||
int c, locked;
|
||||
|
||||
|
@ -565,7 +546,11 @@ zeroxx(Text *et, Text *t, Text *_1, int _2, int _3, Rune *_4, int _5)
|
|||
return;
|
||||
t = &t->w->body;
|
||||
if (t->w->isdir)
|
||||
warning(nil, "%.*S is a directory; Zerox illegal\n", t->file->nname, t->file->name);
|
||||
warning(
|
||||
nil,
|
||||
"%.*S is a directory; Zerox illegal\n",
|
||||
t->file->nname,
|
||||
t->file->name);
|
||||
else {
|
||||
nw = coladd(t->w->col, nil, t->w, -1);
|
||||
/* ugly: fix locks so w->unlock works */
|
||||
|
@ -586,9 +571,8 @@ struct TextAddr {
|
|||
long rq1;
|
||||
};
|
||||
|
||||
void
|
||||
get(Text *et, Text *t, Text *argt, int flag1, int _0, Rune *arg, int narg)
|
||||
{
|
||||
void get(
|
||||
Text* et, Text* t, Text* argt, int flag1, int _0, Rune* arg, int narg) {
|
||||
char* name;
|
||||
Rune* r;
|
||||
int i, n, dirty, samename, isdir;
|
||||
|
@ -617,7 +601,10 @@ get(Text *et, Text *t, Text *argt, int flag1, int _0, Rune *arg, int narg)
|
|||
isdir = (d != nil && (d->qid.type & QTDIR));
|
||||
free(d);
|
||||
if (isdir) {
|
||||
warning(nil, "%s is a directory; can't read with multiple windows on it\n", name);
|
||||
warning(
|
||||
nil,
|
||||
"%s is a directory; can't read with multiple windows on it\n",
|
||||
name);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -656,7 +643,8 @@ get(Text *et, Text *t, Text *argt, int flag1, int _0, Rune *arg, int narg)
|
|||
textsetselect(&u->w->tag, u->w->tag.file->b.nc, u->w->tag.file->b.nc);
|
||||
if (samename) {
|
||||
a = &addr[i];
|
||||
// warning(nil, "%d %d %d %d %d %d\n", a->lorigin, a->rorigin, a->lq0, a->rq0, a->lq1, a->rq1);
|
||||
// warning(nil, "%d %d %d %d %d %d\n", a->lorigin, a->rorigin, a->lq0,
|
||||
// a->rq0, a->lq1, a->rq1);
|
||||
q0 = nlcounttopos(u, 0, a->lq0, a->rq0);
|
||||
q1 = nlcounttopos(u, q0, a->lq1, a->rq1);
|
||||
textsetselect(u, q0, q1);
|
||||
|
@ -669,9 +657,7 @@ get(Text *et, Text *t, Text *argt, int flag1, int _0, Rune *arg, int narg)
|
|||
xfidlog(w, "get");
|
||||
}
|
||||
|
||||
static void
|
||||
checksha1(char *name, File *f, Dir *d)
|
||||
{
|
||||
static void checksha1(char* name, File* f, Dir* d) {
|
||||
int fd, n;
|
||||
DigestState* h;
|
||||
uchar out[20];
|
||||
|
@ -694,9 +680,7 @@ checksha1(char *name, File *f, Dir *d)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
putfile(File *f, int q0, int q1, Rune *namer, int nname)
|
||||
{
|
||||
void putfile(File* f, int q0, int q1, Rune* namer, int nname) {
|
||||
uint n, m;
|
||||
Rune* r;
|
||||
Biobuf* b;
|
||||
|
@ -717,7 +701,14 @@ putfile(File *f, int q0, int q1, Rune *namer, int nname)
|
|||
if (f->unread)
|
||||
warning(nil, "%s not written; file already exists\n", name);
|
||||
else
|
||||
warning(nil, "%s modified%s%s since last read\n\twas %t; now %t\n", name, d->muid[0]?" by ":"", d->muid, f->mtime, d->mtime);
|
||||
warning(
|
||||
nil,
|
||||
"%s modified%s%s since last read\n\twas %t; now %t\n",
|
||||
name,
|
||||
d->muid[0] ? " by " : "",
|
||||
d->muid,
|
||||
f->mtime,
|
||||
d->mtime);
|
||||
f->dev = d->dev;
|
||||
f->qidpath = d->qid.path;
|
||||
f->mtime = d->mtime;
|
||||
|
@ -832,9 +823,7 @@ putfile(File *f, int q0, int q1, Rune *namer, int nname)
|
|||
free(name);
|
||||
}
|
||||
|
||||
static void
|
||||
trimspaces(Text *et)
|
||||
{
|
||||
static void trimspaces(Text* et) {
|
||||
File* f;
|
||||
Rune* r;
|
||||
Text* t;
|
||||
|
@ -855,7 +844,8 @@ trimspaces(Text *et)
|
|||
|
||||
r = fbufalloc();
|
||||
q0 = f->b.nc;
|
||||
delstart = q0; /* end of current space run, or 0 if no active run; = q0 to delete spaces before EOF */
|
||||
delstart = q0; /* end of current space run, or 0 if no active run; = q0 to
|
||||
delete spaces before EOF */
|
||||
while (q0 > 0) {
|
||||
n = RBUFSIZE;
|
||||
if (n > q0)
|
||||
|
@ -891,9 +881,7 @@ trimspaces(Text *et)
|
|||
winunlock(t->w);
|
||||
}
|
||||
|
||||
void
|
||||
put(Text *et, Text *_0, Text *argt, int _1, int _2, Rune *arg, int narg)
|
||||
{
|
||||
void put(Text* et, Text* _0, Text* argt, int _1, int _2, Rune* arg, int narg) {
|
||||
int nname;
|
||||
Rune* namer;
|
||||
Window* w;
|
||||
|
@ -921,9 +909,8 @@ put(Text *et, Text *_0, Text *argt, int _1, int _2, Rune *arg, int narg)
|
|||
free(name);
|
||||
}
|
||||
|
||||
void
|
||||
dump(Text *_0, Text *_1, Text *argt, int isdump, int _2, Rune *arg, int narg)
|
||||
{
|
||||
void dump(
|
||||
Text* _0, Text* _1, Text* argt, int isdump, int _2, Rune* arg, int narg) {
|
||||
char* name;
|
||||
|
||||
USED(_0);
|
||||
|
@ -941,9 +928,8 @@ dump(Text *_0, Text *_1, Text *argt, int isdump, int _2, Rune *arg, int narg)
|
|||
free(name);
|
||||
}
|
||||
|
||||
void
|
||||
cut(Text *et, Text *t, Text *_0, int dosnarf, int docut, Rune *_2, int _3)
|
||||
{
|
||||
void cut(
|
||||
Text* et, Text* t, Text* _0, int dosnarf, int docut, Rune* _2, int _3) {
|
||||
uint q0, q1, n, locked, c;
|
||||
Rune* r;
|
||||
|
||||
|
@ -1012,9 +998,8 @@ cut(Text *et, Text *t, Text *_0, int dosnarf, int docut, Rune *_2, int _3)
|
|||
winunlock(t->w);
|
||||
}
|
||||
|
||||
void
|
||||
paste(Text *et, Text *t, Text *_0, int selectall, int tobody, Rune *_1, int _2)
|
||||
{
|
||||
void paste(
|
||||
Text* et, Text* t, Text* _0, int selectall, int tobody, Rune* _1, int _2) {
|
||||
int c;
|
||||
uint q, q0, q1, n;
|
||||
Rune* r;
|
||||
|
@ -1069,9 +1054,7 @@ paste(Text *et, Text *t, Text *_0, int selectall, int tobody, Rune *_1, int _2)
|
|||
winunlock(t->w);
|
||||
}
|
||||
|
||||
void
|
||||
look(Text *et, Text *t, Text *argt, int _0, int _1, Rune *arg, int narg)
|
||||
{
|
||||
void look(Text* et, Text* t, Text* argt, int _0, int _1, Rune* arg, int narg) {
|
||||
Rune* r;
|
||||
int n;
|
||||
|
||||
|
@ -1097,9 +1080,7 @@ look(Text *et, Text *t, Text *argt, int _0, int _1, Rune *arg, int narg)
|
|||
|
||||
static Rune Lnl[] = {'\n', 0};
|
||||
|
||||
void
|
||||
sendx(Text *et, Text *t, Text *_0, int _1, int _2, Rune *_3, int _4)
|
||||
{
|
||||
void sendx(Text* et, Text* t, Text* _0, int _1, int _2, Rune* _3, int _4) {
|
||||
USED(_0);
|
||||
USED(_1);
|
||||
USED(_2);
|
||||
|
@ -1121,9 +1102,7 @@ sendx(Text *et, Text *t, Text *_0, int _1, int _2, Rune *_3, int _4)
|
|||
textshow(t, t->q1, t->q1, 1);
|
||||
}
|
||||
|
||||
void
|
||||
edit(Text *et, Text *_0, Text *argt, int _1, int _2, Rune *arg, int narg)
|
||||
{
|
||||
void edit(Text* et, Text* _0, Text* argt, int _1, int _2, Rune* arg, int narg) {
|
||||
Rune* r;
|
||||
int len;
|
||||
|
||||
|
@ -1142,9 +1121,7 @@ edit(Text *et, Text *_0, Text *argt, int _1, int _2, Rune *arg, int narg)
|
|||
editcmd(et, arg, narg);
|
||||
}
|
||||
|
||||
void
|
||||
xexit(Text *et, Text *_0, Text *_1, int _2, int _3, Rune *_4, int _5)
|
||||
{
|
||||
void xexit(Text* et, Text* _0, Text* _1, int _2, int _3, Rune* _4, int _5) {
|
||||
USED(et);
|
||||
USED(_0);
|
||||
USED(_1);
|
||||
|
@ -1159,9 +1136,7 @@ xexit(Text *et, Text *_0, Text *_1, int _2, int _3, Rune *_4, int _5)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
putall(Text *et, Text *_0, Text *_1, int _2, int _3, Rune *_4, int _5)
|
||||
{
|
||||
void putall(Text* et, Text* _0, Text* _1, int _2, int _3, Rune* _4, int _5) {
|
||||
int i, j, e;
|
||||
Window* w;
|
||||
Column* c;
|
||||
|
@ -1197,10 +1172,7 @@ putall(Text *et, Text *_0, Text *_1, int _2, int _3, Rune *_4, int _5)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
id(Text *et, Text *_0, Text *_1, int _2, int _3, Rune *_4, int _5)
|
||||
{
|
||||
void id(Text* et, Text* _0, Text* _1, int _2, int _3, Rune* _4, int _5) {
|
||||
USED(_0);
|
||||
USED(_1);
|
||||
USED(_2);
|
||||
|
@ -1212,9 +1184,8 @@ id(Text *et, Text *_0, Text *_1, int _2, int _3, Rune *_4, int _5)
|
|||
warning(nil, "/mnt/acme/%d/\n", et->w->id);
|
||||
}
|
||||
|
||||
void
|
||||
local(Text *et, Text *_0, Text *argt, int _1, int _2, Rune *arg, int narg)
|
||||
{
|
||||
void local(
|
||||
Text* et, Text* _0, Text* argt, int _1, int _2, Rune* arg, int narg) {
|
||||
char *a, *aa;
|
||||
Runestr dir;
|
||||
|
||||
|
@ -1233,9 +1204,8 @@ local(Text *et, Text *_0, Text *argt, int _1, int _2, Rune *arg, int narg)
|
|||
run(nil, runetobyte(arg, narg), dir.r, dir.nr, FALSE, aa, a, FALSE);
|
||||
}
|
||||
|
||||
void
|
||||
xkill(Text *_0, Text *_1, Text *argt, int _2, int _3, Rune *arg, int narg)
|
||||
{
|
||||
void xkill(
|
||||
Text* _0, Text* _1, Text* argt, int _2, int _3, Rune* arg, int narg) {
|
||||
Rune *a, *cmd, *r;
|
||||
int na;
|
||||
|
||||
|
@ -1262,9 +1232,7 @@ xkill(Text *_0, Text *_1, Text *argt, int _2, int _3, Rune *arg, int narg)
|
|||
static Rune Lfix[] = {'f', 'i', 'x', 0};
|
||||
static Rune Lvar[] = {'v', 'a', 'r', 0};
|
||||
|
||||
void
|
||||
fontx(Text *et, Text *t, Text *argt, int _0, int _1, Rune *arg, int narg)
|
||||
{
|
||||
void fontx(Text* et, Text* t, Text* argt, int _0, int _1, Rune* arg, int narg) {
|
||||
Rune *a, *r, *flag, *file;
|
||||
int na, nf;
|
||||
char* aa;
|
||||
|
@ -1344,9 +1312,7 @@ fontx(Text *et, Text *t, Text *argt, int _0, int _1, Rune *arg, int narg)
|
|||
free(flag);
|
||||
}
|
||||
|
||||
void
|
||||
incl(Text *et, Text *_0, Text *argt, int _1, int _2, Rune *arg, int narg)
|
||||
{
|
||||
void incl(Text* et, Text* _0, Text* argt, int _1, int _2, Rune* arg, int narg) {
|
||||
Rune *a, *r;
|
||||
Window* w;
|
||||
int na, n, len;
|
||||
|
@ -1392,9 +1358,7 @@ enum {
|
|||
IError = -1,
|
||||
};
|
||||
|
||||
static int
|
||||
indentval(Rune *s, int n, int type)
|
||||
{
|
||||
static int indentval(Rune* s, int n, int type) {
|
||||
static char* strs[] = {
|
||||
[SPACESINDENT] = "Spaces",
|
||||
[AUTOINDENT] = "Indent",
|
||||
|
@ -1419,18 +1383,15 @@ indentval(Rune *s, int n, int type)
|
|||
return IError;
|
||||
}
|
||||
|
||||
static void
|
||||
fixindent(Window *w, void *arg)
|
||||
{
|
||||
static void fixindent(Window* w, void* arg) {
|
||||
int t;
|
||||
|
||||
t = (int)arg;
|
||||
w->indent[t] = globalindent[t];
|
||||
}
|
||||
|
||||
void
|
||||
indent(Text *et, Text* _0, Text *argt, int type, int _1, Rune *arg, int narg)
|
||||
{
|
||||
void indent(
|
||||
Text* et, Text* _0, Text* argt, int type, int _1, Rune* arg, int narg) {
|
||||
Rune *a, *r;
|
||||
Window* w;
|
||||
int na, len, ival;
|
||||
|
@ -1456,9 +1417,7 @@ indent(Text *et, Text* _0, Text *argt, int type, int _1, Rune *arg, int narg)
|
|||
w->indent[type] = ival;
|
||||
}
|
||||
|
||||
void
|
||||
tab(Text *et, Text *_0, Text *argt, int _1, int _2, Rune *arg, int narg)
|
||||
{
|
||||
void tab(Text* et, Text* _0, Text* argt, int _1, int _2, Rune* arg, int narg) {
|
||||
Rune *a, *r;
|
||||
Window* w;
|
||||
int na, len, tab;
|
||||
|
@ -1493,12 +1452,15 @@ tab(Text *et, Text *_0, Text *argt, int _1, int _2, Rune *arg, int narg)
|
|||
winresize(w, w->r, FALSE, TRUE);
|
||||
}
|
||||
} else
|
||||
warning(nil, "%.*S: Tab %d\n", w->body.file->nname, w->body.file->name, w->body.tabstop);
|
||||
warning(
|
||||
nil,
|
||||
"%.*S: Tab %d\n",
|
||||
w->body.file->nname,
|
||||
w->body.file->name,
|
||||
w->body.tabstop);
|
||||
}
|
||||
|
||||
void
|
||||
runproc(void *argvp)
|
||||
{
|
||||
void runproc(void* argvp) {
|
||||
/* args: */
|
||||
Window* win;
|
||||
char* s;
|
||||
|
@ -1753,9 +1715,7 @@ Hard:
|
|||
threadexits(nil);
|
||||
}
|
||||
|
||||
void
|
||||
runwaittask(void *v)
|
||||
{
|
||||
void runwaittask(void* v) {
|
||||
Command* c;
|
||||
Channel* cpid;
|
||||
void** a;
|
||||
|
@ -1781,9 +1741,9 @@ runwaittask(void *v)
|
|||
chanfree(cpid);
|
||||
}
|
||||
|
||||
void
|
||||
run(Window *win, char *s, Rune *rdir, int ndir, int newns, char *argaddr, char *xarg, int iseditcmd)
|
||||
{
|
||||
void run(
|
||||
Window* win, char* s, Rune* rdir, int ndir, int newns, char* argaddr,
|
||||
char* xarg, int iseditcmd) {
|
||||
void** arg;
|
||||
Command* c;
|
||||
Channel* cpid;
|
||||
|
|
65
file.c
65
file.c
|
@ -23,8 +23,7 @@
|
|||
*/
|
||||
|
||||
typedef struct Undo Undo;
|
||||
struct Undo
|
||||
{
|
||||
struct Undo {
|
||||
short type; /* Delete, Insert, Filename */
|
||||
short mod; /* modify bit */
|
||||
uint seq; /* sequence number */
|
||||
|
@ -32,14 +31,9 @@ struct Undo
|
|||
uint n; /* # runes in string or file name */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
Undosize = sizeof(Undo)/sizeof(Rune)
|
||||
};
|
||||
enum { Undosize = sizeof(Undo) / sizeof(Rune) };
|
||||
|
||||
File*
|
||||
fileaddtext(File *f, Text *t)
|
||||
{
|
||||
File* fileaddtext(File* f, Text* t) {
|
||||
if (f == nil) {
|
||||
f = emalloc(sizeof(File));
|
||||
f->unread = TRUE;
|
||||
|
@ -50,9 +44,7 @@ fileaddtext(File *f, Text *t)
|
|||
return f;
|
||||
}
|
||||
|
||||
void
|
||||
filedeltext(File *f, Text *t)
|
||||
{
|
||||
void filedeltext(File* f, Text* t) {
|
||||
int i;
|
||||
|
||||
for (i = 0; i < f->ntext; i++)
|
||||
|
@ -71,9 +63,7 @@ filedeltext(File *f, Text *t)
|
|||
f->curtext = f->text[0];
|
||||
}
|
||||
|
||||
void
|
||||
fileinsert(File *f, uint p0, Rune *s, uint ns)
|
||||
{
|
||||
void fileinsert(File* f, uint p0, Rune* s, uint ns) {
|
||||
if (p0 > f->b.nc)
|
||||
error("internal error: fileinsert");
|
||||
if (f->seq > 0)
|
||||
|
@ -83,9 +73,7 @@ fileinsert(File *f, uint p0, Rune *s, uint ns)
|
|||
f->mod = TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
fileuninsert(File *f, Buffer *delta, uint p0, uint ns)
|
||||
{
|
||||
void fileuninsert(File* f, Buffer* delta, uint p0, uint ns) {
|
||||
Undo u;
|
||||
|
||||
/* undo an insertion by deleting */
|
||||
|
@ -97,9 +85,7 @@ fileuninsert(File *f, Buffer *delta, uint p0, uint ns)
|
|||
bufinsert(delta, delta->nc, (Rune*)&u, Undosize);
|
||||
}
|
||||
|
||||
void
|
||||
filedelete(File *f, uint p0, uint p1)
|
||||
{
|
||||
void filedelete(File* f, uint p0, uint p1) {
|
||||
if (!(p0 <= p1 && p0 <= f->b.nc && p1 <= f->b.nc))
|
||||
error("internal error: filedelete");
|
||||
if (f->seq > 0)
|
||||
|
@ -109,9 +95,7 @@ filedelete(File *f, uint p0, uint p1)
|
|||
f->mod = TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
fileundelete(File *f, Buffer *delta, uint p0, uint p1)
|
||||
{
|
||||
void fileundelete(File* f, Buffer* delta, uint p0, uint p1) {
|
||||
Undo u;
|
||||
Rune* buf;
|
||||
uint i, n;
|
||||
|
@ -132,12 +116,9 @@ fileundelete(File *f, Buffer *delta, uint p0, uint p1)
|
|||
}
|
||||
fbuffree(buf);
|
||||
bufinsert(delta, delta->nc, (Rune*)&u, Undosize);
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
filesetname(File *f, Rune *name, int n)
|
||||
{
|
||||
void filesetname(File* f, Rune* name, int n) {
|
||||
if (f->seq > 0)
|
||||
fileunsetname(f, &f->delta);
|
||||
free(f->name);
|
||||
|
@ -147,9 +128,7 @@ filesetname(File *f, Rune *name, int n)
|
|||
f->unread = TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
fileunsetname(File *f, Buffer *delta)
|
||||
{
|
||||
void fileunsetname(File* f, Buffer* delta) {
|
||||
Undo u;
|
||||
|
||||
/* undo a file name change by restoring old name */
|
||||
|
@ -163,18 +142,14 @@ fileunsetname(File *f, Buffer *delta)
|
|||
bufinsert(delta, delta->nc, (Rune*)&u, Undosize);
|
||||
}
|
||||
|
||||
uint
|
||||
fileload(File *f, uint p0, int fd, int *nulls, DigestState *h)
|
||||
{
|
||||
uint fileload(File* f, uint p0, int fd, int* nulls, DigestState* h) {
|
||||
if (f->seq > 0)
|
||||
error("undo in file.load unimplemented");
|
||||
return bufload(&f->b, p0, fd, nulls, h);
|
||||
}
|
||||
|
||||
/* return sequence number of pending redo */
|
||||
uint
|
||||
fileredoseq(File *f)
|
||||
{
|
||||
uint fileredoseq(File* f) {
|
||||
Undo u;
|
||||
Buffer* delta;
|
||||
|
||||
|
@ -185,9 +160,7 @@ fileredoseq(File *f)
|
|||
return u.seq;
|
||||
}
|
||||
|
||||
void
|
||||
fileundo(File *f, int isundo, uint *q0p, uint *q1p)
|
||||
{
|
||||
void fileundo(File* f, int isundo, uint* q0p, uint* q1p) {
|
||||
Undo u;
|
||||
Rune* buf;
|
||||
uint i, j, n, up;
|
||||
|
@ -278,17 +251,13 @@ fileundo(File *f, int isundo, uint *q0p, uint *q1p)
|
|||
fbuffree(buf);
|
||||
}
|
||||
|
||||
void
|
||||
filereset(File *f)
|
||||
{
|
||||
void filereset(File* f) {
|
||||
bufreset(&f->delta);
|
||||
bufreset(&f->epsilon);
|
||||
f->seq = 0;
|
||||
}
|
||||
|
||||
void
|
||||
fileclose(File *f)
|
||||
{
|
||||
void fileclose(File* f) {
|
||||
free(f->name);
|
||||
f->nname = 0;
|
||||
f->name = nil;
|
||||
|
@ -302,9 +271,7 @@ fileclose(File *f)
|
|||
free(f);
|
||||
}
|
||||
|
||||
void
|
||||
filemark(File *f)
|
||||
{
|
||||
void filemark(File* f) {
|
||||
if (f->epsilon.nc)
|
||||
bufdelete(&f->epsilon, 0, f->epsilon.nc);
|
||||
f->seq = seq;
|
||||
|
|
1
fns.h
1
fns.h
|
@ -95,6 +95,7 @@ void flushwarnings(void);
|
|||
void startplumbing(void);
|
||||
long nlcount(Text*, long, long, long*);
|
||||
long nlcounttopos(Text*, long, long, long);
|
||||
Rune* parsetag(Window*, int*);
|
||||
|
||||
Runestr runestr(Rune*, uint);
|
||||
Range range(int, int);
|
||||
|
|
159
fsys.c
159
fsys.c
|
@ -14,11 +14,7 @@
|
|||
|
||||
static int sfd;
|
||||
|
||||
enum
|
||||
{
|
||||
Nhash = 16,
|
||||
DEBUG = 0
|
||||
};
|
||||
enum { Nhash = 16, DEBUG = 0 };
|
||||
|
||||
static Fid* fids[Nhash];
|
||||
|
||||
|
@ -40,9 +36,7 @@ static Xfid* fsyswstat(Xfid*, Fid*);
|
|||
|
||||
Xfid* (*fcall[Tmax])(Xfid*, Fid*);
|
||||
|
||||
static void
|
||||
initfcall(void)
|
||||
{
|
||||
static void initfcall(void) {
|
||||
fcall[Tflush] = fsysflush;
|
||||
fcall[Tversion] = fsysversion;
|
||||
fcall[Tauth] = fsysauth;
|
||||
|
@ -62,23 +56,25 @@ char Eperm[] = "permission denied";
|
|||
char Eexist[] = "file does not exist";
|
||||
char Enotdir[] = "not a directory";
|
||||
|
||||
Dirtab dirtab[]=
|
||||
{
|
||||
Dirtab dirtab[] = {
|
||||
{".", QTDIR, Qdir, 0500 | DMDIR},
|
||||
{"acme", QTDIR, Qacme, 0500 | DMDIR},
|
||||
{"cons", QTFILE, Qcons, 0600},
|
||||
{"consctl", QTFILE, Qconsctl, 0000},
|
||||
{ "draw", QTDIR, Qdraw, 0000|DMDIR }, /* to suppress graphics progs started in acme */
|
||||
{"draw",
|
||||
QTDIR,
|
||||
Qdraw,
|
||||
0000 | DMDIR}, /* to suppress graphics progs started in acme */
|
||||
{"editout", QTFILE, Qeditout, 0200},
|
||||
{"index", QTFILE, Qindex, 0400},
|
||||
{"label", QTFILE, Qlabel, 0600},
|
||||
{"log", QTFILE, Qlog, 0400},
|
||||
{"new", QTDIR, Qnew, 0500 | DMDIR},
|
||||
{ nil, }
|
||||
};
|
||||
|
||||
Dirtab dirtabw[]=
|
||||
{
|
||||
nil,
|
||||
}};
|
||||
|
||||
Dirtab dirtabw[] = {
|
||||
{".", QTDIR, Qdir, 0500 | DMDIR},
|
||||
{"addr", QTFILE, QWaddr, 0600},
|
||||
{"body", QTAPPEND, QWbody, 0600 | DMAPPEND},
|
||||
|
@ -91,12 +87,12 @@ Dirtab dirtabw[]=
|
|||
{"wrsel", QTFILE, QWwrsel, 0200},
|
||||
{"tag", QTAPPEND, QWtag, 0600 | DMAPPEND},
|
||||
{"xdata", QTFILE, QWxdata, 0600},
|
||||
{ nil, }
|
||||
};
|
||||
{
|
||||
nil,
|
||||
}};
|
||||
|
||||
typedef struct Mnt Mnt;
|
||||
struct Mnt
|
||||
{
|
||||
struct Mnt {
|
||||
QLock lk;
|
||||
int id;
|
||||
Mntdir* md;
|
||||
|
@ -114,9 +110,7 @@ int messagesize = Maxblock+IOHDRSZ; /* good start */
|
|||
|
||||
void fsysproc(void*);
|
||||
|
||||
void
|
||||
fsysinit(void)
|
||||
{
|
||||
void fsysinit(void) {
|
||||
int p[2];
|
||||
char* u;
|
||||
|
||||
|
@ -132,9 +126,7 @@ fsysinit(void)
|
|||
proccreate(fsysproc, nil, STACK);
|
||||
}
|
||||
|
||||
void
|
||||
fsysproc(void *v)
|
||||
{
|
||||
void fsysproc(void* v) {
|
||||
int n;
|
||||
Xfid* x;
|
||||
Fid* f;
|
||||
|
@ -146,7 +138,9 @@ fsysproc(void *v)
|
|||
USED(v);
|
||||
x = nil;
|
||||
for (;;) {
|
||||
buf = emalloc(messagesize+UTFmax); /* overflow for appending partial rune in xfidwrite */
|
||||
buf = emalloc(
|
||||
messagesize +
|
||||
UTFmax); /* overflow for appending partial rune in xfidwrite */
|
||||
n = read9pmsg(sfd, buf, messagesize);
|
||||
if (n <= 0) {
|
||||
if (closing)
|
||||
|
@ -189,9 +183,7 @@ fsysproc(void *v)
|
|||
}
|
||||
}
|
||||
|
||||
Mntdir*
|
||||
fsysaddid(Rune *dir, int ndir, Rune **incl, int nincl)
|
||||
{
|
||||
Mntdir* fsysaddid(Rune* dir, int ndir, Rune** incl, int nincl) {
|
||||
Mntdir* m;
|
||||
int id;
|
||||
|
||||
|
@ -210,17 +202,13 @@ fsysaddid(Rune *dir, int ndir, Rune **incl, int nincl)
|
|||
return m;
|
||||
}
|
||||
|
||||
void
|
||||
fsysincid(Mntdir *m)
|
||||
{
|
||||
void fsysincid(Mntdir* m) {
|
||||
qlock(&mnt.lk);
|
||||
m->ref++;
|
||||
qunlock(&mnt.lk);
|
||||
}
|
||||
|
||||
void
|
||||
fsysdelid(Mntdir *idm)
|
||||
{
|
||||
void fsysdelid(Mntdir* idm) {
|
||||
Mntdir *m, *prev;
|
||||
int i;
|
||||
char buf[64];
|
||||
|
@ -257,15 +245,11 @@ fsysdelid(Mntdir *idm)
|
|||
/*
|
||||
* Called only in exec.c:/^run(), from a different FD group
|
||||
*/
|
||||
Mntdir*
|
||||
fsysmount(Rune *dir, int ndir, Rune **incl, int nincl)
|
||||
{
|
||||
Mntdir* fsysmount(Rune* dir, int ndir, Rune** incl, int nincl) {
|
||||
return fsysaddid(dir, ndir, incl, nincl);
|
||||
}
|
||||
|
||||
void
|
||||
fsysclose(void)
|
||||
{
|
||||
void fsysclose(void) {
|
||||
closing = 1;
|
||||
/*
|
||||
* apparently this is not kosher on openbsd.
|
||||
|
@ -275,9 +259,7 @@ fsysclose(void)
|
|||
*/
|
||||
}
|
||||
|
||||
Xfid*
|
||||
respond(Xfid *x, Fcall *t, char *err)
|
||||
{
|
||||
Xfid* respond(Xfid* x, Fcall* t, char* err) {
|
||||
int n;
|
||||
|
||||
if (err) {
|
||||
|
@ -301,10 +283,7 @@ respond(Xfid *x, Fcall *t, char *err)
|
|||
return x;
|
||||
}
|
||||
|
||||
static
|
||||
Xfid*
|
||||
fsysversion(Xfid *x, Fid *f)
|
||||
{
|
||||
static Xfid* fsysversion(Xfid* x, Fid* f) {
|
||||
Fcall t;
|
||||
|
||||
USED(f);
|
||||
|
@ -318,29 +297,20 @@ fsysversion(Xfid *x, Fid *f)
|
|||
return respond(x, &t, nil);
|
||||
}
|
||||
|
||||
static
|
||||
Xfid*
|
||||
fsysauth(Xfid *x, Fid *f)
|
||||
{
|
||||
static Xfid* fsysauth(Xfid* x, Fid* f) {
|
||||
Fcall t;
|
||||
|
||||
USED(f);
|
||||
return respond(x, &t, "acme: authentication not required");
|
||||
}
|
||||
|
||||
static
|
||||
Xfid*
|
||||
fsysflush(Xfid *x, Fid *f)
|
||||
{
|
||||
static Xfid* fsysflush(Xfid* x, Fid* f) {
|
||||
USED(f);
|
||||
sendp(x->c, (void*)xfidflush);
|
||||
return nil;
|
||||
}
|
||||
|
||||
static
|
||||
Xfid*
|
||||
fsysattach(Xfid *x, Fid *f)
|
||||
{
|
||||
static Xfid* fsysattach(Xfid* x, Fid* f) {
|
||||
Fcall t;
|
||||
int id;
|
||||
Mntdir* m;
|
||||
|
@ -374,10 +344,7 @@ fsysattach(Xfid *x, Fid *f)
|
|||
return respond(x, &t, nil);
|
||||
}
|
||||
|
||||
static
|
||||
Xfid*
|
||||
fsyswalk(Xfid *x, Fid *f)
|
||||
{
|
||||
static Xfid* fsyswalk(Xfid* x, Fid* f) {
|
||||
Fcall t;
|
||||
int c, i, j, id;
|
||||
Qid q;
|
||||
|
@ -519,10 +486,7 @@ fsyswalk(Xfid *x, Fid *f)
|
|||
return respond(x, &t, err);
|
||||
}
|
||||
|
||||
static
|
||||
Xfid*
|
||||
fsysopen(Xfid *x, Fid *f)
|
||||
{
|
||||
static Xfid* fsysopen(Xfid* x, Fid* f) {
|
||||
Fcall t;
|
||||
int m;
|
||||
|
||||
|
@ -554,27 +518,16 @@ fsysopen(Xfid *x, Fid *f)
|
|||
return respond(x, &t, Eperm);
|
||||
}
|
||||
|
||||
static
|
||||
Xfid*
|
||||
fsyscreate(Xfid *x, Fid *f)
|
||||
{
|
||||
static Xfid* fsyscreate(Xfid* x, Fid* f) {
|
||||
Fcall t;
|
||||
|
||||
USED(f);
|
||||
return respond(x, &t, Eperm);
|
||||
}
|
||||
|
||||
static
|
||||
int
|
||||
idcmp(const void *a, const void *b)
|
||||
{
|
||||
return *(int*)a - *(int*)b;
|
||||
}
|
||||
static int idcmp(const void* a, const void* b) { return *(int*)a - *(int*)b; }
|
||||
|
||||
static
|
||||
Xfid*
|
||||
fsysread(Xfid *x, Fid *f)
|
||||
{
|
||||
static Xfid* fsysread(Xfid* x, Fid* f) {
|
||||
Fcall t;
|
||||
uchar* b;
|
||||
int i, id, n, o, e, j, k, *ids, nids;
|
||||
|
@ -649,60 +602,44 @@ fsysread(Xfid *x, Fid *f)
|
|||
return nil;
|
||||
}
|
||||
|
||||
static
|
||||
Xfid*
|
||||
fsyswrite(Xfid *x, Fid *f)
|
||||
{
|
||||
static Xfid* fsyswrite(Xfid* x, Fid* f) {
|
||||
USED(f);
|
||||
sendp(x->c, (void*)xfidwrite);
|
||||
return nil;
|
||||
}
|
||||
|
||||
static
|
||||
Xfid*
|
||||
fsysclunk(Xfid *x, Fid *f)
|
||||
{
|
||||
static Xfid* fsysclunk(Xfid* x, Fid* f) {
|
||||
fsysdelid(f->mntdir);
|
||||
sendp(x->c, (void*)xfidclose);
|
||||
return nil;
|
||||
}
|
||||
|
||||
static
|
||||
Xfid*
|
||||
fsysremove(Xfid *x, Fid *f)
|
||||
{
|
||||
static Xfid* fsysremove(Xfid* x, Fid* f) {
|
||||
Fcall t;
|
||||
|
||||
USED(f);
|
||||
return respond(x, &t, Eperm);
|
||||
}
|
||||
|
||||
static
|
||||
Xfid*
|
||||
fsysstat(Xfid *x, Fid *f)
|
||||
{
|
||||
static Xfid* fsysstat(Xfid* x, Fid* f) {
|
||||
Fcall t;
|
||||
|
||||
t.stat = emalloc(messagesize - IOHDRSZ);
|
||||
t.nstat = dostat(WIN(x->f->qid), f->dir, t.stat, messagesize-IOHDRSZ, getclock());
|
||||
t.nstat =
|
||||
dostat(WIN(x->f->qid), f->dir, t.stat, messagesize - IOHDRSZ, getclock());
|
||||
x = respond(x, &t, nil);
|
||||
free(t.stat);
|
||||
return x;
|
||||
}
|
||||
|
||||
static
|
||||
Xfid*
|
||||
fsyswstat(Xfid *x, Fid *f)
|
||||
{
|
||||
static Xfid* fsyswstat(Xfid* x, Fid* f) {
|
||||
Fcall t;
|
||||
|
||||
USED(f);
|
||||
return respond(x, &t, Eperm);
|
||||
}
|
||||
|
||||
Fid*
|
||||
newfid(int fid)
|
||||
{
|
||||
Fid* newfid(int fid) {
|
||||
Fid *f, *ff, **fh;
|
||||
|
||||
ff = nil;
|
||||
|
@ -723,15 +660,9 @@ newfid(int fid)
|
|||
return f;
|
||||
}
|
||||
|
||||
uint
|
||||
getclock(void)
|
||||
{
|
||||
return time(0);
|
||||
}
|
||||
uint getclock(void) { return time(0); }
|
||||
|
||||
int
|
||||
dostat(int id, Dirtab *dir, uchar *buf, int nbuf, uint clock)
|
||||
{
|
||||
int dostat(int id, Dirtab* dir, uchar* buf, int nbuf, uint clock) {
|
||||
Dir d;
|
||||
|
||||
d.qid.path = QID(id, dir->qid);
|
||||
|
|
31
logf.c
31
logf.c
|
@ -14,8 +14,7 @@
|
|||
|
||||
// State for global log file.
|
||||
typedef struct Log Log;
|
||||
struct Log
|
||||
{
|
||||
struct Log {
|
||||
QLock lk;
|
||||
Rendez r;
|
||||
|
||||
|
@ -39,9 +38,7 @@ struct Log
|
|||
|
||||
static Log eventlog;
|
||||
|
||||
void
|
||||
xfidlogopen(Xfid *x)
|
||||
{
|
||||
void xfidlogopen(Xfid* x) {
|
||||
qlock(&eventlog.lk);
|
||||
if (eventlog.nf >= eventlog.mf) {
|
||||
eventlog.mf = eventlog.mf * 2;
|
||||
|
@ -55,9 +52,7 @@ xfidlogopen(Xfid *x)
|
|||
qunlock(&eventlog.lk);
|
||||
}
|
||||
|
||||
void
|
||||
xfidlogclose(Xfid *x)
|
||||
{
|
||||
void xfidlogclose(Xfid* x) {
|
||||
int i;
|
||||
|
||||
qlock(&eventlog.lk);
|
||||
|
@ -70,9 +65,7 @@ xfidlogclose(Xfid *x)
|
|||
qunlock(&eventlog.lk);
|
||||
}
|
||||
|
||||
void
|
||||
xfidlogread(Xfid *x)
|
||||
{
|
||||
void xfidlogread(Xfid* x) {
|
||||
char* p;
|
||||
int i;
|
||||
Fcall fc;
|
||||
|
@ -82,7 +75,8 @@ xfidlogread(Xfid *x)
|
|||
eventlog.mread = eventlog.mread * 2;
|
||||
if (eventlog.mread == 0)
|
||||
eventlog.mread = 8;
|
||||
eventlog.read = erealloc(eventlog.read, eventlog.mread*sizeof eventlog.read[0]);
|
||||
eventlog.read =
|
||||
erealloc(eventlog.read, eventlog.mread * sizeof eventlog.read[0]);
|
||||
}
|
||||
eventlog.read[eventlog.nread++] = x;
|
||||
|
||||
|
@ -115,9 +109,7 @@ xfidlogread(Xfid *x)
|
|||
free(p);
|
||||
}
|
||||
|
||||
void
|
||||
xfidlogflush(Xfid *x)
|
||||
{
|
||||
void xfidlogflush(Xfid* x) {
|
||||
int i;
|
||||
Xfid* rx;
|
||||
|
||||
|
@ -153,9 +145,7 @@ xfidlogflush(Xfid *x)
|
|||
* op == "del" for deleted window
|
||||
* - called from winclose
|
||||
*/
|
||||
void
|
||||
xfidlog(Window *w, char *op)
|
||||
{
|
||||
void xfidlog(Window* w, char* op) {
|
||||
int i, n;
|
||||
vlong min;
|
||||
File* f;
|
||||
|
@ -175,7 +165,10 @@ xfidlog(Window *w, char *op)
|
|||
free(eventlog.ev[i]);
|
||||
eventlog.nev -= n;
|
||||
eventlog.start += n;
|
||||
memmove(eventlog.ev, eventlog.ev+n, eventlog.nev*sizeof eventlog.ev[0]);
|
||||
memmove(
|
||||
eventlog.ev,
|
||||
eventlog.ev + n,
|
||||
eventlog.nev * sizeof eventlog.ev[0]);
|
||||
}
|
||||
|
||||
// Otherwise grow.
|
||||
|
|
205
look.c
205
look.c
|
@ -21,9 +21,7 @@ Window* openfile(Text*, Expand*);
|
|||
|
||||
int nuntitled;
|
||||
|
||||
void
|
||||
plumbthread(void *v)
|
||||
{
|
||||
void plumbthread(void* v) {
|
||||
CFid* fid;
|
||||
Plumbmsg* m;
|
||||
Timer* t;
|
||||
|
@ -70,18 +68,13 @@ plumbthread(void *v)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
startplumbing(void)
|
||||
{
|
||||
void startplumbing(void) {
|
||||
cplumb = chancreate(sizeof(Plumbmsg*), 0);
|
||||
chansetname(cplumb, "cplumb");
|
||||
threadcreate(plumbthread, nil, STACK);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
look3(Text *t, uint q0, uint q1, int external)
|
||||
{
|
||||
void look3(Text* t, uint q0, uint q1, int external) {
|
||||
int n, c, f, expanded;
|
||||
Text* ct;
|
||||
Expand e;
|
||||
|
@ -100,7 +93,9 @@ look3(Text *t, uint q0, uint q1, int external)
|
|||
if (expanded == FALSE)
|
||||
return;
|
||||
f = 0;
|
||||
if((e.u.at!=nil && t->w!=nil) || (e.nname>0 && lookfile(e.name, e.nname)!=nil))
|
||||
if (
|
||||
(e.u.at != nil && t->w != nil) ||
|
||||
(e.nname > 0 && lookfile(e.name, e.nname) != nil))
|
||||
f = 1; /* acme can do it without loading a file */
|
||||
if (q0 != e.q0 || q1 != e.q1)
|
||||
f |= 2; /* second (post-expand) message follows */
|
||||
|
@ -167,9 +162,11 @@ look3(Text *t, uint q0, uint q1, int external)
|
|||
q1 = t->q1;
|
||||
} else {
|
||||
p = q0;
|
||||
while(q0>0 && (c=tgetc(t, q0-1))!=' ' && c!='\t' && c!='\n')
|
||||
while (q0 > 0 && (c = tgetc(t, q0 - 1)) != ' ' && c != '\t' &&
|
||||
c != '\n')
|
||||
q0--;
|
||||
while(q1<t->file->b.nc && (c=tgetc(t, q1))!=' ' && c!='\t' && c!='\n')
|
||||
while (q1 < t->file->b.nc && (c = tgetc(t, q1)) != ' ' && c != '\t' &&
|
||||
c != '\n')
|
||||
q1++;
|
||||
if (q1 == q0) {
|
||||
plumbfree(m);
|
||||
|
@ -209,7 +206,9 @@ look3(Text *t, uint q0, uint q1, int external)
|
|||
r = runemalloc(n);
|
||||
bufread(&t->file->b, e.q0, r, n);
|
||||
if (search(ct, r, n) && e.jump)
|
||||
moveto(mousectl, addpt(frptofchar(&ct->fr, ct->fr.p0), Pt(4, ct->fr.font->height-4)));
|
||||
moveto(
|
||||
mousectl,
|
||||
addpt(frptofchar(&ct->fr, ct->fr.p0), Pt(4, ct->fr.font->height - 4)));
|
||||
if (t->w != ct->w)
|
||||
winunlock(ct->w);
|
||||
free(r);
|
||||
|
@ -220,9 +219,7 @@ look3(Text *t, uint q0, uint q1, int external)
|
|||
free(e.bname);
|
||||
}
|
||||
|
||||
int
|
||||
plumbgetc(void *a, uint n)
|
||||
{
|
||||
int plumbgetc(void* a, uint n) {
|
||||
Rune* r;
|
||||
|
||||
r = a;
|
||||
|
@ -231,14 +228,16 @@ plumbgetc(void *a, uint n)
|
|||
return r[n];
|
||||
}
|
||||
|
||||
void
|
||||
plumblook(Plumbmsg *m)
|
||||
{
|
||||
void plumblook(Plumbmsg* m) {
|
||||
Expand e;
|
||||
char* addr;
|
||||
|
||||
if (m->ndata >= BUFSIZE) {
|
||||
warning(nil, "insanely long file name (%d bytes) in plumb message (%.32s...)\n", m->ndata, m->data);
|
||||
warning(
|
||||
nil,
|
||||
"insanely long file name (%d bytes) in plumb message (%.32s...)\n",
|
||||
m->ndata,
|
||||
m->data);
|
||||
return;
|
||||
}
|
||||
e.q0 = 0;
|
||||
|
@ -262,9 +261,7 @@ plumblook(Plumbmsg *m)
|
|||
free(e.u.at);
|
||||
}
|
||||
|
||||
void
|
||||
plumbshow(Plumbmsg *m)
|
||||
{
|
||||
void plumbshow(Plumbmsg* m) {
|
||||
Window* w;
|
||||
Rune rb[256], *r;
|
||||
int nb, nr;
|
||||
|
@ -302,9 +299,7 @@ plumbshow(Plumbmsg *m)
|
|||
xfidlog(w, "new");
|
||||
}
|
||||
|
||||
int
|
||||
search(Text *ct, Rune *r, uint n)
|
||||
{
|
||||
int search(Text* ct, Rune* r, uint n) {
|
||||
uint q, nb, maxn;
|
||||
int around;
|
||||
Rune *s, *b, *c;
|
||||
|
@ -375,9 +370,7 @@ search(Text *ct, Rune *r, uint n)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
int
|
||||
isfilec(Rune r)
|
||||
{
|
||||
int isfilec(Rune r) {
|
||||
static Rune Lx[] = {'.', '-', '+', '/', ':', 0};
|
||||
if (isalnum(r))
|
||||
return TRUE;
|
||||
|
@ -387,9 +380,7 @@ isfilec(Rune r)
|
|||
}
|
||||
|
||||
/* Runestr wrapper for cleanname */
|
||||
Runestr
|
||||
cleanrname(Runestr rs)
|
||||
{
|
||||
Runestr cleanrname(Runestr rs) {
|
||||
char* s;
|
||||
int nb, nulls;
|
||||
|
||||
|
@ -400,9 +391,7 @@ cleanrname(Runestr rs)
|
|||
return rs;
|
||||
}
|
||||
|
||||
Runestr
|
||||
includefile(Rune *dir, Rune *file, int nfile)
|
||||
{
|
||||
Runestr includefile(Rune* dir, Rune* file, int nfile) {
|
||||
int m, n;
|
||||
char* a;
|
||||
Rune* r;
|
||||
|
@ -425,17 +414,36 @@ includefile(Rune *dir, Rune *file, int nfile)
|
|||
|
||||
static Rune* objdir;
|
||||
|
||||
Runestr
|
||||
includename(Text *t, Rune *r, int n)
|
||||
{
|
||||
Runestr includename(Text* t, Rune* r, int n) {
|
||||
Window* w;
|
||||
char buf[128];
|
||||
Rune Lsysinclude[] = { '/', 's', 'y', 's', '/', 'i', 'n', 'c', 'l', 'u', 'd', 'e', 0 };
|
||||
Rune Lusrinclude[] = { '/', 'u', 's', 'r', '/', 'i', 'n', 'c', 'l', 'u', 'd', 'e', 0 };
|
||||
Rune Lusrlocalinclude[] = { '/', 'u', 's', 'r', '/', 'l', 'o', 'c', 'a', 'l',
|
||||
'/', 'i', 'n', 'c', 'l', 'u', 'd', 'e', 0 };
|
||||
Rune Lusrlocalplan9include[] = { '/', 'u', 's', 'r', '/', 'l', 'o', 'c', 'a', 'l',
|
||||
'/', 'p', 'l', 'a', 'n', '9', '/', 'i', 'n', 'c', 'l', 'u', 'd', 'e', 0 };
|
||||
Rune Lsysinclude[] =
|
||||
{'/', 's', 'y', 's', '/', 'i', 'n', 'c', 'l', 'u', 'd', 'e', 0};
|
||||
Rune Lusrinclude[] =
|
||||
{'/', 'u', 's', 'r', '/', 'i', 'n', 'c', 'l', 'u', 'd', 'e', 0};
|
||||
Rune Lusrlocalinclude[] = {
|
||||
'/',
|
||||
'u',
|
||||
's',
|
||||
'r',
|
||||
'/',
|
||||
'l',
|
||||
'o',
|
||||
'c',
|
||||
'a',
|
||||
'l',
|
||||
'/',
|
||||
'i',
|
||||
'n',
|
||||
'c',
|
||||
'l',
|
||||
'u',
|
||||
'd',
|
||||
'e',
|
||||
0};
|
||||
Rune Lusrlocalplan9include[] = {'/', 'u', 's', 'r', '/', 'l', 'o', 'c', 'a',
|
||||
'l', '/', 'p', 'l', 'a', 'n', '9', '/', 'i',
|
||||
'n', 'c', 'l', 'u', 'd', 'e', 0};
|
||||
Runestr file;
|
||||
int i;
|
||||
|
||||
|
@ -474,12 +482,10 @@ includename(Text *t, Rune *r, int n)
|
|||
return runestr(r, n);
|
||||
}
|
||||
|
||||
Runestr
|
||||
dirname(Text *t, Rune *r, int n)
|
||||
{
|
||||
Rune *b, c;
|
||||
uint m, nt;
|
||||
int slash;
|
||||
Runestr dirname(Text* t, Rune* r, int n) {
|
||||
Rune* b;
|
||||
uint nt;
|
||||
int slash, i;
|
||||
Runestr tmp;
|
||||
|
||||
b = nil;
|
||||
|
@ -490,16 +496,14 @@ dirname(Text *t, Rune *r, int n)
|
|||
goto Rescue;
|
||||
if (n >= 1 && r[0] == '/')
|
||||
goto Rescue;
|
||||
b = runemalloc(nt+n+1);
|
||||
bufread(&t->w->tag.file->b, 0, b, nt);
|
||||
b = parsetag(t->w, &i);
|
||||
slash = -1;
|
||||
for(m=0; m<nt; m++){
|
||||
c = b[m];
|
||||
if(c == '/')
|
||||
slash = m;
|
||||
if(c==' ' || c=='\t')
|
||||
for (i--; i >= 0; i--) {
|
||||
if (b[i] == '/') {
|
||||
slash = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (slash < 0)
|
||||
goto Rescue;
|
||||
runemove(b + slash + 1, r, n);
|
||||
|
@ -514,9 +518,7 @@ dirname(Text *t, Rune *r, int n)
|
|||
return tmp;
|
||||
}
|
||||
|
||||
static int
|
||||
texthas(Text *t, uint q0, Rune *r)
|
||||
{
|
||||
static int texthas(Text* t, uint q0, Rune* r) {
|
||||
int i;
|
||||
|
||||
if ((int)q0 < 0)
|
||||
|
@ -527,9 +529,7 @@ texthas(Text *t, uint q0, Rune *r)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
int
|
||||
expandfile(Text *t, uint q0, uint q1, Expand *e)
|
||||
{
|
||||
int expandfile(Text* t, uint q0, uint q1, Expand* e) {
|
||||
int i, n, nname, colon, eval;
|
||||
uint amin, amax;
|
||||
Rune *r, c;
|
||||
|
@ -542,15 +542,20 @@ expandfile(Text *t, uint q0, uint q1, Expand *e)
|
|||
if (q1 == q0) {
|
||||
colon = -1;
|
||||
while (q1 < t->file->b.nc && isfilec(c = textreadc(t, q1))) {
|
||||
if(c == ':' && !texthas(t, q1-4, Lhttpcss) && !texthas(t, q1-5, Lhttpscss)){
|
||||
if (
|
||||
c == ':' && !texthas(t, q1 - 4, Lhttpcss) &&
|
||||
!texthas(t, q1 - 5, Lhttpscss)) {
|
||||
colon = q1;
|
||||
break;
|
||||
}
|
||||
q1++;
|
||||
}
|
||||
while(q0>0 && (isfilec(c=textreadc(t, q0-1)) || isaddrc(c) || isregexc(c))){
|
||||
while (q0 > 0 &&
|
||||
(isfilec(c = textreadc(t, q0 - 1)) || isaddrc(c) || isregexc(c))) {
|
||||
q0--;
|
||||
if(colon<0 && c==':' && !texthas(t, q0-4, Lhttpcss) && !texthas(t, q0-5, Lhttpscss))
|
||||
if (
|
||||
colon < 0 && c == ':' && !texthas(t, q0 - 4, Lhttpcss) &&
|
||||
!texthas(t, q0 - 5, Lhttpscss))
|
||||
colon = q0;
|
||||
}
|
||||
/*
|
||||
|
@ -602,7 +607,9 @@ expandfile(Text *t, uint q0, uint q1, Expand *e)
|
|||
for (i = 0; i < n; i++) {
|
||||
c = r[i];
|
||||
if (c == ':' && nname < 0) {
|
||||
if(q0+i+1<t->file->b.nc && (i==n-1 || isaddrc(textreadc(t, q0+i+1))))
|
||||
if (
|
||||
q0 + i + 1 < t->file->b.nc &&
|
||||
(i == n - 1 || isaddrc(textreadc(t, q0 + i + 1))))
|
||||
amin = q0 + i;
|
||||
else
|
||||
goto Isntfile;
|
||||
|
@ -612,7 +619,7 @@ expandfile(Text *t, uint q0, uint q1, Expand *e)
|
|||
if (nname == -1)
|
||||
nname = n;
|
||||
for (i = 0; i < nname; i++)
|
||||
if(!isfilec(r[i]))
|
||||
if (!isfilec(r[i]) && r[i] != ' ')
|
||||
goto Isntfile;
|
||||
/*
|
||||
* See if it's a file name in <>, and turn that into an include
|
||||
|
@ -620,12 +627,13 @@ expandfile(Text *t, uint q0, uint q1, Expand *e)
|
|||
* restrictive enough syntax and checking for a #include earlier on the
|
||||
* line would be silly.
|
||||
*/
|
||||
if(q0>0 && textreadc(t, q0-1)=='<' && q1<t->file->b.nc && textreadc(t, q1)=='>'){
|
||||
if (
|
||||
q0 > 0 && textreadc(t, q0 - 1) == '<' && q1 < t->file->b.nc &&
|
||||
textreadc(t, q1) == '>') {
|
||||
rs = includename(t, r, nname);
|
||||
r = rs.r;
|
||||
nname = rs.nr;
|
||||
}
|
||||
else if(amin == q0)
|
||||
} else if (amin == q0)
|
||||
goto Isfile;
|
||||
else {
|
||||
rs = dirname(t, r, nname);
|
||||
|
@ -650,7 +658,17 @@ expandfile(Text *t, uint q0, uint q1, Expand *e)
|
|||
e->u.at = t;
|
||||
e->a0 = amin + 1;
|
||||
eval = FALSE;
|
||||
address(TRUE, nil, range(-1,-1), range(0,0), t, e->a0, amax, tgetc, &eval, (uint*)&e->a1);
|
||||
address(
|
||||
TRUE,
|
||||
nil,
|
||||
range(-1, -1),
|
||||
range(0, 0),
|
||||
t,
|
||||
e->a0,
|
||||
amax,
|
||||
tgetc,
|
||||
&eval,
|
||||
(uint*)&e->a1);
|
||||
return TRUE;
|
||||
|
||||
Isntfile:
|
||||
|
@ -658,9 +676,7 @@ expandfile(Text *t, uint q0, uint q1, Expand *e)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
int
|
||||
expand(Text *t, uint q0, uint q1, Expand *e)
|
||||
{
|
||||
int expand(Text* t, uint q0, uint q1, Expand* e) {
|
||||
memset(e, 0, sizeof *e);
|
||||
e->agetc = tgetc;
|
||||
/* if in selection, choose selection */
|
||||
|
@ -686,9 +702,7 @@ expand(Text *t, uint q0, uint q1, Expand *e)
|
|||
return q1 > q0;
|
||||
}
|
||||
|
||||
Window*
|
||||
lookfile(Rune *s, int n)
|
||||
{
|
||||
Window* lookfile(Rune* s, int n) {
|
||||
int i, j, k;
|
||||
Window* w;
|
||||
Column* c;
|
||||
|
@ -715,9 +729,7 @@ lookfile(Rune *s, int n)
|
|||
return nil;
|
||||
}
|
||||
|
||||
Window*
|
||||
lookid(int id, int dump)
|
||||
{
|
||||
Window* lookid(int id, int dump) {
|
||||
int i, j;
|
||||
Window* w;
|
||||
Column* c;
|
||||
|
@ -735,10 +747,7 @@ lookid(int id, int dump)
|
|||
return nil;
|
||||
}
|
||||
|
||||
|
||||
Window*
|
||||
openfile(Text *t, Expand *e)
|
||||
{
|
||||
Window* openfile(Text* t, Expand* e) {
|
||||
Range r;
|
||||
Window *w, *ow;
|
||||
int eval, i, n;
|
||||
|
@ -777,7 +786,8 @@ openfile(Text *t, Expand *e)
|
|||
}
|
||||
if (w) {
|
||||
t = &w->body;
|
||||
if(!t->col->safe && t->fr.maxlines==0) /* window is obscured by full-column window */
|
||||
if (!t->col->safe && t->fr.maxlines == 0) /* window is obscured by
|
||||
full-column window */
|
||||
colgrow(t->col, t->col->w[0], 1);
|
||||
} else {
|
||||
ow = nil;
|
||||
|
@ -810,7 +820,17 @@ openfile(Text *t, Expand *e)
|
|||
eval = FALSE;
|
||||
else {
|
||||
eval = TRUE;
|
||||
r = address(TRUE, t, range(-1,-1), range(t->q0, t->q1), e->u.at, e->a0, e->a1, e->agetc, &eval, &dummy);
|
||||
r = address(
|
||||
TRUE,
|
||||
t,
|
||||
range(-1, -1),
|
||||
range(t->q0, t->q1),
|
||||
e->u.at,
|
||||
e->a0,
|
||||
e->a1,
|
||||
e->agetc,
|
||||
&eval,
|
||||
&dummy);
|
||||
if (r.q0 > r.q1) {
|
||||
eval = FALSE;
|
||||
warning(nil, "addresses out of order\n");
|
||||
|
@ -826,13 +846,14 @@ openfile(Text *t, Expand *e)
|
|||
winsettag(t->w);
|
||||
seltext = t;
|
||||
if (e->jump)
|
||||
moveto(mousectl, addpt(frptofchar(&t->fr, t->fr.p0), Pt(4, font->height-4)));
|
||||
moveto(
|
||||
mousectl,
|
||||
addpt(frptofchar(&t->fr, t->fr.p0), Pt(4, font->height - 4)));
|
||||
return w;
|
||||
}
|
||||
|
||||
void
|
||||
new(Text *et, Text *t, Text *argt, int flag1, int flag2, Rune *arg, int narg)
|
||||
{
|
||||
void new (
|
||||
Text* et, Text* t, Text* argt, int flag1, int flag2, Rune* arg, int narg) {
|
||||
int ndone;
|
||||
Rune *a, *f;
|
||||
int na, nf;
|
||||
|
|
|
@ -7,9 +7,7 @@
|
|||
#include <9pclient.h>
|
||||
#include "dat.h"
|
||||
|
||||
char*
|
||||
formathtml(char *body, int *np)
|
||||
{
|
||||
char* formathtml(char* body, int* np) {
|
||||
int i, j, p[2], q[2];
|
||||
Exec* e;
|
||||
char buf[1024];
|
||||
|
@ -63,9 +61,7 @@ formathtml(char *body, int *np)
|
|||
return body;
|
||||
}
|
||||
|
||||
char*
|
||||
readbody(char *type, char *dir, int *np)
|
||||
{
|
||||
char* readbody(char* type, char* dir, int* np) {
|
||||
char* body;
|
||||
|
||||
body = readfile(dir, "body", np);
|
||||
|
|
BIN
mail/html.o
BIN
mail/html.o
Binary file not shown.
88
mail/mail.c
88
mail/mail.c
|
@ -40,16 +40,15 @@ int shortmenu;
|
|||
CFsys* mailfs;
|
||||
CFsys* acmefs;
|
||||
|
||||
void
|
||||
usage(void)
|
||||
{
|
||||
fprint(2, "usage: Mail [-sS] [-n srvname] [-o outgoing] [mailboxname [directoryname]]\n");
|
||||
void usage(void) {
|
||||
fprint(
|
||||
2,
|
||||
"usage: Mail [-sS] [-n srvname] [-o outgoing] [mailboxname "
|
||||
"[directoryname]]\n");
|
||||
threadexitsall("usage");
|
||||
}
|
||||
|
||||
void
|
||||
removeupasfs(void)
|
||||
{
|
||||
void removeupasfs(void) {
|
||||
char buf[256];
|
||||
|
||||
if (strcmp(mboxname, "mbox") == 0)
|
||||
|
@ -58,9 +57,7 @@ removeupasfs(void)
|
|||
fswrite(mbox.ctlfd, buf, strlen(buf));
|
||||
}
|
||||
|
||||
int
|
||||
ismaildir(char *s)
|
||||
{
|
||||
int ismaildir(char* s) {
|
||||
Dir* d;
|
||||
int ret;
|
||||
|
||||
|
@ -72,9 +69,7 @@ ismaildir(char *s)
|
|||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
threadmain(int argc, char *argv[])
|
||||
{
|
||||
void threadmain(int argc, char* argv[]) {
|
||||
char *s, *name;
|
||||
char err[ERRMAX], *cmd;
|
||||
int i, newdir;
|
||||
|
@ -83,7 +78,8 @@ threadmain(int argc, char *argv[])
|
|||
doquote = needsrcquote;
|
||||
quotefmtinstall();
|
||||
|
||||
/* open these early so we won't miss notification of new mail messages while we read mbox */
|
||||
/* open these early so we won't miss notification of new mail messages while
|
||||
* we read mbox */
|
||||
if ((plumbsendfd = plumbopenfid("send", OWRITE | OCEXEC)) == nil)
|
||||
fprint(2, "warning: open plumb/send: %r\n");
|
||||
if ((plumbseemailfd = plumbopenfid("seemail", OREAD | OCEXEC)) == nil)
|
||||
|
@ -111,7 +107,8 @@ threadmain(int argc, char *argv[])
|
|||
break;
|
||||
default:
|
||||
usage();
|
||||
}ARGEND
|
||||
}
|
||||
ARGEND
|
||||
|
||||
acmefs = nsmount("acme", nil);
|
||||
if (acmefs == nil)
|
||||
|
@ -171,7 +168,8 @@ threadmain(int argc, char *argv[])
|
|||
|
||||
fsname = estrdup(name);
|
||||
if (newdir && argc > 0) {
|
||||
s = emalloc(5+strlen(mailboxdir)+strlen(mboxname)+strlen(name)+10+1);
|
||||
s = emalloc(
|
||||
5 + strlen(mailboxdir) + strlen(mboxname) + strlen(name) + 10 + 1);
|
||||
for (i = 0; i < 10; i++) {
|
||||
sprint(s, "open %s/%s %s", mailboxdir, mboxname, fsname);
|
||||
if (fswrite(mbox.ctlfd, s, strlen(s)) >= 0)
|
||||
|
@ -241,9 +239,7 @@ threadmain(int argc, char *argv[])
|
|||
plumbthread();
|
||||
}
|
||||
|
||||
void
|
||||
plumbproc(void* v)
|
||||
{
|
||||
void plumbproc(void* v) {
|
||||
Plumbmsg* m;
|
||||
|
||||
threadsetname("plumbproc");
|
||||
|
@ -255,9 +251,7 @@ plumbproc(void* v)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
plumbshowproc(void* v)
|
||||
{
|
||||
void plumbshowproc(void* v) {
|
||||
Plumbmsg* m;
|
||||
|
||||
threadsetname("plumbshowproc");
|
||||
|
@ -269,9 +263,7 @@ plumbshowproc(void* v)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
plumbsendproc(void* v)
|
||||
{
|
||||
void plumbsendproc(void* v) {
|
||||
Plumbmsg* m;
|
||||
|
||||
threadsetname("plumbsendproc");
|
||||
|
@ -283,9 +275,7 @@ plumbsendproc(void* v)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
newmesg(char *name, char *digest)
|
||||
{
|
||||
void newmesg(char* name, char* digest) {
|
||||
Dir* d;
|
||||
|
||||
if (strncmp(name, mbox.name, strlen(mbox.name)) != 0)
|
||||
|
@ -302,9 +292,7 @@ newmesg(char *name, char *digest)
|
|||
free(d);
|
||||
}
|
||||
|
||||
void
|
||||
showmesg(char *name, char *digest)
|
||||
{
|
||||
void showmesg(char* name, char* digest) {
|
||||
char* n;
|
||||
char* mb;
|
||||
|
||||
|
@ -318,9 +306,7 @@ showmesg(char *name, char *digest)
|
|||
free(n);
|
||||
}
|
||||
|
||||
void
|
||||
delmesg(char *name, char *digest, int dodel, char *save)
|
||||
{
|
||||
void delmesg(char* name, char* digest, int dodel, char* save) {
|
||||
Message* m;
|
||||
|
||||
m = mesglookupfile(&mbox, name, digest);
|
||||
|
@ -338,9 +324,7 @@ delmesg(char *name, char *digest, int dodel, char *save)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
plumbthread(void)
|
||||
{
|
||||
void plumbthread(void) {
|
||||
Plumbmsg* m;
|
||||
Plumbattr* a;
|
||||
char *type, *digest;
|
||||
|
@ -363,9 +347,7 @@ plumbthread(void)
|
|||
threadexits(nil);
|
||||
}
|
||||
|
||||
void
|
||||
plumbshowthread(void *v)
|
||||
{
|
||||
void plumbshowthread(void* v) {
|
||||
Plumbmsg* m;
|
||||
|
||||
USED(v);
|
||||
|
@ -377,9 +359,7 @@ plumbshowthread(void *v)
|
|||
threadexits(nil);
|
||||
}
|
||||
|
||||
void
|
||||
plumbsendthread(void *v)
|
||||
{
|
||||
void plumbsendthread(void* v) {
|
||||
Plumbmsg* m;
|
||||
|
||||
USED(v);
|
||||
|
@ -391,9 +371,7 @@ plumbsendthread(void *v)
|
|||
threadexits(nil);
|
||||
}
|
||||
|
||||
int
|
||||
mboxcommand(Window *w, char *s)
|
||||
{
|
||||
int mboxcommand(Window* w, char* s) {
|
||||
char *args[10], **targs, *save;
|
||||
Window* sbox;
|
||||
Message *m, *next;
|
||||
|
@ -466,7 +444,8 @@ mboxcommand(Window *w, char *s)
|
|||
for (i = 0; s[i]; i++)
|
||||
if (s[i] == '\n')
|
||||
nargs++;
|
||||
targs = emalloc(nargs*sizeof(char*)); /* could be too many for a local array */
|
||||
targs =
|
||||
emalloc(nargs * sizeof(char*)); /* could be too many for a local array */
|
||||
nargs = getfields(s, targs, nargs, 1, "\n");
|
||||
for (i = 0; i < nargs; i++) {
|
||||
if (!isdigit(targs[i][0]))
|
||||
|
@ -517,14 +496,16 @@ mboxcommand(Window *w, char *s)
|
|||
/* show results in reverse order */
|
||||
m = mbox.tail;
|
||||
save = nil;
|
||||
for(s=strrchr(res, ' '); s!=nil || save!=res; s=strrchr(res, ' ')){
|
||||
for (s = strrchr(res, ' '); s != nil || save != res;
|
||||
s = strrchr(res, ' ')) {
|
||||
if (s != nil) {
|
||||
save = s + 1;
|
||||
*s = '\0';
|
||||
}
|
||||
else save = res;
|
||||
} else
|
||||
save = res;
|
||||
save = estrstrdup(save, "/");
|
||||
for(; m && strcmp(save, m->name) != 0; m=m->prev);
|
||||
for (; m && strcmp(save, m->name) != 0; m = m->prev)
|
||||
;
|
||||
free(save);
|
||||
if (m == nil)
|
||||
break;
|
||||
|
@ -539,9 +520,7 @@ mboxcommand(Window *w, char *s)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
mainctl(void *v)
|
||||
{
|
||||
void mainctl(void* v) {
|
||||
Window* w;
|
||||
Event *e, *e2, *eq, *ea;
|
||||
int na, nopen;
|
||||
|
@ -641,4 +620,3 @@ mainctl(void *v)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
BIN
mail/mail.o
BIN
mail/mail.o
Binary file not shown.
312
mail/mesg.c
312
mail/mesg.c
|
@ -7,10 +7,7 @@
|
|||
#include <plumb.h>
|
||||
#include "dat.h"
|
||||
|
||||
enum
|
||||
{
|
||||
DIRCHUNK = 32*sizeof(Dir)
|
||||
};
|
||||
enum { DIRCHUNK = 32 * sizeof(Dir) };
|
||||
|
||||
char regexchars[] = "\\/[].+?()*^$";
|
||||
char deleted[] = "(deleted)-";
|
||||
|
@ -23,17 +20,35 @@ struct{
|
|||
char* port;
|
||||
char* suffix;
|
||||
} ports[] = {
|
||||
"text/", "edit", ".txt", /* must be first for plumbport() */
|
||||
"image/gif", "image", ".gif",
|
||||
"image/jpeg", "image", ".jpg",
|
||||
"image/jpeg", "image", ".jpeg",
|
||||
"image/png", "image", ".png",
|
||||
"application/postscript", "postscript", ".ps",
|
||||
"application/pdf", "postscript", ".pdf",
|
||||
"application/msword", "msword", ".doc",
|
||||
"application/rtf", "msword", ".rtf",
|
||||
nil, nil
|
||||
};
|
||||
"text/",
|
||||
"edit",
|
||||
".txt", /* must be first for plumbport() */
|
||||
"image/gif",
|
||||
"image",
|
||||
".gif",
|
||||
"image/jpeg",
|
||||
"image",
|
||||
".jpg",
|
||||
"image/jpeg",
|
||||
"image",
|
||||
".jpeg",
|
||||
"image/png",
|
||||
"image",
|
||||
".png",
|
||||
"application/postscript",
|
||||
"postscript",
|
||||
".ps",
|
||||
"application/pdf",
|
||||
"postscript",
|
||||
".pdf",
|
||||
"application/msword",
|
||||
"msword",
|
||||
".doc",
|
||||
"application/rtf",
|
||||
"msword",
|
||||
".rtf",
|
||||
nil,
|
||||
nil};
|
||||
|
||||
char* goodtypes[] = {
|
||||
"text",
|
||||
|
@ -42,30 +57,13 @@ char *goodtypes[] = {
|
|||
"text/richtext",
|
||||
"text/tab-separated-values",
|
||||
"application/octet-stream",
|
||||
nil
|
||||
};
|
||||
nil};
|
||||
|
||||
char *okheaders[] =
|
||||
{
|
||||
"From:",
|
||||
"Date:",
|
||||
"To:",
|
||||
"CC:",
|
||||
"Subject:",
|
||||
nil
|
||||
};
|
||||
char* okheaders[] = {"From:", "Date:", "To:", "CC:", "Subject:", nil};
|
||||
|
||||
char *extraheaders[] =
|
||||
{
|
||||
"Resent-From:",
|
||||
"Resent-To:",
|
||||
"Sort:",
|
||||
nil
|
||||
};
|
||||
char* extraheaders[] = {"Resent-From:", "Resent-To:", "Sort:", nil};
|
||||
|
||||
char*
|
||||
line(char *data, char **pp)
|
||||
{
|
||||
char* line(char* data, char** pp) {
|
||||
char *p, *q;
|
||||
|
||||
for (p = data; *p != '\0' && *p != '\n'; p++)
|
||||
|
@ -79,9 +77,7 @@ line(char *data, char **pp)
|
|||
return q;
|
||||
}
|
||||
|
||||
static char*
|
||||
mkaddrs(char *t, char **colon)
|
||||
{
|
||||
static char* mkaddrs(char* t, char** colon) {
|
||||
int i, nf, inquote;
|
||||
char **f, *s;
|
||||
Fmt fmt;
|
||||
|
@ -118,9 +114,7 @@ mkaddrs(char *t, char **colon)
|
|||
return fmtstrflush(&fmt);
|
||||
}
|
||||
|
||||
int
|
||||
loadinfo(Message *m, char *dir)
|
||||
{
|
||||
int loadinfo(Message* m, char* dir) {
|
||||
int n;
|
||||
char *data, *p, *s, *t;
|
||||
|
||||
|
@ -198,9 +192,7 @@ loadinfo(Message *m, char *dir)
|
|||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
isnumeric(char *s)
|
||||
{
|
||||
int isnumeric(char* s) {
|
||||
while (*s) {
|
||||
if (!isdigit(*s))
|
||||
return 0;
|
||||
|
@ -209,17 +201,13 @@ isnumeric(char *s)
|
|||
return 1;
|
||||
}
|
||||
|
||||
CFid*
|
||||
mailopen(char *name, int mode)
|
||||
{
|
||||
CFid* mailopen(char* name, int mode) {
|
||||
if (strncmp(name, "Mail/", 5) != 0)
|
||||
return nil;
|
||||
return fsopen(mailfs, name + 5, mode);
|
||||
}
|
||||
|
||||
Dir*
|
||||
loaddir(char *name, int *np)
|
||||
{
|
||||
Dir* loaddir(char* name, int* np) {
|
||||
CFid* fid;
|
||||
Dir* dp;
|
||||
|
||||
|
@ -231,9 +219,7 @@ loaddir(char *name, int *np)
|
|||
return dp;
|
||||
}
|
||||
|
||||
void
|
||||
readmbox(Message *mbox, char *dir, char *subdir)
|
||||
{
|
||||
void readmbox(Message* mbox, char* dir, char* subdir) {
|
||||
char* name;
|
||||
Dir *d, *dirp;
|
||||
int i, n;
|
||||
|
@ -252,9 +238,7 @@ readmbox(Message *mbox, char *dir, char *subdir)
|
|||
}
|
||||
|
||||
/* add message to box, in increasing numerical order */
|
||||
int
|
||||
mesgadd(Message *mbox, char *dir, Dir *d, char *digest)
|
||||
{
|
||||
int mesgadd(Message* mbox, char* dir, Dir* d, char* digest) {
|
||||
Message* m;
|
||||
char* name;
|
||||
int loaded;
|
||||
|
@ -268,8 +252,11 @@ mesgadd(Message *mbox, char *dir, Dir *d, char *digest)
|
|||
name = estrstrdup(dir, m->name);
|
||||
loaded = loadinfo(m, name);
|
||||
free(name);
|
||||
/* if two upas/fs are running, we can get misled, so check digest before accepting message */
|
||||
if(loaded==0 || (digest!=nil && m->digest!=nil && strcmp(digest, m->digest)!=0)){
|
||||
/* if two upas/fs are running, we can get misled, so check digest before
|
||||
* accepting message */
|
||||
if (
|
||||
loaded == 0 ||
|
||||
(digest != nil && m->digest != nil && strcmp(digest, m->digest) != 0)) {
|
||||
mesgfreeparts(m);
|
||||
free(m);
|
||||
return 0;
|
||||
|
@ -287,9 +274,7 @@ mesgadd(Message *mbox, char *dir, Dir *d, char *digest)
|
|||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
thisyear(char *year)
|
||||
{
|
||||
int thisyear(char* year) {
|
||||
static char now[10];
|
||||
char* s;
|
||||
|
||||
|
@ -300,9 +285,7 @@ thisyear(char *year)
|
|||
return strncmp(year, now, 4) == 0;
|
||||
}
|
||||
|
||||
char*
|
||||
stripdate(char *as)
|
||||
{
|
||||
char* stripdate(char* as) {
|
||||
int n;
|
||||
char *s, *fld[10];
|
||||
|
||||
|
@ -329,9 +312,7 @@ stripdate(char *as)
|
|||
return as;
|
||||
}
|
||||
|
||||
char*
|
||||
readfile(char *dir, char *name, int *np)
|
||||
{
|
||||
char* readfile(char* dir, char* name, int* np) {
|
||||
char *file, *data;
|
||||
int len;
|
||||
Dir* d;
|
||||
|
@ -370,9 +351,7 @@ readfile(char *dir, char *name, int *np)
|
|||
return data;
|
||||
}
|
||||
|
||||
char*
|
||||
info(Message *m, int ind, int ogf)
|
||||
{
|
||||
char* info(Message* m, int ind, int ogf) {
|
||||
char* i;
|
||||
int j, len, lens;
|
||||
char* p;
|
||||
|
@ -406,7 +385,8 @@ info(Message *m, int ind, int ogf)
|
|||
i = eappend(i, "\t", p);
|
||||
i = egrow(i, "\t", stripdate(m->date));
|
||||
if (ind == 0) {
|
||||
if(strcmp(m->type, "text")!=0 && strncmp(m->type, "text/", 5)!=0 &&
|
||||
if (
|
||||
strcmp(m->type, "text") != 0 && strncmp(m->type, "text/", 5) != 0 &&
|
||||
strncmp(m->type, "multipart/", 10) != 0)
|
||||
i = egrow(i, "\t(", estrstrdup(m->type, ")"));
|
||||
} else if (strncmp(m->type, "multipart/", 10) != 0)
|
||||
|
@ -420,9 +400,9 @@ info(Message *m, int ind, int ogf)
|
|||
return i;
|
||||
}
|
||||
|
||||
void
|
||||
mesgmenu0(Window *w, Message *mbox, char *realdir, char *dir, int ind, CFid *fd, int onlyone, int dotail)
|
||||
{
|
||||
void mesgmenu0(
|
||||
Window* w, Message* mbox, char* realdir, char* dir, int ind, CFid* fd,
|
||||
int onlyone, int dotail) {
|
||||
int i;
|
||||
Message* m;
|
||||
char *name, *tmp;
|
||||
|
@ -457,18 +437,14 @@ mesgmenu0(Window *w, Message *mbox, char *realdir, char *dir, int ind, CFid *fd,
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
mesgmenu(Window *w, Message *mbox)
|
||||
{
|
||||
void mesgmenu(Window* w, Message* mbox) {
|
||||
winopenbody(w, OWRITE);
|
||||
mesgmenu0(w, mbox, mbox->name, "", 0, w->body, 0, !shortmenu);
|
||||
winclosebody(w);
|
||||
}
|
||||
|
||||
/* one new message has arrived, as mbox->tail */
|
||||
void
|
||||
mesgmenunew(Window *w, Message *mbox)
|
||||
{
|
||||
void mesgmenunew(Window* w, Message* mbox) {
|
||||
Biobuf* b;
|
||||
|
||||
winselect(w, "0", 0);
|
||||
|
@ -478,7 +454,8 @@ mesgmenunew(Window *w, Message *mbox)
|
|||
free(b);
|
||||
if (!mbox->dirty)
|
||||
winclean(w);
|
||||
/* select tag line plus following indented lines, but not final newline (it's distinctive) */
|
||||
/* select tag line plus following indented lines, but not final newline (it's
|
||||
* distinctive) */
|
||||
winselect(w, "0/.*\\n((\t.*\\n)*\t.*)?/", 1);
|
||||
fsclose(w->addr);
|
||||
fsclose(w->data);
|
||||
|
@ -486,12 +463,11 @@ mesgmenunew(Window *w, Message *mbox)
|
|||
w->data = nil;
|
||||
}
|
||||
|
||||
char*
|
||||
name2regexp(char *prefix, char *s)
|
||||
{
|
||||
char* name2regexp(char* prefix, char* s) {
|
||||
char *buf, *p, *q;
|
||||
|
||||
buf = emalloc(strlen(prefix)+2*strlen(s)+50); /* leave room to append more */
|
||||
buf = emalloc(
|
||||
strlen(prefix) + 2 * strlen(s) + 50); /* leave room to append more */
|
||||
p = buf;
|
||||
*p++ = '0';
|
||||
*p++ = '/';
|
||||
|
@ -508,12 +484,9 @@ name2regexp(char *prefix, char *s)
|
|||
return buf;
|
||||
}
|
||||
|
||||
void
|
||||
mesgmenumarkdel(Window *w, Message *mbox, Message *m, int writeback)
|
||||
{
|
||||
void mesgmenumarkdel(Window* w, Message* mbox, Message* m, int writeback) {
|
||||
char* buf;
|
||||
|
||||
|
||||
if (m->deleted)
|
||||
return;
|
||||
m->writebackdel = writeback;
|
||||
|
@ -532,9 +505,7 @@ mesgmenumarkdel(Window *w, Message *mbox, Message *m, int writeback)
|
|||
m->deleted = 1;
|
||||
}
|
||||
|
||||
void
|
||||
mesgmenumarkundel(Window *w, Message *v, Message *m)
|
||||
{
|
||||
void mesgmenumarkundel(Window* w, Message* v, Message* m) {
|
||||
char* buf;
|
||||
|
||||
USED(v);
|
||||
|
@ -554,9 +525,7 @@ mesgmenumarkundel(Window *w, Message *v, Message *m)
|
|||
m->deleted = 0;
|
||||
}
|
||||
|
||||
void
|
||||
mesgmenudel(Window *w, Message *mbox, Message *m)
|
||||
{
|
||||
void mesgmenudel(Window* w, Message* mbox, Message* m) {
|
||||
char* buf;
|
||||
|
||||
if (w->data == nil)
|
||||
|
@ -573,15 +542,14 @@ mesgmenudel(Window *w, Message *mbox, Message *m)
|
|||
m->deleted = 1;
|
||||
}
|
||||
|
||||
void
|
||||
mesgmenumark(Window *w, char *which, char *mark)
|
||||
{
|
||||
void mesgmenumark(Window* w, char* which, char* mark) {
|
||||
char* buf;
|
||||
|
||||
if (w->data == nil)
|
||||
w->data = winopenfile(w, "data");
|
||||
buf = name2regexp(deletedrx01, which);
|
||||
if(winsetaddr(w, buf, 1) && winsetaddr(w, "+0-#1", 1)) /* go to end of line */
|
||||
if (winsetaddr(w, buf, 1) && winsetaddr(w, "+0-#1", 1)) /* go to end of line
|
||||
*/
|
||||
fswrite(w->data, mark, strlen(mark));
|
||||
free(buf);
|
||||
fsclose(w->data);
|
||||
|
@ -592,9 +560,7 @@ mesgmenumark(Window *w, char *which, char *mark)
|
|||
winclean(w);
|
||||
}
|
||||
|
||||
void
|
||||
mesgfreeparts(Message *m)
|
||||
{
|
||||
void mesgfreeparts(Message* m) {
|
||||
free(m->name);
|
||||
free(m->replyname);
|
||||
free(m->from);
|
||||
|
@ -609,9 +575,7 @@ mesgfreeparts(Message *m)
|
|||
free(m->digest);
|
||||
}
|
||||
|
||||
void
|
||||
mesgdel(Message *mbox, Message *m)
|
||||
{
|
||||
void mesgdel(Message* mbox, Message* m) {
|
||||
Message *n, *next;
|
||||
|
||||
if (m->opened)
|
||||
|
@ -634,9 +598,7 @@ mesgdel(Message *mbox, Message *m)
|
|||
mesgfreeparts(m);
|
||||
}
|
||||
|
||||
int
|
||||
mesgsave(Message *m, char *s, int save)
|
||||
{
|
||||
int mesgsave(Message* m, char* s, int save) {
|
||||
int ofd, n, k, ret;
|
||||
char *t, *raw, *unixheader, *all;
|
||||
|
||||
|
@ -683,9 +645,7 @@ mesgsave(Message *m, char *s, int save)
|
|||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
mesgcommand(Message *m, char *cmd)
|
||||
{
|
||||
int mesgcommand(Message* m, char* cmd) {
|
||||
char* s;
|
||||
char* args[10];
|
||||
int save, ok, ret, nargs;
|
||||
|
@ -729,7 +689,9 @@ mesgcommand(Message *m, char *cmd)
|
|||
}
|
||||
if (strcmp(args[0], "Q") == 0) {
|
||||
s = winselection(m->w); /* will be freed by mkreply */
|
||||
if(nargs>=3 && strcmp(args[1], "Reply")==0 && strcmp(args[2], "all")==0)
|
||||
if (
|
||||
nargs >= 3 && strcmp(args[1], "Reply") == 0 &&
|
||||
strcmp(args[2], "all") == 0)
|
||||
mkreply(m, "QReplyall", nil, nil, s);
|
||||
else
|
||||
mkreply(m, "QReply", nil, nil, s);
|
||||
|
@ -776,9 +738,7 @@ mesgcommand(Message *m, char *cmd)
|
|||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
mesgtagpost(Message *m)
|
||||
{
|
||||
void mesgtagpost(Message* m) {
|
||||
if (m->tagposted)
|
||||
return;
|
||||
wintagwrite(m->w, " Post", 5);
|
||||
|
@ -788,9 +748,7 @@ mesgtagpost(Message *m)
|
|||
/* need to expand selection more than default word */
|
||||
#pragma varargck argpos eval 2
|
||||
|
||||
long
|
||||
eval(Window *w, char *s, ...)
|
||||
{
|
||||
long eval(Window* w, char* s, ...) {
|
||||
char buf[64];
|
||||
va_list arg;
|
||||
|
||||
|
@ -806,9 +764,7 @@ eval(Window *w, char *s, ...)
|
|||
return strtol(buf, 0, 10);
|
||||
}
|
||||
|
||||
int
|
||||
isemail(char *s)
|
||||
{
|
||||
int isemail(char* s) {
|
||||
int nat;
|
||||
|
||||
nat = 0;
|
||||
|
@ -821,9 +777,7 @@ isemail(char *s)
|
|||
}
|
||||
|
||||
char addrdelim[] = "/[ \t\\n<>()\\[\\]]/";
|
||||
char*
|
||||
expandaddr(Window *w, Event *e)
|
||||
{
|
||||
char* expandaddr(Window* w, Event* e) {
|
||||
char* s;
|
||||
long q0, q1;
|
||||
|
||||
|
@ -849,9 +803,7 @@ expandaddr(Window *w, Event *e)
|
|||
return s;
|
||||
}
|
||||
|
||||
int
|
||||
replytoaddr(Window *w, Message *m, Event *e, char *s)
|
||||
{
|
||||
int replytoaddr(Window* w, Message* m, Event* e, char* s) {
|
||||
int did;
|
||||
char* buf;
|
||||
Plumbmsg* pm;
|
||||
|
@ -875,7 +827,9 @@ replytoaddr(Window *w, Message *m, Event *e, char *s)
|
|||
if (m->subject && m->subject[0]) {
|
||||
pm->attr = emalloc(sizeof(Plumbattr));
|
||||
pm->attr->name = estrdup("Subject");
|
||||
if(tolower(m->subject[0]) != 'r' || tolower(m->subject[1]) != 'e' || m->subject[2] != ':')
|
||||
if (
|
||||
tolower(m->subject[0]) != 'r' || tolower(m->subject[1]) != 'e' ||
|
||||
m->subject[2] != ':')
|
||||
pm->attr->value = estrstrdup("Re: ", m->subject);
|
||||
else
|
||||
pm->attr->value = estrdup(m->subject);
|
||||
|
@ -889,10 +843,7 @@ replytoaddr(Window *w, Message *m, Event *e, char *s)
|
|||
return did;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
mesgctl(void *v)
|
||||
{
|
||||
void mesgctl(void* v) {
|
||||
Message* m;
|
||||
Window* w;
|
||||
Event *e, *eq, *e2, *ea;
|
||||
|
@ -974,7 +925,9 @@ mesgctl(void *v)
|
|||
/* strip any known extensions */
|
||||
for (i = 0; ports[i].suffix != nil; i++) {
|
||||
j = strlen(ports[i].suffix);
|
||||
if(strlen(s)>j && strcmp(s+strlen(s)-j, ports[i].suffix)==0){
|
||||
if (
|
||||
strlen(s) > j &&
|
||||
strcmp(s + strlen(s) - j, ports[i].suffix) == 0) {
|
||||
s[strlen(s) - j] = '\0';
|
||||
break;
|
||||
}
|
||||
|
@ -1008,16 +961,12 @@ mesgctl(void *v)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
mesgline(Message *m, char *header, char *value)
|
||||
{
|
||||
void mesgline(Message* m, char* header, char* value) {
|
||||
if (strlen(value) > 0)
|
||||
fsprint(m->w->body, "%s: %s\n", header, value);
|
||||
}
|
||||
|
||||
int
|
||||
isprintable(char *type)
|
||||
{
|
||||
int isprintable(char* type) {
|
||||
int i;
|
||||
|
||||
for (i = 0; goodtypes[i] != nil; i++)
|
||||
|
@ -1026,9 +975,7 @@ isprintable(char *type)
|
|||
return 0;
|
||||
}
|
||||
|
||||
char*
|
||||
ext(char *type)
|
||||
{
|
||||
char* ext(char* type) {
|
||||
int i;
|
||||
|
||||
for (i = 0; ports[i].type != nil; i++)
|
||||
|
@ -1037,27 +984,31 @@ ext(char *type)
|
|||
return "";
|
||||
}
|
||||
|
||||
void
|
||||
mimedisplay(Message *m, char *name, char *rootdir, Window *w, int fileonly)
|
||||
{
|
||||
void mimedisplay(
|
||||
Message* m, char* name, char* rootdir, Window* w, int fileonly) {
|
||||
char* dest;
|
||||
|
||||
if(strcmp(m->disposition, "file")==0 || strlen(m->filename)!=0 || !fileonly){
|
||||
if (
|
||||
strcmp(m->disposition, "file") == 0 || strlen(m->filename) != 0 ||
|
||||
!fileonly) {
|
||||
if (strlen(m->filename) == 0)
|
||||
dest = estrstrdup("a", ext(m->type));
|
||||
else
|
||||
dest = estrdup(m->filename);
|
||||
if (m->filename[0] != '/')
|
||||
dest = egrow(estrdup(home), "/", dest);
|
||||
fsprint(w->body, "\t9p read %s/%s/%sbody > %s\n",
|
||||
srvname, mboxname, name, dest);
|
||||
fsprint(
|
||||
w->body,
|
||||
"\t9p read %s/%s/%sbody > %s\n",
|
||||
srvname,
|
||||
mboxname,
|
||||
name,
|
||||
dest);
|
||||
free(dest);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
printheader(char *dir, CFid *fid, char **okheaders)
|
||||
{
|
||||
void printheader(char* dir, CFid* fid, char** okheaders) {
|
||||
char* s;
|
||||
char* lines[100];
|
||||
int i, j, n;
|
||||
|
@ -1073,16 +1024,15 @@ printheader(char *dir, CFid *fid, char **okheaders)
|
|||
free(s);
|
||||
}
|
||||
|
||||
void
|
||||
mesgload(Message *m, char *rootdir, char *file, Window *w)
|
||||
{
|
||||
void mesgload(Message* m, char* rootdir, char* file, Window* w) {
|
||||
char *s, *subdir, *name, *dir;
|
||||
Message *mp, *thisone;
|
||||
int n;
|
||||
|
||||
dir = estrstrdup(rootdir, file);
|
||||
|
||||
if(strcmp(m->type, "message/rfc822") != 0){ /* suppress headers of envelopes */
|
||||
if (strcmp(m->type, "message/rfc822") != 0) { /* suppress headers of envelopes
|
||||
*/
|
||||
if (strlen(m->from) > 0) {
|
||||
fsprint(w->body, "From: %s\n", m->from);
|
||||
mesgline(m, "Date", m->date);
|
||||
|
@ -1127,7 +1077,12 @@ mesgload(Message *m, char *rootdir, char *file, Window *w)
|
|||
name = estrstrdup(file, mp->name);
|
||||
/* skip first element in name because it's already in window name */
|
||||
if (mp != m->head)
|
||||
fsprint(w->body, "\n===> %s (%s) [%s]\n", strchr(name, '/')+1, mp->type, mp->disposition);
|
||||
fsprint(
|
||||
w->body,
|
||||
"\n===> %s (%s) [%s]\n",
|
||||
strchr(name, '/') + 1,
|
||||
mp->type,
|
||||
mp->disposition);
|
||||
if (strcmp(mp->type, "text") == 0 || strncmp(mp->type, "text/", 5) == 0) {
|
||||
mimedisplay(mp, name, rootdir, w, 1);
|
||||
printheader(subdir, w->body, okheaders);
|
||||
|
@ -1137,7 +1092,9 @@ mesgload(Message *m, char *rootdir, char *file, Window *w)
|
|||
winwritebody(w, s, n);
|
||||
free(s);
|
||||
} else {
|
||||
if(strncmp(mp->type, "multipart/", 10)==0 || strcmp(mp->type, "message/rfc822")==0){
|
||||
if (
|
||||
strncmp(mp->type, "multipart/", 10) == 0 ||
|
||||
strcmp(mp->type, "message/rfc822") == 0) {
|
||||
mp->w = w;
|
||||
mesgload(mp, rootdir, name, w);
|
||||
mp->w = nil;
|
||||
|
@ -1151,9 +1108,7 @@ mesgload(Message *m, char *rootdir, char *file, Window *w)
|
|||
free(dir);
|
||||
}
|
||||
|
||||
int
|
||||
tokenizec(char *str, char **args, int max, char *splitc)
|
||||
{
|
||||
int tokenizec(char* str, char** args, int max, char* splitc) {
|
||||
int i, na;
|
||||
int intok = 0;
|
||||
char* p;
|
||||
|
@ -1161,7 +1116,8 @@ tokenizec(char *str, char **args, int max, char *splitc)
|
|||
if (max <= 0)
|
||||
return 0;
|
||||
|
||||
/* if(strchr(str, ',') || strchr(str, '"') || strchr(str, '<') || strchr(str, '(')) */
|
||||
/* if(strchr(str, ',') || strchr(str, '"') || strchr(str, '<') || strchr(str,
|
||||
* '(')) */
|
||||
/* splitc = ","; */
|
||||
for (na = 0; *str != '\0'; str++) {
|
||||
if (strchr(splitc, *str) == nil) {
|
||||
|
@ -1189,9 +1145,7 @@ tokenizec(char *str, char **args, int max, char *splitc)
|
|||
return na;
|
||||
}
|
||||
|
||||
Message*
|
||||
mesglookup(Message *mbox, char *name, char *digest)
|
||||
{
|
||||
Message* mesglookup(Message* mbox, char* name, char* digest) {
|
||||
int n;
|
||||
Message* m;
|
||||
char* t;
|
||||
|
@ -1221,9 +1175,7 @@ mesglookup(Message *mbox, char *name, char *digest)
|
|||
/*
|
||||
* Find plumb port, knowing type is text, given file name (by extension)
|
||||
*/
|
||||
int
|
||||
plumbportbysuffix(char *file)
|
||||
{
|
||||
int plumbportbysuffix(char* file) {
|
||||
char* suf;
|
||||
int i, nsuf, nfile;
|
||||
|
||||
|
@ -1241,9 +1193,7 @@ plumbportbysuffix(char *file)
|
|||
/*
|
||||
* Find plumb port using type and file name (by extension)
|
||||
*/
|
||||
int
|
||||
plumbport(char *type, char *file)
|
||||
{
|
||||
int plumbport(char* type, char* file) {
|
||||
int i;
|
||||
|
||||
for (i = 0; ports[i].type != nil; i++)
|
||||
|
@ -1256,9 +1206,7 @@ plumbport(char *type, char *file)
|
|||
return -1;
|
||||
}
|
||||
|
||||
void
|
||||
plumb(Message *m, char *dir)
|
||||
{
|
||||
void plumb(Message* m, char* dir) {
|
||||
int i;
|
||||
char* port;
|
||||
Plumbmsg* pm;
|
||||
|
@ -1287,9 +1235,8 @@ plumb(Message *m, char *dir)
|
|||
}
|
||||
}
|
||||
|
||||
int
|
||||
mesgopen(Message *mbox, char *dir, char *s, Message *mesg, int plumbed, char *digest)
|
||||
{
|
||||
int mesgopen(
|
||||
Message* mbox, char* dir, char* s, Message* mesg, int plumbed, char* digest) {
|
||||
char *t, *u, *v;
|
||||
Message* m;
|
||||
char* direlem[10];
|
||||
|
@ -1315,7 +1262,8 @@ mesgopen(Message *mbox, char *dir, char *s, Message *mesg, int plumbed, char *di
|
|||
m = mesglookup(mbox, direlem[0], digest);
|
||||
if (m == nil)
|
||||
goto Error;
|
||||
if(mesg!=nil && m!=mesg) /* string looked like subpart but isn't part of this message */
|
||||
if (mesg != nil && m != mesg) /* string looked like subpart but isn't part of
|
||||
this message */
|
||||
goto Error;
|
||||
if (m->opened == 0) {
|
||||
if (m->w == nil) {
|
||||
|
@ -1371,9 +1319,7 @@ mesgopen(Message *mbox, char *dir, char *s, Message *mesg, int plumbed, char *di
|
|||
return 1;
|
||||
}
|
||||
|
||||
void
|
||||
rewritembox(Window *w, Message *mbox)
|
||||
{
|
||||
void rewritembox(Window* w, Message* mbox) {
|
||||
Message *m, *next;
|
||||
char *deletestr, *t;
|
||||
int nopen;
|
||||
|
@ -1409,9 +1355,7 @@ rewritembox(Window *w, Message *mbox)
|
|||
}
|
||||
|
||||
/* name is a full file name, but it might not belong to us */
|
||||
Message*
|
||||
mesglookupfile(Message *mbox, char *name, char *digest)
|
||||
{
|
||||
Message* mesglookupfile(Message* mbox, char* name, char* digest) {
|
||||
int k, n;
|
||||
|
||||
k = strlen(name);
|
||||
|
|
BIN
mail/mesg.o
BIN
mail/mesg.o
Binary file not shown.
BIN
mail/o.Mail
BIN
mail/o.Mail
Binary file not shown.
86
mail/reply.c
86
mail/reply.c
|
@ -9,9 +9,7 @@
|
|||
|
||||
static int replyid;
|
||||
|
||||
int
|
||||
quote(Message *m, CFid *fid, char *dir, char *quotetext)
|
||||
{
|
||||
int quote(Message* m, CFid* fid, char* dir, char* quotetext) {
|
||||
char *body, *type;
|
||||
int i, n, nlines;
|
||||
char** lines;
|
||||
|
@ -27,7 +25,9 @@ quote(Message *m, CFid *fid, char *dir, char *quotetext)
|
|||
print("no type in %s\n", dir);
|
||||
return 0;
|
||||
}
|
||||
if(strncmp(type, "multipart/", 10)==0 || strncmp(type, "message/", 8)==0){
|
||||
if (
|
||||
strncmp(type, "multipart/", 10) == 0 ||
|
||||
strncmp(type, "message/", 8) == 0) {
|
||||
dir = estrstrdup(dir, "1/");
|
||||
if (quote(m, fid, dir, nil)) {
|
||||
free(type);
|
||||
|
@ -67,9 +67,8 @@ quote(Message *m, CFid *fid, char *dir, char *quotetext)
|
|||
return 1;
|
||||
}
|
||||
|
||||
void
|
||||
mkreply(Message *m, char *label, char *to, Plumbattr *attr, char *quotetext)
|
||||
{
|
||||
void mkreply(
|
||||
Message* m, char* label, char* to, Plumbattr* attr, char* quotetext) {
|
||||
char buf[100];
|
||||
CFid* fd;
|
||||
Message* r;
|
||||
|
@ -134,7 +133,9 @@ mkreply(Message *m, char *label, char *to, Plumbattr *attr, char *quotetext)
|
|||
if (strlen(m->subject) > 0) {
|
||||
t = "Subject: Re: ";
|
||||
if (strlen(m->subject) >= 3)
|
||||
if(tolower(m->subject[0])=='r' && tolower(m->subject[1])=='e' && m->subject[2]==':')
|
||||
if (
|
||||
tolower(m->subject[0]) == 'r' && tolower(m->subject[1]) == 'e' &&
|
||||
m->subject[2] == ':')
|
||||
t = "Subject: ";
|
||||
fsprint(r->w->body, "%s%s\n", t, m->subject);
|
||||
}
|
||||
|
@ -159,9 +160,7 @@ mkreply(Message *m, char *label, char *to, Plumbattr *attr, char *quotetext)
|
|||
windormant(r->w);
|
||||
}
|
||||
|
||||
void
|
||||
delreply(Message *m)
|
||||
{
|
||||
void delreply(Message* m) {
|
||||
if (m->next == nil)
|
||||
replies.tail = m->prev;
|
||||
else
|
||||
|
@ -174,10 +173,9 @@ delreply(Message *m)
|
|||
free(m);
|
||||
}
|
||||
|
||||
/* copy argv to stack and free the incoming strings, so we don't leak argument vectors */
|
||||
void
|
||||
buildargv(char **inargv, char *argv[NARGS+1], char args[NARGCHAR])
|
||||
{
|
||||
/* copy argv to stack and free the incoming strings, so we don't leak argument
|
||||
* vectors */
|
||||
void buildargv(char** inargv, char* argv[NARGS + 1], char args[NARGCHAR]) {
|
||||
int i, n;
|
||||
char *s, *a;
|
||||
|
||||
|
@ -197,9 +195,7 @@ buildargv(char **inargv, char *argv[NARGS+1], char args[NARGCHAR])
|
|||
argv[i] = nil;
|
||||
}
|
||||
|
||||
void
|
||||
execproc(void *v)
|
||||
{
|
||||
void execproc(void* v) {
|
||||
struct Exec* e;
|
||||
int p[2], q[2];
|
||||
char* prog;
|
||||
|
@ -234,28 +230,11 @@ execproc(void *v)
|
|||
threadexits("can't exec");
|
||||
}
|
||||
|
||||
enum{
|
||||
ATTACH,
|
||||
BCC,
|
||||
CC,
|
||||
FROM,
|
||||
INCLUDE,
|
||||
TO
|
||||
};
|
||||
enum { ATTACH, BCC, CC, FROM, INCLUDE, TO };
|
||||
|
||||
char *headers[] = {
|
||||
"attach:",
|
||||
"bcc:",
|
||||
"cc:",
|
||||
"from:",
|
||||
"include:",
|
||||
"to:",
|
||||
nil
|
||||
};
|
||||
char* headers[] = {"attach:", "bcc:", "cc:", "from:", "include:", "to:", nil};
|
||||
|
||||
int
|
||||
whichheader(char *h)
|
||||
{
|
||||
int whichheader(char* h) {
|
||||
int i;
|
||||
|
||||
for (i = 0; headers[i] != nil; i++)
|
||||
|
@ -271,9 +250,7 @@ int ncc, nbcc, nto;
|
|||
char* attlist[200];
|
||||
char included[200];
|
||||
|
||||
int
|
||||
addressed(char *name)
|
||||
{
|
||||
int addressed(char* name) {
|
||||
int i;
|
||||
|
||||
for (i = 0; i < nto; i++)
|
||||
|
@ -288,9 +265,7 @@ addressed(char *name)
|
|||
return 0;
|
||||
}
|
||||
|
||||
char*
|
||||
skipbl(char *s, char *e)
|
||||
{
|
||||
char* skipbl(char* s, char* e) {
|
||||
while (s < e) {
|
||||
if (*s != ' ' && *s != '\t' && *s != ',')
|
||||
break;
|
||||
|
@ -299,9 +274,7 @@ skipbl(char *s, char *e)
|
|||
return s;
|
||||
}
|
||||
|
||||
char*
|
||||
findbl(char *s, char *e)
|
||||
{
|
||||
char* findbl(char* s, char* e) {
|
||||
while (s < e) {
|
||||
if (*s == ' ' || *s == '\t' || *s == ',')
|
||||
break;
|
||||
|
@ -311,11 +284,10 @@ findbl(char *s, char *e)
|
|||
}
|
||||
|
||||
/*
|
||||
* comma-separate possibly blank-separated strings in line; e points before newline
|
||||
* comma-separate possibly blank-separated strings in line; e points before
|
||||
* newline
|
||||
*/
|
||||
void
|
||||
commas(char *s, char *e)
|
||||
{
|
||||
void commas(char* s, char* e) {
|
||||
char* t;
|
||||
|
||||
/* may have initial blanks */
|
||||
|
@ -334,9 +306,7 @@ commas(char *s, char *e)
|
|||
}
|
||||
}
|
||||
|
||||
int
|
||||
print2(int fd, int ofd, char *fmt, ...)
|
||||
{
|
||||
int print2(int fd, int ofd, char* fmt, ...) {
|
||||
int m, n;
|
||||
char* s;
|
||||
va_list arg;
|
||||
|
@ -353,9 +323,7 @@ print2(int fd, int ofd, char *fmt, ...)
|
|||
return n;
|
||||
}
|
||||
|
||||
void
|
||||
write2(int fd, int ofd, char *buf, int n, int nofrom)
|
||||
{
|
||||
void write2(int fd, int ofd, char* buf, int n, int nofrom) {
|
||||
char *from, *p;
|
||||
int m;
|
||||
|
||||
|
@ -388,9 +356,7 @@ write2(int fd, int ofd, char *buf, int n, int nofrom)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
mesgsend(Message *m)
|
||||
{
|
||||
void mesgsend(Message* m) {
|
||||
char *s, *body, *to;
|
||||
int i, j, h, n, natt, p[2];
|
||||
struct Exec* e;
|
||||
|
|
BIN
mail/reply.o
BIN
mail/reply.o
Binary file not shown.
33
mail/util.c
33
mail/util.c
|
@ -6,9 +6,7 @@
|
|||
#include <9pclient.h>
|
||||
#include "dat.h"
|
||||
|
||||
void*
|
||||
emalloc(uint n)
|
||||
{
|
||||
void* emalloc(uint n) {
|
||||
void* p;
|
||||
|
||||
p = malloc(n);
|
||||
|
@ -19,9 +17,7 @@ emalloc(uint n)
|
|||
return p;
|
||||
}
|
||||
|
||||
void*
|
||||
erealloc(void *p, uint n)
|
||||
{
|
||||
void* erealloc(void* p, uint n) {
|
||||
p = realloc(p, n);
|
||||
if (p == nil)
|
||||
error("can't realloc: %r");
|
||||
|
@ -29,9 +25,7 @@ erealloc(void *p, uint n)
|
|||
return p;
|
||||
}
|
||||
|
||||
char*
|
||||
estrdup(char *s)
|
||||
{
|
||||
char* estrdup(char* s) {
|
||||
char* t;
|
||||
|
||||
t = emalloc(strlen(s) + 1);
|
||||
|
@ -39,9 +33,7 @@ estrdup(char *s)
|
|||
return t;
|
||||
}
|
||||
|
||||
char*
|
||||
estrstrdup(char *s, char *t)
|
||||
{
|
||||
char* estrstrdup(char* s, char* t) {
|
||||
char* u;
|
||||
|
||||
u = emalloc(strlen(s) + strlen(t) + 1);
|
||||
|
@ -50,9 +42,7 @@ estrstrdup(char *s, char *t)
|
|||
return u;
|
||||
}
|
||||
|
||||
char*
|
||||
eappend(char *s, char *sep, char *t)
|
||||
{
|
||||
char* eappend(char* s, char* sep, char* t) {
|
||||
char* u;
|
||||
|
||||
if (t == nil)
|
||||
|
@ -67,17 +57,13 @@ eappend(char *s, char *sep, char *t)
|
|||
return u;
|
||||
}
|
||||
|
||||
char*
|
||||
egrow(char *s, char *sep, char *t)
|
||||
{
|
||||
char* egrow(char* s, char* sep, char* t) {
|
||||
s = eappend(s, sep, t);
|
||||
free(t);
|
||||
return s;
|
||||
}
|
||||
|
||||
void
|
||||
error(char *fmt, ...)
|
||||
{
|
||||
void error(char* fmt, ...) {
|
||||
Fmt f;
|
||||
char buf[64];
|
||||
va_list arg;
|
||||
|
@ -92,9 +78,7 @@ error(char *fmt, ...)
|
|||
threadexitsall(fmt);
|
||||
}
|
||||
|
||||
void
|
||||
ctlprint(CFid *fd, char *fmt, ...)
|
||||
{
|
||||
void ctlprint(CFid* fd, char* fmt, ...) {
|
||||
int n;
|
||||
va_list arg;
|
||||
|
||||
|
@ -104,4 +88,3 @@ ctlprint(CFid *fd, char *fmt, ...)
|
|||
if (n <= 0)
|
||||
error("control file write error: %r");
|
||||
}
|
||||
|
||||
|
|
BIN
mail/util.o
BIN
mail/util.o
Binary file not shown.
113
mail/win.c
113
mail/win.c
|
@ -6,9 +6,7 @@
|
|||
#include <9pclient.h>
|
||||
#include "dat.h"
|
||||
|
||||
Window*
|
||||
newwindow(void)
|
||||
{
|
||||
Window* newwindow(void) {
|
||||
char buf[12];
|
||||
Window* w;
|
||||
|
||||
|
@ -27,17 +25,13 @@ newwindow(void)
|
|||
return w;
|
||||
}
|
||||
|
||||
void
|
||||
winincref(Window *w)
|
||||
{
|
||||
void winincref(Window* w) {
|
||||
qlock(&w->lk);
|
||||
++w->ref;
|
||||
qunlock(&w->lk);
|
||||
}
|
||||
|
||||
void
|
||||
windecref(Window *w)
|
||||
{
|
||||
void windecref(Window* w) {
|
||||
qlock(&w->lk);
|
||||
if (--w->ref > 0) {
|
||||
qunlock(&w->lk);
|
||||
|
@ -48,18 +42,14 @@ windecref(Window *w)
|
|||
free(w);
|
||||
}
|
||||
|
||||
void
|
||||
winsetdump(Window *w, char *dir, char *cmd)
|
||||
{
|
||||
void winsetdump(Window* w, char* dir, char* cmd) {
|
||||
if (dir != nil)
|
||||
ctlprint(w->ctl, "dumpdir %s\n", dir);
|
||||
if (cmd != nil)
|
||||
ctlprint(w->ctl, "dump %s\n", cmd);
|
||||
}
|
||||
|
||||
void
|
||||
wineventproc(void *v)
|
||||
{
|
||||
void wineventproc(void* v) {
|
||||
Window* w;
|
||||
int i;
|
||||
|
||||
|
@ -72,9 +62,7 @@ wineventproc(void *v)
|
|||
}
|
||||
}
|
||||
|
||||
static CFid*
|
||||
winopenfile1(Window *w, char *f, int m)
|
||||
{
|
||||
static CFid* winopenfile1(Window* w, char* f, int m) {
|
||||
char buf[64];
|
||||
CFid* fd;
|
||||
|
||||
|
@ -85,15 +73,9 @@ winopenfile1(Window *w, char *f, int m)
|
|||
return fd;
|
||||
}
|
||||
|
||||
CFid*
|
||||
winopenfile(Window *w, char *f)
|
||||
{
|
||||
return winopenfile1(w, f, ORDWR);
|
||||
}
|
||||
CFid* winopenfile(Window* w, char* f) { return winopenfile1(w, f, ORDWR); }
|
||||
|
||||
void
|
||||
wintagwrite(Window *w, char *s, int n)
|
||||
{
|
||||
void wintagwrite(Window* w, char* s, int n) {
|
||||
CFid* fid;
|
||||
|
||||
fid = winopenfile(w, "tag");
|
||||
|
@ -102,9 +84,7 @@ wintagwrite(Window *w, char *s, int n)
|
|||
fsclose(fid);
|
||||
}
|
||||
|
||||
void
|
||||
winname(Window *w, char *s)
|
||||
{
|
||||
void winname(Window* w, char* s) {
|
||||
int len;
|
||||
char *ns, *sp;
|
||||
Rune r = L'␣'; /* visible space */
|
||||
|
@ -123,9 +103,7 @@ winname(Window *w, char *s)
|
|||
return;
|
||||
}
|
||||
|
||||
void
|
||||
winopenbody(Window *w, int mode)
|
||||
{
|
||||
void winopenbody(Window* w, int mode) {
|
||||
char buf[256];
|
||||
CFid* fid;
|
||||
|
||||
|
@ -136,31 +114,26 @@ winopenbody(Window *w, int mode)
|
|||
error("can't open window body file: %r");
|
||||
}
|
||||
|
||||
void
|
||||
winclosebody(Window *w)
|
||||
{
|
||||
void winclosebody(Window* w) {
|
||||
if (w->body != nil) {
|
||||
fsclose(w->body);
|
||||
w->body = nil;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
winwritebody(Window *w, char *s, int n)
|
||||
{
|
||||
void winwritebody(Window* w, char* s, int n) {
|
||||
if (w->body == nil)
|
||||
winopenbody(w, OWRITE);
|
||||
if (fswrite(w->body, s, n) != n)
|
||||
error("write error to window: %r");
|
||||
}
|
||||
|
||||
int
|
||||
wingetec(Window *w)
|
||||
{
|
||||
int wingetec(Window* w) {
|
||||
if (w->nbuf == 0) {
|
||||
w->nbuf = fsread(w->event, w->buf, sizeof w->buf);
|
||||
if (w->nbuf <= 0) {
|
||||
/* probably because window has exited, and only called by wineventproc, so just shut down */
|
||||
/* probably because window has exited, and only called by wineventproc, so
|
||||
* just shut down */
|
||||
windecref(w);
|
||||
threadexits(nil);
|
||||
}
|
||||
|
@ -170,9 +143,7 @@ wingetec(Window *w)
|
|||
return *w->bufp++;
|
||||
}
|
||||
|
||||
int
|
||||
wingeten(Window *w)
|
||||
{
|
||||
int wingeten(Window* w) {
|
||||
int n, c;
|
||||
|
||||
n = 0;
|
||||
|
@ -183,9 +154,7 @@ wingeten(Window *w)
|
|||
return n;
|
||||
}
|
||||
|
||||
int
|
||||
wingeter(Window *w, char *buf, int *nb)
|
||||
{
|
||||
int wingeter(Window* w, char* buf, int* nb) {
|
||||
Rune r;
|
||||
int n;
|
||||
|
||||
|
@ -201,9 +170,7 @@ wingeter(Window *w, char *buf, int *nb)
|
|||
return r;
|
||||
}
|
||||
|
||||
void
|
||||
wingetevent(Window *w, Event *e)
|
||||
{
|
||||
void wingetevent(Window* w, Event* e) {
|
||||
int i, nb;
|
||||
|
||||
e->c1 = wingetec(w);
|
||||
|
@ -225,15 +192,11 @@ wingetevent(Window *w, Event *e)
|
|||
error("event syntax error");
|
||||
}
|
||||
|
||||
void
|
||||
winwriteevent(Window *w, Event *e)
|
||||
{
|
||||
void winwriteevent(Window* w, Event* e) {
|
||||
fsprint(w->event, "%c%c%d %d\n", e->c1, e->c2, e->q0, e->q1);
|
||||
}
|
||||
|
||||
void
|
||||
winread(Window *w, uint q0, uint q1, char *data)
|
||||
{
|
||||
void winread(Window* w, uint q0, uint q1, char* data) {
|
||||
int m, n, nr;
|
||||
char buf[256];
|
||||
|
||||
|
@ -251,7 +214,9 @@ winread(Window *w, uint q0, uint q1, char *data)
|
|||
error("reading data: %r");
|
||||
nr = utfnlen(buf, n);
|
||||
while (m + nr > q1) {
|
||||
do; while(n>0 && (buf[--n]&0xC0)==0x80);
|
||||
do
|
||||
;
|
||||
while (n > 0 && (buf[--n] & 0xC0) == 0x80);
|
||||
--nr;
|
||||
}
|
||||
if (n == 0)
|
||||
|
@ -263,9 +228,7 @@ winread(Window *w, uint q0, uint q1, char *data)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
windormant(Window *w)
|
||||
{
|
||||
void windormant(Window* w) {
|
||||
if (w->addr != nil) {
|
||||
fsclose(w->addr);
|
||||
w->addr = nil;
|
||||
|
@ -280,10 +243,7 @@ windormant(Window *w)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
windel(Window *w, int sure)
|
||||
{
|
||||
int windel(Window* w, int sure) {
|
||||
if (sure)
|
||||
fswrite(w->ctl, "delete\n", 7);
|
||||
else if (fswrite(w->ctl, "del\n", 4) != 4)
|
||||
|
@ -295,15 +255,9 @@ windel(Window *w, int sure)
|
|||
return 1;
|
||||
}
|
||||
|
||||
void
|
||||
winclean(Window *w)
|
||||
{
|
||||
ctlprint(w->ctl, "clean\n");
|
||||
}
|
||||
void winclean(Window* w) { ctlprint(w->ctl, "clean\n"); }
|
||||
|
||||
int
|
||||
winsetaddr(Window *w, char *addr, int errok)
|
||||
{
|
||||
int winsetaddr(Window* w, char* addr, int errok) {
|
||||
if (w->addr == nil)
|
||||
w->addr = winopenfile(w, "addr");
|
||||
if (fswrite(w->addr, addr, strlen(addr)) < 0) {
|
||||
|
@ -314,9 +268,7 @@ winsetaddr(Window *w, char *addr, int errok)
|
|||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
winselect(Window *w, char *addr, int errok)
|
||||
{
|
||||
int winselect(Window* w, char* addr, int errok) {
|
||||
if (winsetaddr(w, addr, errok)) {
|
||||
ctlprint(w->ctl, "dot=addr\n");
|
||||
return 1;
|
||||
|
@ -324,8 +276,9 @@ winselect(Window *w, char *addr, int errok)
|
|||
return 0;
|
||||
}
|
||||
|
||||
char*
|
||||
winreadbody(Window *w, int *np) /* can't use readfile because acme doesn't report the length */
|
||||
char* winreadbody(
|
||||
Window* w,
|
||||
int* np) /* can't use readfile because acme doesn't report the length */
|
||||
{
|
||||
char* s;
|
||||
int m, na, n;
|
||||
|
@ -352,9 +305,7 @@ winreadbody(Window *w, int *np) /* can't use readfile because acme doesn't repor
|
|||
return s;
|
||||
}
|
||||
|
||||
char*
|
||||
winselection(Window *w)
|
||||
{
|
||||
char* winselection(Window* w) {
|
||||
int m, n;
|
||||
char* buf;
|
||||
char tmp[256];
|
||||
|
|
BIN
mail/win.o
BIN
mail/win.o
Binary file not shown.
119
regx.c
119
regx.c
|
@ -19,8 +19,7 @@ Rune *lastregexp;
|
|||
* Machine Information
|
||||
*/
|
||||
typedef struct Inst Inst;
|
||||
struct Inst
|
||||
{
|
||||
struct Inst {
|
||||
uint type; /* < OPERATOR ==> literal, otherwise action */
|
||||
union {
|
||||
int sid;
|
||||
|
@ -43,8 +42,7 @@ Inst *bstartinst; /* same for backwards machine */
|
|||
Channel* rechan; /* chan(Inst*) */
|
||||
|
||||
typedef struct Ilist Ilist;
|
||||
struct Ilist
|
||||
{
|
||||
struct Ilist {
|
||||
Inst* inst; /* Instruction of the thread */
|
||||
Rangeset se;
|
||||
uint startp; /* first char of match */
|
||||
|
@ -88,8 +86,7 @@ static Rangeset sempty;
|
|||
* Parser Information
|
||||
*/
|
||||
typedef struct Node Node;
|
||||
struct Node
|
||||
{
|
||||
struct Node {
|
||||
Inst* first;
|
||||
Inst* last;
|
||||
};
|
||||
|
@ -127,26 +124,20 @@ void evaluntil(int);
|
|||
void optimize(Inst*);
|
||||
void bldcclass(void);
|
||||
|
||||
void
|
||||
rxinit(void)
|
||||
{
|
||||
void rxinit(void) {
|
||||
rechan = chancreate(sizeof(Inst*), 0);
|
||||
chansetname(rechan, "rechan");
|
||||
lastregexp = runemalloc(1);
|
||||
}
|
||||
|
||||
void
|
||||
regerror(char *e)
|
||||
{
|
||||
void regerror(char* e) {
|
||||
lastregexp[0] = 0;
|
||||
warning(nil, "regexp: %s\n", e);
|
||||
sendp(rechan, nil);
|
||||
threadexits(nil);
|
||||
}
|
||||
|
||||
Inst *
|
||||
newinst(int t)
|
||||
{
|
||||
Inst* newinst(int t) {
|
||||
if (progp >= &program[NPROG])
|
||||
regerror("expression too long");
|
||||
progp->type = t;
|
||||
|
@ -155,9 +146,7 @@ newinst(int t)
|
|||
return progp++;
|
||||
}
|
||||
|
||||
void
|
||||
realcompile(void *arg)
|
||||
{
|
||||
void realcompile(void* arg) {
|
||||
int token;
|
||||
Rune* s;
|
||||
|
||||
|
@ -190,9 +179,7 @@ realcompile(void *arg)
|
|||
}
|
||||
|
||||
/* r is null terminated */
|
||||
int
|
||||
rxcompile(Rune *r)
|
||||
{
|
||||
int rxcompile(Rune* r) {
|
||||
int i, nr;
|
||||
Inst* oprogp;
|
||||
|
||||
|
@ -223,9 +210,7 @@ rxcompile(Rune *r)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
operand(int t)
|
||||
{
|
||||
void operand(int t) {
|
||||
Inst* i;
|
||||
if (lastwasand)
|
||||
operator(CAT); /* catenate is implicit */
|
||||
|
@ -239,9 +224,7 @@ operand(int t)
|
|||
lastwasand = TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
operator(int t)
|
||||
{
|
||||
void operator(int t) {
|
||||
if (t == RBRA && --nbra < 0)
|
||||
regerror("unmatched `)'");
|
||||
if (t == LBRA) {
|
||||
|
@ -258,9 +241,7 @@ operator(int t)
|
|||
lastwasand = TRUE; /* these look like operands */
|
||||
}
|
||||
|
||||
void
|
||||
pushand(Inst *f, Inst *l)
|
||||
{
|
||||
void pushand(Inst* f, Inst* l) {
|
||||
if (andp >= &andstack[NSTACK])
|
||||
error("operand stack overflow");
|
||||
andp->first = f;
|
||||
|
@ -268,9 +249,7 @@ pushand(Inst *f, Inst *l)
|
|||
andp++;
|
||||
}
|
||||
|
||||
void
|
||||
pushator(int t)
|
||||
{
|
||||
void pushator(int t) {
|
||||
if (atorp >= &atorstack[NSTACK])
|
||||
error("operator stack overflow");
|
||||
*atorp++ = t;
|
||||
|
@ -280,9 +259,7 @@ pushator(int t)
|
|||
*subidp++ = cursubid;
|
||||
}
|
||||
|
||||
Node *
|
||||
popand(int op)
|
||||
{
|
||||
Node* popand(int op) {
|
||||
char buf[64];
|
||||
|
||||
if (andp <= &andstack[0])
|
||||
|
@ -294,18 +271,14 @@ popand(int op)
|
|||
return --andp;
|
||||
}
|
||||
|
||||
int
|
||||
popator()
|
||||
{
|
||||
int popator() {
|
||||
if (atorp <= &atorstack[0])
|
||||
error("operator stack underflow");
|
||||
--subidp;
|
||||
return *--atorp;
|
||||
}
|
||||
|
||||
void
|
||||
evaluntil(int pri)
|
||||
{
|
||||
void evaluntil(int pri) {
|
||||
Node *op1, *op2, *t;
|
||||
Inst *inst1, *inst2;
|
||||
|
||||
|
@ -373,10 +346,7 @@ evaluntil(int pri)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
optimize(Inst *start)
|
||||
{
|
||||
void optimize(Inst* start) {
|
||||
Inst *inst, *target;
|
||||
|
||||
for (inst = start; inst->type != END; inst++) {
|
||||
|
@ -387,16 +357,12 @@ optimize(Inst *start)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
startlex(Rune *s)
|
||||
{
|
||||
void startlex(Rune* s) {
|
||||
exprp = s;
|
||||
nbra = 0;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
lex(void){
|
||||
int lex(void) {
|
||||
int c;
|
||||
|
||||
c = *exprp++;
|
||||
|
@ -445,9 +411,7 @@ lex(void){
|
|||
return c;
|
||||
}
|
||||
|
||||
int
|
||||
nextrec(void)
|
||||
{
|
||||
int nextrec(void) {
|
||||
if (exprp[0] == 0 || (exprp[0] == '\\' && exprp[1] == 0))
|
||||
regerror("malformed `[]'");
|
||||
if (exprp[0] == '\\') {
|
||||
|
@ -461,9 +425,7 @@ nextrec(void)
|
|||
return *exprp++;
|
||||
}
|
||||
|
||||
void
|
||||
bldcclass(void)
|
||||
{
|
||||
void bldcclass(void) {
|
||||
int c1, c2, n, na;
|
||||
Rune* classp;
|
||||
|
||||
|
@ -506,9 +468,7 @@ bldcclass(void)
|
|||
class[nclass++] = classp;
|
||||
}
|
||||
|
||||
int
|
||||
classmatch(int classno, int c, int negate)
|
||||
{
|
||||
int classmatch(int classno, int c, int negate) {
|
||||
Rune* p;
|
||||
|
||||
p = class[classno];
|
||||
|
@ -528,9 +488,7 @@ classmatch(int classno, int c, int negate)
|
|||
* *l must be pending when addinst called; if *l has been looked
|
||||
* at already, the optimization is a bug.
|
||||
*/
|
||||
int
|
||||
addinst(Ilist *l, Inst *inst, Rangeset *sep)
|
||||
{
|
||||
int addinst(Ilist* l, Inst* inst, Rangeset* sep) {
|
||||
Ilist* p;
|
||||
|
||||
for (p = l; p->inst; p++) {
|
||||
|
@ -546,16 +504,10 @@ addinst(Ilist *l, Inst *inst, Rangeset *sep)
|
|||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
rxnull(void)
|
||||
{
|
||||
return startinst==nil || bstartinst==nil;
|
||||
}
|
||||
int rxnull(void) { return startinst == nil || bstartinst == nil; }
|
||||
|
||||
/* either t!=nil or r!=nil, and we match the string in the appropriate place */
|
||||
int
|
||||
rxexecute(Text *t, Rune *r, uint startp, uint eof, Rangeset *rp)
|
||||
{
|
||||
int rxexecute(Text* t, Rune* r, uint startp, uint eof, Rangeset* rp) {
|
||||
int flag;
|
||||
Inst* inst;
|
||||
Ilist* tlp;
|
||||
|
@ -650,7 +602,9 @@ rxexecute(Text *t, Rune *r, uint startp, uint eof, Rangeset *rp)
|
|||
goto Addinst;
|
||||
break;
|
||||
case BOL:
|
||||
if(p==0 || (t!=nil && textreadc(t, p-1)=='\n') || (r!=nil && r[p-1]=='\n')){
|
||||
if (
|
||||
p == 0 || (t != nil && textreadc(t, p - 1) == '\n') ||
|
||||
(r != nil && r[p - 1] == '\n')) {
|
||||
Step:
|
||||
inst = inst->u1.next;
|
||||
goto Switchstmt;
|
||||
|
@ -688,17 +642,14 @@ rxexecute(Text *t, Rune *r, uint startp, uint eof, Rangeset *rp)
|
|||
return sel.r[0].q0 >= 0;
|
||||
}
|
||||
|
||||
void
|
||||
newmatch(Rangeset *sp)
|
||||
{
|
||||
if(sel.r[0].q0<0 || sp->r[0].q0<sel.r[0].q0 ||
|
||||
void newmatch(Rangeset* sp) {
|
||||
if (
|
||||
sel.r[0].q0 < 0 || sp->r[0].q0 < sel.r[0].q0 ||
|
||||
(sp->r[0].q0 == sel.r[0].q0 && sp->r[0].q1 > sel.r[0].q1))
|
||||
sel = *sp;
|
||||
}
|
||||
|
||||
int
|
||||
rxbexecute(Text *t, uint startp, Rangeset *rp)
|
||||
{
|
||||
int rxbexecute(Text* t, uint startp, Rangeset* rp) {
|
||||
int flag;
|
||||
Inst* inst;
|
||||
Ilist* tlp;
|
||||
|
@ -827,12 +778,12 @@ rxbexecute(Text *t, uint startp, Rangeset *rp)
|
|||
return sel.r[0].q0 >= 0;
|
||||
}
|
||||
|
||||
void
|
||||
bnewmatch(Rangeset *sp)
|
||||
{
|
||||
void bnewmatch(Rangeset* sp) {
|
||||
int i;
|
||||
|
||||
if(sel.r[0].q0<0 || sp->r[0].q0>sel.r[0].q1 || (sp->r[0].q0==sel.r[0].q1 && sp->r[0].q1<sel.r[0].q0))
|
||||
if (
|
||||
sel.r[0].q0 < 0 || sp->r[0].q0 > sel.r[0].q1 ||
|
||||
(sp->r[0].q0 == sel.r[0].q1 && sp->r[0].q1 < sel.r[0].q0))
|
||||
for (i = 0; i < NRange; i++) { /* note the reversal; q0<=q1 */
|
||||
sel.r[i].q0 = sp->r[i].q1;
|
||||
sel.r[i].q1 = sp->r[i].q0;
|
||||
|
|
202
rows.c
202
rows.c
|
@ -13,43 +13,49 @@
|
|||
#include "dat.h"
|
||||
#include "fns.h"
|
||||
|
||||
static Rune Lcolhdr[] = {
|
||||
'N', 'e', 'w', 'c', 'o', 'l', ' ',
|
||||
'K', 'i', 'l', 'l', ' ',
|
||||
'P', 'u', 't', 'a', 'l', 'l', ' ',
|
||||
'D', 'u', 'm', 'p', ' ',
|
||||
'E', 'x', 'i', 't', ' ',
|
||||
0
|
||||
};
|
||||
static Rune Lcolhdr[] = {'N', 'e', 'w', 'c', 'o', 'l', ' ', 'K', 'i', 'l',
|
||||
'l', ' ', 'P', 'u', 't', 'a', 'l', 'l', ' ', 'D',
|
||||
'u', 'm', 'p', ' ', 'E', 'x', 'i', 't', ' ', 0};
|
||||
|
||||
void
|
||||
rowinit(Row *row, Rectangle r)
|
||||
{
|
||||
void rowinit(Row* row, Rectangle r) {
|
||||
Rectangle r1;
|
||||
Text* t;
|
||||
|
||||
draw(screen, r, allocimage(display, Rect(0,0,1,1), screen->chan, 1, 0x222222FF), nil, ZP);
|
||||
draw(
|
||||
screen,
|
||||
r,
|
||||
allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, 0x222222FF),
|
||||
nil,
|
||||
ZP);
|
||||
row->r = r;
|
||||
row->col = nil;
|
||||
row->ncol = 0;
|
||||
r1 = r;
|
||||
r1.max.y = r1.min.y + font->height;
|
||||
t = &row->tag;
|
||||
textinit(t, fileaddtext(nil, t), r1, rfget(FALSE, FALSE, FALSE, nil), tagcols);
|
||||
textinit(
|
||||
t,
|
||||
fileaddtext(nil, t),
|
||||
r1,
|
||||
rfget(FALSE, FALSE, FALSE, nil),
|
||||
tagcols);
|
||||
t->what = Rowtag;
|
||||
t->row = row;
|
||||
t->w = nil;
|
||||
t->col = nil;
|
||||
r1.min.y = r1.max.y;
|
||||
r1.max.y += Border;
|
||||
draw(screen, r1, allocimage(display, Rect(0,0,1,1), screen->chan, 1, 0x222222FF), nil, ZP);
|
||||
draw(
|
||||
screen,
|
||||
r1,
|
||||
allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, 0x222222FF),
|
||||
nil,
|
||||
ZP);
|
||||
textinsert(t, 0, Lcolhdr, 29, TRUE);
|
||||
textsetselect(t, t->file->b.nc, t->file->b.nc);
|
||||
}
|
||||
|
||||
Column*
|
||||
rowadd(Row *row, Column *c, int x)
|
||||
{
|
||||
Column* rowadd(Row* row, Column* c, int x) {
|
||||
Rectangle r, r1;
|
||||
Column* d;
|
||||
int i;
|
||||
|
@ -73,7 +79,12 @@ rowadd(Row *row, Column *c, int x)
|
|||
r = d->r;
|
||||
if (Dx(r) < 100)
|
||||
return nil;
|
||||
draw(screen, r, allocimage(display, Rect(0,0,1,1), screen->chan, 1, 0x222222FF), nil, ZP);
|
||||
draw(
|
||||
screen,
|
||||
r,
|
||||
allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, 0x222222FF),
|
||||
nil,
|
||||
ZP);
|
||||
r1 = r;
|
||||
r1.max.x = min(x - Border, r.max.x - 50);
|
||||
if (Dx(r1) < 50)
|
||||
|
@ -81,7 +92,12 @@ rowadd(Row *row, Column *c, int x)
|
|||
colresize(d, r1);
|
||||
r1.min.x = r1.max.x;
|
||||
r1.max.x = r1.min.x + Border;
|
||||
draw(screen, r1, allocimage(display, Rect(0,0,1,1), screen->chan, 1, 0x222222FF), nil, ZP);
|
||||
draw(
|
||||
screen,
|
||||
r1,
|
||||
allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, 0x222222FF),
|
||||
nil,
|
||||
ZP);
|
||||
r.min.x = r1.max.x;
|
||||
}
|
||||
if (c == nil) {
|
||||
|
@ -100,9 +116,7 @@ rowadd(Row *row, Column *c, int x)
|
|||
return c;
|
||||
}
|
||||
|
||||
void
|
||||
rowresize(Row *row, Rectangle r)
|
||||
{
|
||||
void rowresize(Row* row, Rectangle r) {
|
||||
int i, deltax;
|
||||
Rectangle or, r1, r2;
|
||||
Column* c;
|
||||
|
@ -115,7 +129,12 @@ rowresize(Row *row, Rectangle r)
|
|||
textresize(&row->tag, r1, TRUE);
|
||||
r1.min.y = r1.max.y;
|
||||
r1.max.y += Border;
|
||||
draw(screen, r1, allocimage(display, Rect(0,0,1,1), screen->chan, 1, 0x222222FF), nil, ZP);
|
||||
draw(
|
||||
screen,
|
||||
r1,
|
||||
allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, 0x222222FF),
|
||||
nil,
|
||||
ZP);
|
||||
r.min.y = r1.max.y;
|
||||
r1 = r;
|
||||
r1.max.x = r1.min.x;
|
||||
|
@ -130,16 +149,19 @@ rowresize(Row *row, Rectangle r)
|
|||
if (i > 0) {
|
||||
r2 = r1;
|
||||
r2.max.x = r2.min.x + Border;
|
||||
draw(screen, r2, allocimage(display, Rect(0,0,1,1), screen->chan, 1, 0x222222FF), nil, ZP);
|
||||
draw(
|
||||
screen,
|
||||
r2,
|
||||
allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, 0x222222FF),
|
||||
nil,
|
||||
ZP);
|
||||
r1.min.x = r2.max.x;
|
||||
}
|
||||
colresize(c, r1);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
rowdragcol(Row *row, Column *c, int _0)
|
||||
{
|
||||
void rowdragcol(Row* row, Column* c, int _0) {
|
||||
Rectangle r;
|
||||
int i, b, x;
|
||||
Point p, op;
|
||||
|
@ -169,7 +191,9 @@ rowdragcol(Row *row, Column *c, int _0)
|
|||
p = mouse->xy;
|
||||
if ((abs(p.x - op.x) < 5 && abs(p.y - op.y) < 5))
|
||||
return;
|
||||
if((i>0 && p.x<row->col[i-1]->r.min.x) || (i<row->ncol-1 && p.x>c->r.max.x)){
|
||||
if (
|
||||
(i > 0 && p.x < row->col[i - 1]->r.min.x) ||
|
||||
(i < row->ncol - 1 && p.x > c->r.max.x)) {
|
||||
/* shuffle */
|
||||
x = c->r.min.x;
|
||||
rowclose(row, c, FALSE);
|
||||
|
@ -191,23 +215,31 @@ rowdragcol(Row *row, Column *c, int _0)
|
|||
p.x = c->r.max.x - 80 - Scrollwid;
|
||||
r = d->r;
|
||||
r.max.x = c->r.max.x;
|
||||
draw(screen, r, allocimage(display, Rect(0,0,1,1), screen->chan, 1, 0x222222FF), nil, ZP);
|
||||
draw(
|
||||
screen,
|
||||
r,
|
||||
allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, 0x222222FF),
|
||||
nil,
|
||||
ZP);
|
||||
r.max.x = p.x;
|
||||
colresize(d, r);
|
||||
r = c->r;
|
||||
r.min.x = p.x;
|
||||
r.max.x = r.min.x;
|
||||
r.max.x += Border;
|
||||
draw(screen, r, allocimage(display, Rect(0,0,1,1), screen->chan, 1, 0x222222FF), nil, ZP);
|
||||
draw(
|
||||
screen,
|
||||
r,
|
||||
allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, 0x222222FF),
|
||||
nil,
|
||||
ZP);
|
||||
r.min.x = r.max.x;
|
||||
r.max.x = c->r.max.x;
|
||||
colresize(c, r);
|
||||
colmousebut(c);
|
||||
}
|
||||
|
||||
void
|
||||
rowclose(Row *row, Column *c, int dofree)
|
||||
{
|
||||
void rowclose(Row* row, Column* c, int dofree) {
|
||||
Rectangle r;
|
||||
int i;
|
||||
|
||||
|
@ -223,7 +255,12 @@ rowclose(Row *row, Column *c, int dofree)
|
|||
memmove(row->col + i, row->col + i + 1, (row->ncol - i) * sizeof(Column*));
|
||||
row->col = realloc(row->col, row->ncol * sizeof(Column*));
|
||||
if (row->ncol == 0) {
|
||||
draw(screen, r, allocimage(display, Rect(0,0,1,1), screen->chan, 1, 0x222222FF), nil, ZP);
|
||||
draw(
|
||||
screen,
|
||||
r,
|
||||
allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, 0x222222FF),
|
||||
nil,
|
||||
ZP);
|
||||
return;
|
||||
}
|
||||
if (i == row->ncol) { /* extend last column right */
|
||||
|
@ -234,13 +271,16 @@ rowclose(Row *row, Column *c, int dofree)
|
|||
c = row->col[i];
|
||||
r.max.x = c->r.max.x;
|
||||
}
|
||||
draw(screen, r, allocimage(display, Rect(0,0,1,1), screen->chan, 1, 0x222222FF), nil, ZP);
|
||||
draw(
|
||||
screen,
|
||||
r,
|
||||
allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, 0x222222FF),
|
||||
nil,
|
||||
ZP);
|
||||
colresize(c, r);
|
||||
}
|
||||
|
||||
Column*
|
||||
rowwhichcol(Row *row, Point p)
|
||||
{
|
||||
Column* rowwhichcol(Row* row, Point p) {
|
||||
int i;
|
||||
Column* c;
|
||||
|
||||
|
@ -252,9 +292,7 @@ rowwhichcol(Row *row, Point p)
|
|||
return nil;
|
||||
}
|
||||
|
||||
Text*
|
||||
rowwhich(Row *row, Point p)
|
||||
{
|
||||
Text* rowwhich(Row* row, Point p) {
|
||||
Column* c;
|
||||
|
||||
if (ptinrect(p, row->tag.all))
|
||||
|
@ -265,9 +303,7 @@ rowwhich(Row *row, Point p)
|
|||
return nil;
|
||||
}
|
||||
|
||||
Text*
|
||||
rowtype(Row *row, Rune r, Point p)
|
||||
{
|
||||
Text* rowtype(Row* row, Rune r, Point p) {
|
||||
Window* w;
|
||||
Text* t;
|
||||
|
||||
|
@ -301,9 +337,7 @@ rowtype(Row *row, Rune r, Point p)
|
|||
return t;
|
||||
}
|
||||
|
||||
int
|
||||
rowclean(Row *row)
|
||||
{
|
||||
int rowclean(Row* row) {
|
||||
int clean;
|
||||
int i;
|
||||
|
||||
|
@ -313,9 +347,7 @@ rowclean(Row *row)
|
|||
return clean;
|
||||
}
|
||||
|
||||
void
|
||||
rowdump(Row *row, char *file)
|
||||
{
|
||||
void rowdump(Row* row, char* file) {
|
||||
int i, j, fd, m, n, dumped;
|
||||
uint q0, q1;
|
||||
Biobuf* b;
|
||||
|
@ -403,30 +435,51 @@ rowdump(Row *row, char *file)
|
|||
a = emalloc(1);
|
||||
if (t->file->dumpid) {
|
||||
dumped = FALSE;
|
||||
Bprint(b, "x%11d %11d %11d %11d %11.7f %s\n", i, t->file->dumpid,
|
||||
w->body.q0, w->body.q1,
|
||||
Bprint(
|
||||
b,
|
||||
"x%11d %11d %11d %11d %11.7f %s\n",
|
||||
i,
|
||||
t->file->dumpid,
|
||||
w->body.q0,
|
||||
w->body.q1,
|
||||
100.0 * (w->r.min.y - c->r.min.y) / Dy(c->r),
|
||||
fontname);
|
||||
} else if (w->dumpstr) {
|
||||
dumped = FALSE;
|
||||
Bprint(b, "e%11d %11d %11d %11d %11.7f %s\n", i, t->file->dumpid,
|
||||
0, 0,
|
||||
Bprint(
|
||||
b,
|
||||
"e%11d %11d %11d %11d %11.7f %s\n",
|
||||
i,
|
||||
t->file->dumpid,
|
||||
0,
|
||||
0,
|
||||
100.0 * (w->r.min.y - c->r.min.y) / Dy(c->r),
|
||||
fontname);
|
||||
} else if ((w->dirty == FALSE && access(a, 0) == 0) || w->isdir) {
|
||||
dumped = FALSE;
|
||||
t->file->dumpid = w->id;
|
||||
Bprint(b, "f%11d %11d %11d %11d %11.7f %s\n", i, w->id,
|
||||
w->body.q0, w->body.q1,
|
||||
Bprint(
|
||||
b,
|
||||
"f%11d %11d %11d %11d %11.7f %s\n",
|
||||
i,
|
||||
w->id,
|
||||
w->body.q0,
|
||||
w->body.q1,
|
||||
100.0 * (w->r.min.y - c->r.min.y) / Dy(c->r),
|
||||
fontname);
|
||||
} else {
|
||||
dumped = TRUE;
|
||||
t->file->dumpid = w->id;
|
||||
Bprint(b, "F%11d %11d %11d %11d %11.7f %11d %s\n", i, j,
|
||||
w->body.q0, w->body.q1,
|
||||
Bprint(
|
||||
b,
|
||||
"F%11d %11d %11d %11d %11.7f %11d %s\n",
|
||||
i,
|
||||
j,
|
||||
w->body.q0,
|
||||
w->body.q1,
|
||||
100.0 * (w->r.min.y - c->r.min.y) / Dy(c->r),
|
||||
w->body.file->b.nc, fontname);
|
||||
w->body.file->b.nc,
|
||||
fontname);
|
||||
}
|
||||
free(a);
|
||||
winctlprint(w, buf, 0);
|
||||
|
@ -467,10 +520,7 @@ rowdump(Row *row, char *file)
|
|||
fbuffree(buf);
|
||||
}
|
||||
|
||||
static
|
||||
char*
|
||||
rdline(Biobuf *b, int *linep)
|
||||
{
|
||||
static char* rdline(Biobuf* b, int* linep) {
|
||||
char* l;
|
||||
|
||||
l = Brdline(b, '\n');
|
||||
|
@ -482,9 +532,7 @@ rdline(Biobuf *b, int *linep)
|
|||
/*
|
||||
* Get font names from load file so we don't load fonts we won't use
|
||||
*/
|
||||
void
|
||||
rowloadfonts(char *file)
|
||||
{
|
||||
void rowloadfonts(char* file) {
|
||||
int i;
|
||||
Biobuf* b;
|
||||
char* l;
|
||||
|
@ -511,9 +559,7 @@ rowloadfonts(char *file)
|
|||
Bterm(b);
|
||||
}
|
||||
|
||||
int
|
||||
rowload(Row *row, char *file, int initing)
|
||||
{
|
||||
int rowload(Row* row, char* file, int initing) {
|
||||
int i, j, line, y, nr, nfontr, n, ns, ndumped, dumpid, x, fd, done;
|
||||
double percent;
|
||||
Biobuf *b, *bout;
|
||||
|
@ -584,12 +630,22 @@ rowload(Row *row, char *file, int initing)
|
|||
r2.min.x = x;
|
||||
if (Dx(r1) < 50 || Dx(r2) < 50)
|
||||
continue;
|
||||
draw(screen, Rpt(r1.min, r2.max), allocimage(display, Rect(0,0,1,1), screen->chan, 1, 0x222222FF), nil, ZP);
|
||||
draw(
|
||||
screen,
|
||||
Rpt(r1.min, r2.max),
|
||||
allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, 0x222222FF),
|
||||
nil,
|
||||
ZP);
|
||||
colresize(c1, r1);
|
||||
colresize(c2, r2);
|
||||
r2.min.x = x - Border;
|
||||
r2.max.x = x;
|
||||
draw(screen, r2, allocimage(display, Rect(0,0,1,1), screen->chan, 1, 0x222222FF), nil, ZP);
|
||||
draw(
|
||||
screen,
|
||||
r2,
|
||||
allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, 0x222222FF),
|
||||
nil,
|
||||
ZP);
|
||||
}
|
||||
if (i >= row->ncol)
|
||||
rowadd(row, nil, x);
|
||||
|
@ -795,9 +851,7 @@ Rescue1:
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
allwindows(void (*f)(Window*, void*), void *arg)
|
||||
{
|
||||
void allwindows(void (*f)(Window*, void*), void* arg) {
|
||||
int i, j;
|
||||
Column* c;
|
||||
|
||||
|
|
28
scrl.c
28
scrl.c
|
@ -14,10 +14,7 @@
|
|||
|
||||
static Image* scrtmp;
|
||||
|
||||
static
|
||||
Rectangle
|
||||
scrpos(Rectangle r, uint p0, uint p1, uint tot)
|
||||
{
|
||||
static Rectangle scrpos(Rectangle r, uint p0, uint p1, uint tot) {
|
||||
Rectangle q;
|
||||
int h;
|
||||
|
||||
|
@ -43,18 +40,19 @@ scrpos(Rectangle r, uint p0, uint p1, uint tot)
|
|||
return q;
|
||||
}
|
||||
|
||||
void
|
||||
scrlresize(void)
|
||||
{
|
||||
void scrlresize(void) {
|
||||
freeimage(scrtmp);
|
||||
scrtmp = allocimage(display, Rect(0, 0, 32, screen->r.max.y), screen->chan, 0, DNofill);
|
||||
scrtmp = allocimage(
|
||||
display,
|
||||
Rect(0, 0, 32, screen->r.max.y),
|
||||
screen->chan,
|
||||
0,
|
||||
DNofill);
|
||||
if (scrtmp == nil)
|
||||
error("scroll alloc");
|
||||
}
|
||||
|
||||
void
|
||||
textscrdraw(Text *t)
|
||||
{
|
||||
void textscrdraw(Text* t) {
|
||||
Rectangle r, r1, r2;
|
||||
Image* b;
|
||||
|
||||
|
@ -79,9 +77,7 @@ textscrdraw(Text *t)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
scrsleep(uint dt)
|
||||
{
|
||||
void scrsleep(uint dt) {
|
||||
Timer* timer;
|
||||
static Alt alts[3];
|
||||
|
||||
|
@ -104,9 +100,7 @@ scrsleep(uint dt)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
textscroll(Text *t, int but)
|
||||
{
|
||||
void textscroll(Text* t, int but) {
|
||||
uint p0, oldp0;
|
||||
Rectangle s;
|
||||
int x, y, my, h, first;
|
||||
|
|
260
text.c
260
text.c
|
@ -21,9 +21,7 @@ enum{
|
|||
TABDIR = 3 /* width of tabs in directory windows */
|
||||
};
|
||||
|
||||
void
|
||||
textinit(Text *t, File *f, Rectangle r, Reffont *rf, Image *cols[NCOL])
|
||||
{
|
||||
void textinit(Text* t, File* f, Rectangle r, Reffont* rf, Image* cols[NCOL]) {
|
||||
t->file = f;
|
||||
t->all = r;
|
||||
t->scrollr = r;
|
||||
|
@ -38,9 +36,7 @@ textinit(Text *t, File *f, Rectangle r, Reffont *rf, Image *cols[NCOL])
|
|||
textredraw(t, r, rf->f, screen, -1);
|
||||
}
|
||||
|
||||
void
|
||||
textredraw(Text *t, Rectangle r, Font *f, Image *b, int odx)
|
||||
{
|
||||
void textredraw(Text* t, Rectangle r, Font* f, Image* b, int odx) {
|
||||
int maxt;
|
||||
Rectangle rr;
|
||||
|
||||
|
@ -70,9 +66,7 @@ textredraw(Text *t, Rectangle r, Font *f, Image *b, int odx)
|
|||
}
|
||||
}
|
||||
|
||||
int
|
||||
textresize(Text *t, Rectangle r, int keepextra)
|
||||
{
|
||||
int textresize(Text* t, Rectangle r, int keepextra) {
|
||||
int odx;
|
||||
|
||||
if (Dy(r) <= 0)
|
||||
|
@ -97,9 +91,7 @@ textresize(Text *t, Rectangle r, int keepextra)
|
|||
return t->all.max.y;
|
||||
}
|
||||
|
||||
void
|
||||
textclose(Text *t)
|
||||
{
|
||||
void textclose(Text* t) {
|
||||
free(t->cache);
|
||||
frclear(&t->fr, 1);
|
||||
filedeltext(t->file, t);
|
||||
|
@ -117,9 +109,7 @@ textclose(Text *t)
|
|||
barttext = nil;
|
||||
}
|
||||
|
||||
int
|
||||
dircmp(const void *a, const void *b)
|
||||
{
|
||||
int dircmp(const void* a, const void* b) {
|
||||
Dirlist *da, *db;
|
||||
int i, n;
|
||||
|
||||
|
@ -132,9 +122,7 @@ dircmp(const void *a, const void *b)
|
|||
return da->nr - db->nr;
|
||||
}
|
||||
|
||||
void
|
||||
textcolumnate(Text *t, Dirlist **dlp, int ndl)
|
||||
{
|
||||
void textcolumnate(Text* t, Dirlist** dlp, int ndl) {
|
||||
int i, j, w, colw, mint, maxt, ncol, nrow;
|
||||
Dirlist* dl;
|
||||
uint q1;
|
||||
|
@ -189,9 +177,7 @@ textcolumnate(Text *t, Dirlist **dlp, int ndl)
|
|||
}
|
||||
}
|
||||
|
||||
int
|
||||
textload(Text *t, uint q0, char *file, int setqid)
|
||||
{
|
||||
int textload(Text* t, uint q0, char* file, int setqid) {
|
||||
Rune* rp;
|
||||
Dirlist *dl, **dlp;
|
||||
int fd, i, j, n, ndl, nulls;
|
||||
|
@ -226,7 +212,10 @@ textload(Text *t, uint q0, char *file, int setqid)
|
|||
if (d->qid.type & QTDIR) {
|
||||
/* this is checked in get() but it's possible the file changed underfoot */
|
||||
if (t->file->ntext > 1) {
|
||||
warning(nil, "%s is a directory; can't read with multiple windows on it\n", file);
|
||||
warning(
|
||||
nil,
|
||||
"%s is a directory; can't read with multiple windows on it\n",
|
||||
file);
|
||||
goto Rescue;
|
||||
}
|
||||
t->w->isdir = TRUE;
|
||||
|
@ -300,7 +289,8 @@ textload(Text *t, uint q0, char *file, int setqid)
|
|||
for (i = 0; i < t->file->ntext; i++) {
|
||||
u = t->file->text[i];
|
||||
if (u != t) {
|
||||
if(u->org > u->file->b.nc) /* will be 0 because of reset(), but safety first */
|
||||
if (u->org > u->file->b.nc) /* will be 0 because of reset(), but safety
|
||||
first */
|
||||
u->org = 0;
|
||||
textresize(u, u->all, TRUE);
|
||||
textbacknl(u, u->org, 0); /* go to beginning of line */
|
||||
|
@ -317,13 +307,12 @@ textload(Text *t, uint q0, char *file, int setqid)
|
|||
return -1;
|
||||
}
|
||||
|
||||
uint
|
||||
textbsinsert(Text *t, uint q0, Rune *r, uint n, int tofile, int *nrp)
|
||||
{
|
||||
uint textbsinsert(Text* t, uint q0, Rune* r, uint n, int tofile, int* nrp) {
|
||||
Rune *bp, *tp, *up;
|
||||
int i, initial;
|
||||
|
||||
if(t->what == Tag){ /* can't happen but safety first: mustn't backspace over file name */
|
||||
if (t->what == Tag) { /* can't happen but safety first: mustn't backspace over
|
||||
file name */
|
||||
Err:
|
||||
textinsert(t, q0, r, n, tofile);
|
||||
*nrp = n;
|
||||
|
@ -362,9 +351,7 @@ textbsinsert(Text *t, uint q0, Rune *r, uint n, int tofile, int *nrp)
|
|||
goto Err;
|
||||
}
|
||||
|
||||
void
|
||||
textinsert(Text *t, uint q0, Rune *r, uint n, int tofile)
|
||||
{
|
||||
void textinsert(Text* t, uint q0, Rune* r, uint n, int tofile) {
|
||||
int c, i;
|
||||
Text* u;
|
||||
|
||||
|
@ -388,7 +375,6 @@ textinsert(Text *t, uint q0, Rune *r, uint n, int tofile)
|
|||
textscrdraw(u);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if (q0 < t->iq1)
|
||||
t->iq1 += n;
|
||||
|
@ -411,18 +397,14 @@ textinsert(Text *t, uint q0, Rune *r, uint n, int tofile)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
typecommit(Text *t)
|
||||
{
|
||||
void typecommit(Text* t) {
|
||||
if (t->w != nil)
|
||||
wincommit(t->w, t);
|
||||
else
|
||||
textcommit(t, TRUE);
|
||||
}
|
||||
|
||||
void
|
||||
textfill(Text *t)
|
||||
{
|
||||
void textfill(Text* t) {
|
||||
Rune* rp;
|
||||
int i, n, m, nl;
|
||||
|
||||
|
@ -456,9 +438,7 @@ textfill(Text *t)
|
|||
fbuffree(rp);
|
||||
}
|
||||
|
||||
void
|
||||
textdelete(Text *t, uint q0, uint q1, int tofile)
|
||||
{
|
||||
void textdelete(Text* t, uint q0, uint q1, int tofile) {
|
||||
uint n, p0, p1;
|
||||
int i, c;
|
||||
Text* u;
|
||||
|
@ -513,16 +493,12 @@ textdelete(Text *t, uint q0, uint q1, int tofile)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
textconstrain(Text *t, uint q0, uint q1, uint *p0, uint *p1)
|
||||
{
|
||||
void textconstrain(Text* t, uint q0, uint q1, uint* p0, uint* p1) {
|
||||
*p0 = min(q0, t->file->b.nc);
|
||||
*p1 = min(q1, t->file->b.nc);
|
||||
}
|
||||
|
||||
Rune
|
||||
textreadc(Text *t, uint q)
|
||||
{
|
||||
Rune textreadc(Text* t, uint q) {
|
||||
Rune r;
|
||||
|
||||
if (t->cq0 <= q && q < t->cq0 + t->ncache)
|
||||
|
@ -532,9 +508,7 @@ textreadc(Text *t, uint q)
|
|||
return r;
|
||||
}
|
||||
|
||||
static int
|
||||
spacesindentbswidth(Text *t)
|
||||
{
|
||||
static int spacesindentbswidth(Text* t) {
|
||||
uint q, col;
|
||||
Rune r;
|
||||
|
||||
|
@ -553,9 +527,7 @@ spacesindentbswidth(Text *t)
|
|||
return t->q0 - q;
|
||||
}
|
||||
|
||||
int
|
||||
textbswidth(Text *t, Rune c)
|
||||
{
|
||||
int textbswidth(Text* t, Rune c) {
|
||||
uint q, eq;
|
||||
Rune r;
|
||||
int skipping;
|
||||
|
@ -587,9 +559,7 @@ textbswidth(Text *t, Rune c)
|
|||
return t->q0 - q;
|
||||
}
|
||||
|
||||
int
|
||||
textfilewidth(Text *t, uint q0, int oneelement)
|
||||
{
|
||||
int textfilewidth(Text* t, uint q0, int oneelement) {
|
||||
uint q;
|
||||
Rune r;
|
||||
|
||||
|
@ -605,9 +575,7 @@ textfilewidth(Text *t, uint q0, int oneelement)
|
|||
return q0 - q;
|
||||
}
|
||||
|
||||
Rune*
|
||||
textcomplete(Text *t)
|
||||
{
|
||||
Rune* textcomplete(Text* t) {
|
||||
int i, nstr, npath;
|
||||
uint q;
|
||||
Rune tmp[200];
|
||||
|
@ -618,7 +586,8 @@ textcomplete(Text *t)
|
|||
Runestr dir;
|
||||
|
||||
/* control-f: filename completion; works back to white space or / */
|
||||
if(t->q0<t->file->b.nc && textreadc(t, t->q0)>' ') /* must be at end of word */
|
||||
if (t->q0 < t->file->b.nc && textreadc(t, t->q0) > ' ') /* must be at end of
|
||||
word */
|
||||
return nil;
|
||||
nstr = textfilewidth(t, t->q0, TRUE);
|
||||
str = runemalloc(nstr);
|
||||
|
@ -667,10 +636,14 @@ textcomplete(Text *t)
|
|||
}
|
||||
|
||||
if (!c->advance) {
|
||||
warning(nil, "%.*S%s%.*S*%s\n",
|
||||
dir.nr, dir.r,
|
||||
warning(
|
||||
nil,
|
||||
"%.*S%s%.*S*%s\n",
|
||||
dir.nr,
|
||||
dir.r,
|
||||
dir.nr > 0 && dir.r[dir.nr - 1] != '/' ? "/" : "",
|
||||
nstr, str,
|
||||
nstr,
|
||||
str,
|
||||
c->nmatch ? "" : ": no matches in:");
|
||||
for (i = 0; i < c->nfile; i++)
|
||||
warning(nil, " %s\n", c->filename[i]);
|
||||
|
@ -687,9 +660,7 @@ textcomplete(Text *t)
|
|||
free(path);
|
||||
return rp;
|
||||
}
|
||||
void
|
||||
texttype(Text *t, Rune r)
|
||||
{
|
||||
void texttype(Text* t, Rune r) {
|
||||
uint q0, q1;
|
||||
int nnb, nb, n, i;
|
||||
int nr;
|
||||
|
@ -746,7 +717,10 @@ texttype(Text *t, Rune r)
|
|||
case Kpgdown:
|
||||
n = 2 * t->fr.maxlines / 3;
|
||||
case_Down:
|
||||
q0 = t->org+frcharofpt(&t->fr, Pt(t->fr.r.min.x, t->fr.r.min.y+n*t->fr.font->height));
|
||||
q0 =
|
||||
t->org + frcharofpt(
|
||||
&t->fr,
|
||||
Pt(t->fr.r.min.x, t->fr.r.min.y + n * t->fr.font->height));
|
||||
textsetorigin(t, q0, TRUE);
|
||||
return;
|
||||
case Kup:
|
||||
|
@ -899,7 +873,8 @@ texttype(Text *t, Rune r)
|
|||
nnb = textbswidth(t, r);
|
||||
q1 = t->q0;
|
||||
q0 = q1 - nnb;
|
||||
/* if selection is at beginning of window, avoid deleting invisible text */
|
||||
/* if selection is at beginning of window, avoid deleting invisible text
|
||||
*/
|
||||
if (q0 < t->org) {
|
||||
q0 = t->org;
|
||||
nnb = q1 - q0;
|
||||
|
@ -961,7 +936,8 @@ texttype(Text *t, Rune r)
|
|||
}
|
||||
break; /* fall through to normal code */
|
||||
}
|
||||
/* otherwise ordinary character; just insert, typically in caches of all texts */
|
||||
/* otherwise ordinary character; just insert, typically in caches of all texts
|
||||
*/
|
||||
for (i = 0; i < t->file->ntext; i++) {
|
||||
u = t->file->text[i];
|
||||
if (u->eq0 == ~0)
|
||||
|
@ -998,10 +974,7 @@ texttype(Text *t, Rune r)
|
|||
t->iq1 = t->q0;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
textcommit(Text *t, int tofile)
|
||||
{
|
||||
void textcommit(Text* t, int tofile) {
|
||||
if (t->ncache == 0)
|
||||
return;
|
||||
if (tofile)
|
||||
|
@ -1021,17 +994,13 @@ static uint selectq;
|
|||
/*
|
||||
* called from frame library
|
||||
*/
|
||||
void
|
||||
framescroll(Frame *f, int dl)
|
||||
{
|
||||
void framescroll(Frame* f, int dl) {
|
||||
if (f != &selecttext->fr)
|
||||
error("frameselect not right frame");
|
||||
textframescroll(selecttext, dl);
|
||||
}
|
||||
|
||||
void
|
||||
textframescroll(Text *t, int dl)
|
||||
{
|
||||
void textframescroll(Text* t, int dl) {
|
||||
uint q0;
|
||||
|
||||
if (dl == 0) {
|
||||
|
@ -1047,7 +1016,9 @@ textframescroll(Text *t, int dl)
|
|||
} else {
|
||||
if (t->org + t->fr.nchars == t->file->b.nc)
|
||||
return;
|
||||
q0 = t->org+frcharofpt(&t->fr, Pt(t->fr.r.min.x, t->fr.r.min.y+dl*t->fr.font->height));
|
||||
q0 = t->org + frcharofpt(
|
||||
&t->fr,
|
||||
Pt(t->fr.r.min.x, t->fr.r.min.y + dl * t->fr.font->height));
|
||||
if (selectq > t->org + t->fr.p1)
|
||||
textsetselect(t, t->org + t->fr.p1, selectq);
|
||||
else
|
||||
|
@ -1056,10 +1027,7 @@ textframescroll(Text *t, int dl)
|
|||
textsetorigin(t, q0, TRUE);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
textselect(Text *t)
|
||||
{
|
||||
void textselect(Text* t) {
|
||||
uint q0, q1;
|
||||
int b, x, y;
|
||||
int state;
|
||||
|
@ -1084,7 +1052,8 @@ textselect(Text *t)
|
|||
/* stay here until something interesting happens */
|
||||
do
|
||||
readmouse(mousectl);
|
||||
while(mouse->buttons==b && abs(mouse->xy.x-x)<3 && abs(mouse->xy.y-y)<3);
|
||||
while (mouse->buttons == b && abs(mouse->xy.x - x) < 3 &&
|
||||
abs(mouse->xy.y - y) < 3);
|
||||
mouse->xy.x = x; /* in case we're calling frselect */
|
||||
mouse->xy.y = y;
|
||||
q0 = t->q0; /* may have changed */
|
||||
|
@ -1157,9 +1126,7 @@ textselect(Text *t)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
textshow(Text *t, uint q0, uint q1, int doselect)
|
||||
{
|
||||
void textshow(Text* t, uint q0, uint q1, int doselect) {
|
||||
int qe;
|
||||
int nl;
|
||||
int tsd;
|
||||
|
@ -1205,10 +1172,7 @@ textshow(Text *t, uint q0, uint q1, int doselect)
|
|||
}
|
||||
}
|
||||
|
||||
static
|
||||
int
|
||||
region(int a, int b)
|
||||
{
|
||||
static int region(int a, int b) {
|
||||
if (a < b)
|
||||
return -1;
|
||||
if (a == b)
|
||||
|
@ -1216,9 +1180,7 @@ region(int a, int b)
|
|||
return 1;
|
||||
}
|
||||
|
||||
void
|
||||
selrestore(Frame *f, Point pt0, uint p0, uint p1)
|
||||
{
|
||||
void selrestore(Frame* f, Point pt0, uint p0, uint p1) {
|
||||
if (p1 <= f->p0 || p0 >= f->p1) {
|
||||
/* no overlap */
|
||||
frdrawsel0(f, pt0, p0, p1, f->cols[BACK], f->cols[TEXT]);
|
||||
|
@ -1240,16 +1202,20 @@ selrestore(Frame *f, Point pt0, uint p0, uint p1)
|
|||
}
|
||||
/* after selection */
|
||||
if (p1 > f->p1) {
|
||||
frdrawsel0(f, frptofchar(f, f->p1), f->p1, p1, f->cols[BACK], f->cols[TEXT]);
|
||||
frdrawsel0(
|
||||
f,
|
||||
frptofchar(f, f->p1),
|
||||
f->p1,
|
||||
p1,
|
||||
f->cols[BACK],
|
||||
f->cols[TEXT]);
|
||||
p1 = f->p1;
|
||||
}
|
||||
/* inside selection */
|
||||
frdrawsel0(f, pt0, p0, p1, f->cols[HIGH], f->cols[HTEXT]);
|
||||
}
|
||||
|
||||
void
|
||||
textsetselect(Text *t, uint q0, uint q1)
|
||||
{
|
||||
void textsetselect(Text* t, uint q0, uint q1) {
|
||||
int p0, p1, ticked;
|
||||
|
||||
/* t->fr.p0 and t->fr.p1 are always right; t->q0 and t->q1 may be off */
|
||||
|
@ -1277,7 +1243,14 @@ textsetselect(Text *t, uint q0, uint q1)
|
|||
return;
|
||||
}
|
||||
if (p0 > p1)
|
||||
sysfatal("acme: textsetselect p0=%d p1=%d q0=%ud q1=%ud t->org=%d nchars=%d", p0, p1, q0, q1, (int)t->org, (int)t->fr.nchars);
|
||||
sysfatal(
|
||||
"acme: textsetselect p0=%d p1=%d q0=%ud q1=%ud t->org=%d nchars=%d",
|
||||
p0,
|
||||
p1,
|
||||
q0,
|
||||
q1,
|
||||
(int)t->org,
|
||||
(int)t->fr.nchars);
|
||||
/* screen disagrees with desired selection */
|
||||
if (t->fr.p1 <= p0 || p1 <= t->fr.p0 || p0 == p1 || t->fr.p1 == t->fr.p0) {
|
||||
/* no overlap or too easy to bother trying */
|
||||
|
@ -1311,13 +1284,11 @@ textsetselect(Text *t, uint q0, uint q1)
|
|||
* Release the button in less than DELAY ms and it's considered a null selection
|
||||
* if the mouse hardly moved, regardless of whether it crossed a char boundary.
|
||||
*/
|
||||
enum {
|
||||
DELAY = 2,
|
||||
MINMOVE = 4
|
||||
};
|
||||
enum { DELAY = 2, MINMOVE = 4 };
|
||||
|
||||
uint
|
||||
xselect(Frame *f, Mousectl *mc, Image *col, uint *p1p) /* when called, button is down */
|
||||
uint xselect(
|
||||
Frame* f, Mousectl* mc, Image* col,
|
||||
uint* p1p) /* when called, button is down */
|
||||
{
|
||||
uint p0, p1, q, tmp;
|
||||
ulong msec;
|
||||
|
@ -1373,9 +1344,9 @@ xselect(Frame *f, Mousectl *mc, Image *col, uint *p1p) /* when called, button is
|
|||
flushimage(f->display, 1);
|
||||
readmouse(mc);
|
||||
} while (mc->m.buttons == b);
|
||||
if(mc->m.msec-msec < DELAY && p0!=p1
|
||||
&& abs(mp.x-mc->m.xy.x)<MINMOVE
|
||||
&& abs(mp.y-mc->m.xy.y)<MINMOVE) {
|
||||
if (
|
||||
mc->m.msec - msec < DELAY && p0 != p1 && abs(mp.x - mc->m.xy.x) < MINMOVE &&
|
||||
abs(mp.y - mc->m.xy.y) < MINMOVE) {
|
||||
if (reg > 0)
|
||||
selrestore(f, pt0, p0, p1);
|
||||
else if (reg < 0)
|
||||
|
@ -1399,9 +1370,7 @@ xselect(Frame *f, Mousectl *mc, Image *col, uint *p1p) /* when called, button is
|
|||
return p0;
|
||||
}
|
||||
|
||||
int
|
||||
textselect23(Text *t, uint *q0, uint *q1, Image *high, int mask)
|
||||
{
|
||||
int textselect23(Text* t, uint* q0, uint* q1, Image* high, int mask) {
|
||||
uint p0, p1;
|
||||
int buts;
|
||||
|
||||
|
@ -1417,9 +1386,7 @@ textselect23(Text *t, uint *q0, uint *q1, Image *high, int mask)
|
|||
return buts;
|
||||
}
|
||||
|
||||
int
|
||||
textselect2(Text *t, uint *q0, uint *q1, Text **tp)
|
||||
{
|
||||
int textselect2(Text* t, uint* q0, uint* q1, Text** tp) {
|
||||
int buts;
|
||||
|
||||
*tp = nil;
|
||||
|
@ -1433,9 +1400,7 @@ textselect2(Text *t, uint *q0, uint *q1, Text **tp)
|
|||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
textselect3(Text *t, uint *q0, uint *q1)
|
||||
{
|
||||
int textselect3(Text* t, uint* q0, uint* q1) {
|
||||
int h;
|
||||
|
||||
h = (textselect23(t, q0, q1, but3col, 1 | 2) == 0);
|
||||
|
@ -1447,24 +1412,10 @@ static Rune right1[] = { '}', ']', ')', '>', 0xbb, 0 };
|
|||
static Rune left2[] = {'\n', 0};
|
||||
static Rune left3[] = {'\'', '"', '`', 0};
|
||||
|
||||
static
|
||||
Rune *left[] = {
|
||||
left1,
|
||||
left2,
|
||||
left3,
|
||||
nil
|
||||
};
|
||||
static
|
||||
Rune *right[] = {
|
||||
right1,
|
||||
left2,
|
||||
left3,
|
||||
nil
|
||||
};
|
||||
static Rune* left[] = {left1, left2, left3, nil};
|
||||
static Rune* right[] = {right1, left2, left3, nil};
|
||||
|
||||
void
|
||||
textdoubleclick(Text *t, uint *q0, uint *q1)
|
||||
{
|
||||
void textdoubleclick(Text* t, uint* q0, uint* q1) {
|
||||
int c, i;
|
||||
Rune *r, *l, *p;
|
||||
uint q;
|
||||
|
@ -1512,9 +1463,7 @@ textdoubleclick(Text *t, uint *q0, uint *q1)
|
|||
(*q0)--;
|
||||
}
|
||||
|
||||
int
|
||||
textclickmatch(Text *t, int cl, int cr, int dir, uint *q)
|
||||
{
|
||||
int textclickmatch(Text* t, int cl, int cr, int dir, uint* q) {
|
||||
Rune c;
|
||||
int nest;
|
||||
|
||||
|
@ -1543,9 +1492,7 @@ textclickmatch(Text *t, int cl, int cr, int dir, uint *q)
|
|||
// Is the text starting at location q an html tag?
|
||||
// Return 1 for <a>, -1 for </a>, 0 for no tag or <a />.
|
||||
// Set *q1, if non-nil, to the location after the tag.
|
||||
static int
|
||||
ishtmlstart(Text *t, uint q, uint *q1)
|
||||
{
|
||||
static int ishtmlstart(Text* t, uint q, uint* q1) {
|
||||
int c, c1, c2;
|
||||
|
||||
if (q + 2 > t->file->b.nc)
|
||||
|
@ -1573,9 +1520,7 @@ ishtmlstart(Text *t, uint q, uint *q1)
|
|||
// Is the text ending at location q an html tag?
|
||||
// Return 1 for <a>, -1 for </a>, 0 for no tag or <a />.
|
||||
// Set *q0, if non-nil, to the start of the tag.
|
||||
static int
|
||||
ishtmlend(Text *t, uint q, uint *q0)
|
||||
{
|
||||
static int ishtmlend(Text* t, uint q, uint* q0) {
|
||||
int c, c1, c2;
|
||||
|
||||
if (q < 2)
|
||||
|
@ -1600,9 +1545,7 @@ ishtmlend(Text *t, uint q, uint *q0)
|
|||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
textclickhtmlmatch(Text *t, uint *q0, uint *q1)
|
||||
{
|
||||
int textclickhtmlmatch(Text* t, uint* q0, uint* q1) {
|
||||
int depth, n;
|
||||
uint q, nq;
|
||||
|
||||
|
@ -1646,9 +1589,7 @@ textclickhtmlmatch(Text *t, uint *q0, uint *q1)
|
|||
return 0;
|
||||
}
|
||||
|
||||
uint
|
||||
textbacknl(Text *t, uint p, uint n)
|
||||
{
|
||||
uint textbacknl(Text* t, uint p, uint n) {
|
||||
int i, j;
|
||||
|
||||
/* look for start of this line if n==0 */
|
||||
|
@ -1667,9 +1608,7 @@ textbacknl(Text *t, uint p, uint n)
|
|||
return p;
|
||||
}
|
||||
|
||||
void
|
||||
textsetorigin(Text *t, uint org, int exact)
|
||||
{
|
||||
void textsetorigin(Text* t, uint org, int exact) {
|
||||
int i, a, fixup;
|
||||
Rune* r;
|
||||
uint n;
|
||||
|
@ -1689,9 +1628,9 @@ textsetorigin(Text *t, uint org, int exact)
|
|||
fixup = 0;
|
||||
if (a >= 0 && a < t->fr.nchars) {
|
||||
frdelete(&t->fr, 0, a);
|
||||
fixup = 1; /* frdelete can leave end of last line in wrong selection mode; it doesn't know what follows */
|
||||
}
|
||||
else if(a<0 && -a<t->fr.nchars){
|
||||
fixup = 1; /* frdelete can leave end of last line in wrong selection mode;
|
||||
it doesn't know what follows */
|
||||
} else if (a < 0 && -a < t->fr.nchars) {
|
||||
n = t->org - org;
|
||||
r = runemalloc(n);
|
||||
bufread(&t->file->b, org, r, n);
|
||||
|
@ -1704,12 +1643,15 @@ textsetorigin(Text *t, uint org, int exact)
|
|||
textscrdraw(t);
|
||||
textsetselect(t, t->q0, t->q1);
|
||||
if (fixup && t->fr.p1 > t->fr.p0)
|
||||
frdrawsel(&t->fr, frptofchar(&t->fr, t->fr.p1-1), t->fr.p1-1, t->fr.p1, 1);
|
||||
frdrawsel(
|
||||
&t->fr,
|
||||
frptofchar(&t->fr, t->fr.p1 - 1),
|
||||
t->fr.p1 - 1,
|
||||
t->fr.p1,
|
||||
1);
|
||||
}
|
||||
|
||||
void
|
||||
textreset(Text *t)
|
||||
{
|
||||
void textreset(Text* t) {
|
||||
t->file->seq = 0;
|
||||
t->eq0 = ~0;
|
||||
/* do t->delete(0, t->nc, TRUE) without building backup stuff */
|
||||
|
|
33
time.c
33
time.c
|
@ -15,30 +15,16 @@
|
|||
static Channel* ctimer; /* chan(Timer*)[100] */
|
||||
static Timer* timer;
|
||||
|
||||
static
|
||||
uint
|
||||
msec(void)
|
||||
{
|
||||
return nsec()/1000000;
|
||||
}
|
||||
static uint msec(void) { return nsec() / 1000000; }
|
||||
|
||||
void
|
||||
timerstop(Timer *t)
|
||||
{
|
||||
void timerstop(Timer* t) {
|
||||
t->next = timer;
|
||||
timer = t;
|
||||
}
|
||||
|
||||
void
|
||||
timercancel(Timer *t)
|
||||
{
|
||||
t->cancel = TRUE;
|
||||
}
|
||||
void timercancel(Timer* t) { t->cancel = TRUE; }
|
||||
|
||||
static
|
||||
void
|
||||
timerproc(void *v)
|
||||
{
|
||||
static void timerproc(void* v) {
|
||||
int i, nt, na, dt, del;
|
||||
Timer **t, *x;
|
||||
uint old, new;
|
||||
|
@ -51,7 +37,8 @@ timerproc(void *v)
|
|||
nt = 0;
|
||||
old = msec();
|
||||
for (;;) {
|
||||
sleep(10); /* longer sleeps here delay recv on ctimer, but 10ms should not be noticeable */
|
||||
sleep(10); /* longer sleeps here delay recv on ctimer, but 10ms should not
|
||||
be noticeable */
|
||||
new = msec();
|
||||
dt = new - old;
|
||||
old = new;
|
||||
|
@ -95,17 +82,13 @@ timerproc(void *v)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
timerinit(void)
|
||||
{
|
||||
void timerinit(void) {
|
||||
ctimer = chancreate(sizeof(Timer*), 100);
|
||||
chansetname(ctimer, "ctimer");
|
||||
proccreate(timerproc, nil, STACK);
|
||||
}
|
||||
|
||||
Timer*
|
||||
timerstart(int dt)
|
||||
{
|
||||
Timer* timerstart(int dt) {
|
||||
Timer* t;
|
||||
|
||||
t = timer;
|
||||
|
|
117
util.c
117
util.c
|
@ -15,9 +15,7 @@
|
|||
static Point prevmouse;
|
||||
static Window* mousew;
|
||||
|
||||
Range
|
||||
range(int q0, int q1)
|
||||
{
|
||||
Range range(int q0, int q1) {
|
||||
Range r;
|
||||
|
||||
r.q0 = q0;
|
||||
|
@ -25,9 +23,7 @@ range(int q0, int q1)
|
|||
return r;
|
||||
}
|
||||
|
||||
Runestr
|
||||
runestr(Rune *r, uint n)
|
||||
{
|
||||
Runestr runestr(Rune* r, uint n) {
|
||||
Runestr rs;
|
||||
|
||||
rs.r = r;
|
||||
|
@ -35,9 +31,7 @@ runestr(Rune *r, uint n)
|
|||
return rs;
|
||||
}
|
||||
|
||||
void
|
||||
cvttorunes(char *p, int n, Rune *r, int *nb, int *nr, int *nulls)
|
||||
{
|
||||
void cvttorunes(char* p, int n, Rune* r, int* nb, int* nr, int* nulls) {
|
||||
uchar* q;
|
||||
Rune* s;
|
||||
int j, w;
|
||||
|
@ -68,16 +62,12 @@ cvttorunes(char *p, int n, Rune *r, int *nb, int *nr, int *nulls)
|
|||
*nr = s - r;
|
||||
}
|
||||
|
||||
void
|
||||
error(char *s)
|
||||
{
|
||||
void error(char* s) {
|
||||
fprint(2, "acme: %s: %r\n", s);
|
||||
threadexitsall(nil);
|
||||
}
|
||||
|
||||
Window*
|
||||
errorwin1(Rune *dir, int ndir, Rune **incl, int nincl)
|
||||
{
|
||||
Window* errorwin1(Rune* dir, int ndir, Rune** incl, int nincl) {
|
||||
Window* w;
|
||||
Rune* r;
|
||||
int i, n;
|
||||
|
@ -113,9 +103,7 @@ errorwin1(Rune *dir, int ndir, Rune **incl, int nincl)
|
|||
}
|
||||
|
||||
/* make new window, if necessary; return with it locked */
|
||||
Window*
|
||||
errorwin(Mntdir *md, int owner)
|
||||
{
|
||||
Window* errorwin(Mntdir* md, int owner) {
|
||||
Window* w;
|
||||
|
||||
for (;;) {
|
||||
|
@ -137,9 +125,7 @@ errorwin(Mntdir *md, int owner)
|
|||
* It will be unlocked and returned window
|
||||
* will be locked in its place.
|
||||
*/
|
||||
Window*
|
||||
errorwinforwin(Window *w)
|
||||
{
|
||||
Window* errorwinforwin(Window* w) {
|
||||
int i, n, nincl, owner;
|
||||
Rune** incl;
|
||||
Runestr dir;
|
||||
|
@ -185,10 +171,7 @@ struct Warning{
|
|||
|
||||
static Warning* warnings;
|
||||
|
||||
static
|
||||
void
|
||||
addwarningtext(Mntdir *md, Rune *r, int nr)
|
||||
{
|
||||
static void addwarningtext(Mntdir* md, Rune* r, int nr) {
|
||||
Warning* warn;
|
||||
|
||||
for (warn = warnings; warn; warn = warn->next) {
|
||||
|
@ -208,9 +191,7 @@ addwarningtext(Mntdir *md, Rune *r, int nr)
|
|||
}
|
||||
|
||||
/* called while row is locked */
|
||||
void
|
||||
flushwarnings(void)
|
||||
{
|
||||
void flushwarnings(void) {
|
||||
Warning *warn, *next;
|
||||
Window* w;
|
||||
Text* t;
|
||||
|
@ -257,9 +238,7 @@ flushwarnings(void)
|
|||
warnings = nil;
|
||||
}
|
||||
|
||||
void
|
||||
warning(Mntdir *md, char *s, ...)
|
||||
{
|
||||
void warning(Mntdir* md, char* s, ...) {
|
||||
Rune* r;
|
||||
va_list arg;
|
||||
|
||||
|
@ -272,33 +251,25 @@ warning(Mntdir *md, char *s, ...)
|
|||
free(r);
|
||||
}
|
||||
|
||||
int
|
||||
runeeq(Rune *s1, uint n1, Rune *s2, uint n2)
|
||||
{
|
||||
int runeeq(Rune* s1, uint n1, Rune* s2, uint n2) {
|
||||
if (n1 != n2)
|
||||
return FALSE;
|
||||
return memcmp(s1, s2, n1 * sizeof(Rune)) == 0;
|
||||
}
|
||||
|
||||
uint
|
||||
min(uint a, uint b)
|
||||
{
|
||||
uint min(uint a, uint b) {
|
||||
if (a < b)
|
||||
return a;
|
||||
return b;
|
||||
}
|
||||
|
||||
uint
|
||||
max(uint a, uint b)
|
||||
{
|
||||
uint max(uint a, uint b) {
|
||||
if (a > b)
|
||||
return a;
|
||||
return b;
|
||||
}
|
||||
|
||||
char*
|
||||
runetobyte(Rune *r, int n)
|
||||
{
|
||||
char* runetobyte(Rune* r, int n) {
|
||||
char* s;
|
||||
|
||||
if (r == nil)
|
||||
|
@ -309,9 +280,7 @@ runetobyte(Rune *r, int n)
|
|||
return s;
|
||||
}
|
||||
|
||||
Rune*
|
||||
bytetorune(char *s, int *ip)
|
||||
{
|
||||
Rune* bytetorune(char* s, int* ip) {
|
||||
Rune* r;
|
||||
int nb, nr;
|
||||
|
||||
|
@ -323,9 +292,7 @@ bytetorune(char *s, int *ip)
|
|||
return r;
|
||||
}
|
||||
|
||||
int
|
||||
isalnum(Rune c)
|
||||
{
|
||||
int isalnum(Rune c) {
|
||||
/*
|
||||
* Hard to get absolutely right. Use what we know about ASCII
|
||||
* and assume anything above the Latin control characters is
|
||||
|
@ -340,15 +307,9 @@ isalnum(Rune c)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
int
|
||||
rgetc(void *v, uint n)
|
||||
{
|
||||
return ((Rune*)v)[n];
|
||||
}
|
||||
int rgetc(void* v, uint n) { return ((Rune*)v)[n]; }
|
||||
|
||||
int
|
||||
tgetc(void *a, uint n)
|
||||
{
|
||||
int tgetc(void* a, uint n) {
|
||||
Text* t;
|
||||
|
||||
t = a;
|
||||
|
@ -357,9 +318,7 @@ tgetc(void *a, uint n)
|
|||
return textreadc(t, n);
|
||||
}
|
||||
|
||||
Rune*
|
||||
skipbl(Rune *r, int n, int *np)
|
||||
{
|
||||
Rune* skipbl(Rune* r, int n, int* np) {
|
||||
while (n > 0 && (*r == ' ' || *r == '\t' || *r == '\n')) {
|
||||
--n;
|
||||
r++;
|
||||
|
@ -368,9 +327,7 @@ skipbl(Rune *r, int n, int *np)
|
|||
return r;
|
||||
}
|
||||
|
||||
Rune*
|
||||
findbl(Rune *r, int n, int *np)
|
||||
{
|
||||
Rune* findbl(Rune* r, int n, int* np) {
|
||||
while (n > 0 && *r != ' ' && *r != '\t' && *r != '\n') {
|
||||
--n;
|
||||
r++;
|
||||
|
@ -379,16 +336,12 @@ findbl(Rune *r, int n, int *np)
|
|||
return r;
|
||||
}
|
||||
|
||||
void
|
||||
savemouse(Window *w)
|
||||
{
|
||||
void savemouse(Window* w) {
|
||||
prevmouse = mouse->xy;
|
||||
mousew = w;
|
||||
}
|
||||
|
||||
int
|
||||
restoremouse(Window *w)
|
||||
{
|
||||
int restoremouse(Window* w) {
|
||||
int did;
|
||||
|
||||
did = 0;
|
||||
|
@ -400,15 +353,9 @@ restoremouse(Window *w)
|
|||
return did;
|
||||
}
|
||||
|
||||
void
|
||||
clearmouse()
|
||||
{
|
||||
mousew = nil;
|
||||
}
|
||||
void clearmouse() { mousew = nil; }
|
||||
|
||||
char*
|
||||
estrdup(char *s)
|
||||
{
|
||||
char* estrdup(char* s) {
|
||||
char* t;
|
||||
|
||||
t = strdup(s);
|
||||
|
@ -418,9 +365,7 @@ estrdup(char *s)
|
|||
return t;
|
||||
}
|
||||
|
||||
void*
|
||||
emalloc(uint n)
|
||||
{
|
||||
void* emalloc(uint n) {
|
||||
void* p;
|
||||
|
||||
p = malloc(n);
|
||||
|
@ -431,9 +376,7 @@ emalloc(uint n)
|
|||
return p;
|
||||
}
|
||||
|
||||
void*
|
||||
erealloc(void *p, uint n)
|
||||
{
|
||||
void* erealloc(void* p, uint n) {
|
||||
p = realloc(p, n);
|
||||
if (p == nil)
|
||||
error("realloc failed");
|
||||
|
@ -444,9 +387,7 @@ erealloc(void *p, uint n)
|
|||
/*
|
||||
* Heuristic city.
|
||||
*/
|
||||
Window*
|
||||
makenewwindow(Text *t)
|
||||
{
|
||||
Window* makenewwindow(Text* t) {
|
||||
Column* c;
|
||||
Window *w, *bigw, *emptyw;
|
||||
Text* emptyb;
|
||||
|
@ -475,7 +416,9 @@ makenewwindow(Text *t)
|
|||
/* use >= to choose one near bottom of screen */
|
||||
if (w->body.fr.maxlines >= bigw->body.fr.maxlines)
|
||||
bigw = w;
|
||||
if(w->body.fr.maxlines-w->body.fr.nlines >= emptyw->body.fr.maxlines-emptyw->body.fr.nlines)
|
||||
if (
|
||||
w->body.fr.maxlines - w->body.fr.nlines >=
|
||||
emptyw->body.fr.maxlines - emptyw->body.fr.nlines)
|
||||
emptyw = w;
|
||||
}
|
||||
emptyb = &emptyw->body;
|
||||
|
|
193
wind.c
193
wind.c
|
@ -14,9 +14,7 @@
|
|||
|
||||
int winid;
|
||||
|
||||
void
|
||||
wininit(Window *w, Window *clone, Rectangle r)
|
||||
{
|
||||
void wininit(Window* w, Window* clone, Rectangle r) {
|
||||
Rectangle r1, br;
|
||||
File* f;
|
||||
Reffont* rf;
|
||||
|
@ -94,9 +92,7 @@ wininit(Window *w, Window *clone, Rectangle r)
|
|||
/*
|
||||
* Draw the appropriate button.
|
||||
*/
|
||||
void
|
||||
windrawbutton(Window *w)
|
||||
{
|
||||
void windrawbutton(Window* w) {
|
||||
Image* b;
|
||||
Rectangle br;
|
||||
|
||||
|
@ -109,9 +105,7 @@ windrawbutton(Window *w)
|
|||
draw(screen, br, b, nil, b->r.min);
|
||||
}
|
||||
|
||||
int
|
||||
delrunepos(Window *w)
|
||||
{
|
||||
int delrunepos(Window* w) {
|
||||
int n;
|
||||
Rune rune;
|
||||
|
||||
|
@ -126,24 +120,22 @@ delrunepos(Window *w)
|
|||
return n;
|
||||
}
|
||||
|
||||
void
|
||||
movetodel(Window *w)
|
||||
{
|
||||
void movetodel(Window* w) {
|
||||
int n;
|
||||
|
||||
n = delrunepos(w);
|
||||
if (n < 0)
|
||||
return;
|
||||
moveto(mousectl, addpt(frptofchar(&w->tag.fr, n), Pt(4, w->tag.fr.font->height-4)));
|
||||
moveto(
|
||||
mousectl,
|
||||
addpt(frptofchar(&w->tag.fr, n), Pt(4, w->tag.fr.font->height - 4)));
|
||||
}
|
||||
|
||||
/*
|
||||
* Compute number of tag lines required
|
||||
* to display entire tag text.
|
||||
*/
|
||||
int
|
||||
wintaglines(Window *w, Rectangle r)
|
||||
{
|
||||
int wintaglines(Window* w, Rectangle r) {
|
||||
int n;
|
||||
Rune rune;
|
||||
Point p;
|
||||
|
@ -181,9 +173,7 @@ wintaglines(Window *w, Rectangle r)
|
|||
return n;
|
||||
}
|
||||
|
||||
int
|
||||
winresize(Window *w, Rectangle r, int safe, int keepextra)
|
||||
{
|
||||
int winresize(Window* w, Rectangle r, int safe, int keepextra) {
|
||||
int oy, y, mouseintag, mouseinbody;
|
||||
Point p;
|
||||
Rectangle r1;
|
||||
|
@ -253,17 +243,13 @@ winresize(Window *w, Rectangle r, int safe, int keepextra)
|
|||
return w->r.max.y;
|
||||
}
|
||||
|
||||
void
|
||||
winlock1(Window *w, int owner)
|
||||
{
|
||||
void winlock1(Window* w, int owner) {
|
||||
incref(&w->ref);
|
||||
qlock(&w->lk);
|
||||
w->owner = owner;
|
||||
}
|
||||
|
||||
void
|
||||
winlock(Window *w, int owner)
|
||||
{
|
||||
void winlock(Window* w, int owner) {
|
||||
int i;
|
||||
File* f;
|
||||
|
||||
|
@ -272,9 +258,7 @@ winlock(Window *w, int owner)
|
|||
winlock1(f->text[i]->w, owner);
|
||||
}
|
||||
|
||||
void
|
||||
winunlock(Window *w)
|
||||
{
|
||||
void winunlock(Window* w) {
|
||||
int i;
|
||||
File* f;
|
||||
|
||||
|
@ -292,16 +276,13 @@ winunlock(Window *w)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
winmousebut(Window *w)
|
||||
{
|
||||
moveto(mousectl, addpt(w->tag.scrollr.min,
|
||||
divpt(Pt(Dx(w->tag.scrollr), font->height), 2)));
|
||||
void winmousebut(Window* w) {
|
||||
moveto(
|
||||
mousectl,
|
||||
addpt(w->tag.scrollr.min, divpt(Pt(Dx(w->tag.scrollr), font->height), 2)));
|
||||
}
|
||||
|
||||
void
|
||||
windirfree(Window *w)
|
||||
{
|
||||
void windirfree(Window* w) {
|
||||
int i;
|
||||
Dirlist* dl;
|
||||
|
||||
|
@ -317,9 +298,7 @@ windirfree(Window *w)
|
|||
w->ndl = 0;
|
||||
}
|
||||
|
||||
void
|
||||
winclose(Window *w)
|
||||
{
|
||||
void winclose(Window* w) {
|
||||
int i;
|
||||
|
||||
if (decref(&w->ref) == 0) {
|
||||
|
@ -337,9 +316,7 @@ winclose(Window *w)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
windelete(Window *w)
|
||||
{
|
||||
void windelete(Window* w) {
|
||||
Xfid* x;
|
||||
|
||||
x = w->eventx;
|
||||
|
@ -352,9 +329,7 @@ windelete(Window *w)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
winundo(Window *w, int isundo)
|
||||
{
|
||||
void winundo(Window* w, int isundo) {
|
||||
Text* body;
|
||||
int i;
|
||||
File* f;
|
||||
|
@ -376,9 +351,7 @@ winundo(Window *w, int isundo)
|
|||
winsettag(w);
|
||||
}
|
||||
|
||||
void
|
||||
winsetname(Window *w, Rune *name, int n)
|
||||
{
|
||||
void winsetname(Window* w, Rune* name, int n) {
|
||||
Text* t;
|
||||
Window* v;
|
||||
int i;
|
||||
|
@ -401,9 +374,7 @@ winsetname(Window *w, Rune *name, int n)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
wintype(Window *w, Text *t, Rune r)
|
||||
{
|
||||
void wintype(Window* w, Text* t, Rune r) {
|
||||
int i;
|
||||
|
||||
texttype(t, r);
|
||||
|
@ -413,19 +384,13 @@ wintype(Window *w, Text *t, Rune r)
|
|||
winsettag(w);
|
||||
}
|
||||
|
||||
void
|
||||
wincleartag(Window *w)
|
||||
{
|
||||
void wincleartag(Window* w) {
|
||||
int i, n;
|
||||
Rune* r;
|
||||
|
||||
/* w must be committed */
|
||||
n = w->tag.file->b.nc;
|
||||
r = runemalloc(n);
|
||||
bufread(&w->tag.file->b, 0, r, n);
|
||||
for(i=0; i<n; i++)
|
||||
if(r[i]==' ' || r[i]=='\t')
|
||||
break;
|
||||
r = parsetag(w, &i);
|
||||
for (; i < n; i++)
|
||||
if (r[i] == '|')
|
||||
break;
|
||||
|
@ -442,14 +407,47 @@ wincleartag(Window *w)
|
|||
textsetselect(&w->tag, w->tag.q0, w->tag.q1);
|
||||
}
|
||||
|
||||
void
|
||||
winsettag1(Window *w)
|
||||
{
|
||||
Rune* parsetag(Window* w, int* len) {
|
||||
static Rune Ldelsnarf[] =
|
||||
{' ', 'D', 'e', 'l', ' ', 'S', 'n', 'a', 'r', 'f', 0};
|
||||
static Rune Lspacepipe[] = {' ', '|', 0};
|
||||
static Rune Ltabpipe[] = {' ', '|', 0};
|
||||
int i;
|
||||
Rune *r, *p, *pipe;
|
||||
|
||||
r = runemalloc(w->tag.file->b.nc + 1);
|
||||
bufread(&w->tag.file->b, 0, r, w->tag.file->b.nc);
|
||||
r[w->tag.file->b.nc] = '\0';
|
||||
|
||||
for (i = 0; i < w->tag.file->b.nc; i++)
|
||||
if (r[i] == ' ' || r[i] == '\t')
|
||||
break;
|
||||
|
||||
/*
|
||||
* " |" or "\t|" ends left half of tag
|
||||
* If we find " Del Snarf" in the left half of the tag
|
||||
* (before the pipe), that ends the file name.
|
||||
*/
|
||||
pipe = runestrstr(r, Lspacepipe);
|
||||
if ((p = runestrstr(r, Ltabpipe)) != nil && (pipe == nil || p < pipe))
|
||||
pipe = p;
|
||||
if ((p = runestrstr(r, Ldelsnarf)) != nil && (pipe == nil || p < pipe))
|
||||
i = p - r;
|
||||
else {
|
||||
for (i = 0; i < w->tag.file->b.nc; i++)
|
||||
if (r[i] == ' ' || r[i] == '\t')
|
||||
break;
|
||||
}
|
||||
*len = i;
|
||||
return r;
|
||||
}
|
||||
|
||||
void winsettag1(Window* w) {
|
||||
int i, j, k, n, bar, dirty, resize;
|
||||
Rune* new, *old, *r;
|
||||
uint q0, q1;
|
||||
static Rune Ldelsnarf[] = { ' ', 'D', 'e', 'l', ' ',
|
||||
'S', 'n', 'a', 'r', 'f', 0 };
|
||||
static Rune Ldelsnarf[] =
|
||||
{' ', 'D', 'e', 'l', ' ', 'S', 'n', 'a', 'r', 'f', 0};
|
||||
static Rune Lundo[] = {' ', 'U', 'n', 'd', 'o', 0};
|
||||
static Rune Lredo[] = {' ', 'R', 'e', 'd', 'o', 0};
|
||||
static Rune Lget[] = {' ', 'G', 'e', 't', 0};
|
||||
|
@ -457,15 +455,12 @@ winsettag1(Window *w)
|
|||
static Rune Llook[] = {' ', 'L', 'o', 'o', 'k', ' ', 0};
|
||||
static Rune Lpipe[] = {' ', '|', 0};
|
||||
|
||||
/* there are races that get us here with stuff in the tag cache, so we take extra care to sync it */
|
||||
/* there are races that get us here with stuff in the tag cache, so we take
|
||||
* extra care to sync it */
|
||||
if (w->tag.ncache != 0 || w->tag.file->mod)
|
||||
wincommit(w, &w->tag); /* check file name; also guarantees we can modify tag contents */
|
||||
old = runemalloc(w->tag.file->b.nc+1);
|
||||
bufread(&w->tag.file->b, 0, old, w->tag.file->b.nc);
|
||||
old[w->tag.file->b.nc] = '\0';
|
||||
for(i=0; i<w->tag.file->b.nc; i++)
|
||||
if(old[i]==' ' || old[i]=='\t')
|
||||
break;
|
||||
wincommit(w, &w->tag); /* check file name; also guarantees we can modify tag
|
||||
contents */
|
||||
old = parsetag(w, &i);
|
||||
if (runeeq(old, i, w->body.file->name, w->body.file->nname) == FALSE) {
|
||||
textdelete(&w->tag, 0, i, TRUE);
|
||||
textinsert(&w->tag, 0, w->body.file->name, w->body.file->nname, TRUE);
|
||||
|
@ -491,7 +486,8 @@ winsettag1(Window *w)
|
|||
runemove(new + i, Lredo, 5);
|
||||
i += 5;
|
||||
}
|
||||
dirty = w->body.file->nname && (w->body.ncache || w->body.file->seq!=w->putseq);
|
||||
dirty =
|
||||
w->body.file->nname && (w->body.ncache || w->body.file->seq != w->putseq);
|
||||
if (!w->isdir && dirty) {
|
||||
runemove(new + i, Lput, 4);
|
||||
i += 4;
|
||||
|
@ -556,9 +552,7 @@ winsettag1(Window *w)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
winsettag(Window *w)
|
||||
{
|
||||
void winsettag(Window* w) {
|
||||
int i;
|
||||
File* f;
|
||||
Window* v;
|
||||
|
@ -571,9 +565,7 @@ winsettag(Window *w)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
wincommit(Window *w, Text *t)
|
||||
{
|
||||
void wincommit(Window* w, Text* t) {
|
||||
Rune* r;
|
||||
int i;
|
||||
File* f;
|
||||
|
@ -585,11 +577,7 @@ wincommit(Window *w, Text *t)
|
|||
textcommit(f->text[i], FALSE); /* no-op for t */
|
||||
if (t->what == Body)
|
||||
return;
|
||||
r = runemalloc(w->tag.file->b.nc);
|
||||
bufread(&w->tag.file->b, 0, r, w->tag.file->b.nc);
|
||||
for(i=0; i<w->tag.file->b.nc; i++)
|
||||
if(r[i]==' ' || r[i]=='\t')
|
||||
break;
|
||||
r = parsetag(w, &i);
|
||||
if (runeeq(r, i, w->body.file->name, w->body.file->nname) == FALSE) {
|
||||
seq++;
|
||||
filemark(w->body.file);
|
||||
|
@ -601,9 +589,7 @@ wincommit(Window *w, Text *t)
|
|||
free(r);
|
||||
}
|
||||
|
||||
void
|
||||
winaddincl(Window *w, Rune *r, int n)
|
||||
{
|
||||
void winaddincl(Window* w, Rune* r, int n) {
|
||||
char* a;
|
||||
Dir* d;
|
||||
Runestr rs;
|
||||
|
@ -647,10 +633,9 @@ Rescue:
|
|||
return;
|
||||
}
|
||||
|
||||
int
|
||||
winclean(Window *w, int conservative)
|
||||
{
|
||||
if(w->isscratch || w->isdir) /* don't whine if it's a guide file, error window, etc. */
|
||||
int winclean(Window* w, int conservative) {
|
||||
if (w->isscratch || w->isdir) /* don't whine if it's a guide file, error
|
||||
window, etc. */
|
||||
return TRUE;
|
||||
if (!conservative && w->nopen[QWevent] > 0)
|
||||
return TRUE;
|
||||
|
@ -668,20 +653,26 @@ winclean(Window *w, int conservative)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
char*
|
||||
winctlprint(Window *w, char *buf, int fonts)
|
||||
{
|
||||
sprint(buf, "%11d %11d %11d %11d %11d ", w->id, w->tag.file->b.nc,
|
||||
w->body.file->b.nc, w->isdir, w->dirty);
|
||||
char* winctlprint(Window* w, char* buf, int fonts) {
|
||||
sprint(
|
||||
buf,
|
||||
"%11d %11d %11d %11d %11d ",
|
||||
w->id,
|
||||
w->tag.file->b.nc,
|
||||
w->body.file->b.nc,
|
||||
w->isdir,
|
||||
w->dirty);
|
||||
if (fonts)
|
||||
return smprint("%s%11d %q %11d ", buf, Dx(w->body.fr.r),
|
||||
w->body.reffont->f->name, w->body.fr.maxtab);
|
||||
return smprint(
|
||||
"%s%11d %q %11d ",
|
||||
buf,
|
||||
Dx(w->body.fr.r),
|
||||
w->body.reffont->f->name,
|
||||
w->body.fr.maxtab);
|
||||
return buf;
|
||||
}
|
||||
|
||||
void
|
||||
winevent(Window *w, char *fmt, ...)
|
||||
{
|
||||
void winevent(Window* w, char* fmt, ...) {
|
||||
int n;
|
||||
char* b;
|
||||
Xfid* x;
|
||||
|
|
165
xfid.c
165
xfid.c
|
@ -12,10 +12,7 @@
|
|||
#include "dat.h"
|
||||
#include "fns.h"
|
||||
|
||||
enum
|
||||
{
|
||||
Ctlsize = 5*12
|
||||
};
|
||||
enum { Ctlsize = 5 * 12 };
|
||||
|
||||
char Edel[] = "deleted window";
|
||||
char Ebadctl[] = "ill-formed control message";
|
||||
|
@ -25,10 +22,7 @@ char Einuse[] = "already in use";
|
|||
char Ebadevent[] = "bad event syntax";
|
||||
extern char Eperm[];
|
||||
|
||||
static
|
||||
void
|
||||
clampaddr(Window *w)
|
||||
{
|
||||
static void clampaddr(Window* w) {
|
||||
if (w->addr.q0 < 0)
|
||||
w->addr.q0 = 0;
|
||||
if (w->addr.q1 < 0)
|
||||
|
@ -39,9 +33,7 @@ clampaddr(Window *w)
|
|||
w->addr.q1 = w->body.file->b.nc;
|
||||
}
|
||||
|
||||
void
|
||||
xfidctl(void *arg)
|
||||
{
|
||||
void xfidctl(void* arg) {
|
||||
Xfid* x;
|
||||
void (*f)(Xfid*);
|
||||
|
||||
|
@ -55,9 +47,7 @@ xfidctl(void *arg)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
xfidflush(Xfid *x)
|
||||
{
|
||||
void xfidflush(Xfid* x) {
|
||||
Fcall fc;
|
||||
int i, j;
|
||||
Window* w;
|
||||
|
@ -89,9 +79,7 @@ out:
|
|||
respond(x, &fc, nil);
|
||||
}
|
||||
|
||||
void
|
||||
xfidopen(Xfid *x)
|
||||
{
|
||||
void xfidopen(Xfid* x) {
|
||||
Fcall fc;
|
||||
Window* w;
|
||||
Text* t;
|
||||
|
@ -186,8 +174,7 @@ xfidopen(Xfid *x)
|
|||
break;
|
||||
}
|
||||
winunlock(w);
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
switch (q) {
|
||||
case Qlog:
|
||||
xfidlogopen(x);
|
||||
|
@ -206,9 +193,7 @@ xfidopen(Xfid *x)
|
|||
respond(x, &fc, nil);
|
||||
}
|
||||
|
||||
void
|
||||
xfidclose(Xfid *x)
|
||||
{
|
||||
void xfidclose(Xfid* x) {
|
||||
Fcall fc;
|
||||
Window* w;
|
||||
int q;
|
||||
|
@ -263,9 +248,13 @@ xfidclose(Xfid *x)
|
|||
case QWwrsel:
|
||||
w->nomark = FALSE;
|
||||
t = &w->body;
|
||||
/* before: only did this if !w->noscroll, but that didn't seem right in practice */
|
||||
textshow(t, min(w->wrselrange.q0, t->file->b.nc),
|
||||
min(w->wrselrange.q1, t->file->b.nc), 1);
|
||||
/* before: only did this if !w->noscroll, but that didn't seem right in
|
||||
* practice */
|
||||
textshow(
|
||||
t,
|
||||
min(w->wrselrange.q0, t->file->b.nc),
|
||||
min(w->wrselrange.q1, t->file->b.nc),
|
||||
1);
|
||||
textscrdraw(t);
|
||||
break;
|
||||
case QWeditout:
|
||||
|
@ -274,8 +263,7 @@ xfidclose(Xfid *x)
|
|||
}
|
||||
winunlock(w);
|
||||
winclose(w);
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
switch (q) {
|
||||
case Qeditout:
|
||||
qunlock(&editoutlk);
|
||||
|
@ -285,9 +273,7 @@ xfidclose(Xfid *x)
|
|||
respond(x, &fc, nil);
|
||||
}
|
||||
|
||||
void
|
||||
xfidread(Xfid *x)
|
||||
{
|
||||
void xfidread(Xfid* x) {
|
||||
Fcall fc;
|
||||
int n, q;
|
||||
uint off;
|
||||
|
@ -404,24 +390,23 @@ xfidread(Xfid *x)
|
|||
winunlock(w);
|
||||
}
|
||||
|
||||
static int
|
||||
shouldscroll(Text *t, uint q0, int qid)
|
||||
{
|
||||
static int shouldscroll(Text* t, uint q0, int qid) {
|
||||
if (qid == Qcons)
|
||||
return TRUE;
|
||||
return t->org <= q0 && q0 <= t->org + t->fr.nchars;
|
||||
}
|
||||
|
||||
static Rune*
|
||||
fullrunewrite(Xfid *x, int *inr)
|
||||
{
|
||||
static Rune* fullrunewrite(Xfid* x, int* inr) {
|
||||
int q, cnt, c, nb, nr;
|
||||
Rune* r;
|
||||
|
||||
q = x->f->nrpart;
|
||||
cnt = x->fcall.count;
|
||||
if (q > 0) {
|
||||
memmove(x->fcall.data+q, x->fcall.data, cnt); /* there's room; see fsysproc */
|
||||
memmove(
|
||||
x->fcall.data + q,
|
||||
x->fcall.data,
|
||||
cnt); /* there's room; see fsysproc */
|
||||
memmove(x->fcall.data, x->f->rpart, q);
|
||||
cnt += q;
|
||||
x->f->nrpart = 0;
|
||||
|
@ -443,9 +428,7 @@ fullrunewrite(Xfid *x, int *inr)
|
|||
return r;
|
||||
}
|
||||
|
||||
void
|
||||
xfidwrite(Xfid *x)
|
||||
{
|
||||
void xfidwrite(Xfid* x) {
|
||||
Fcall fc;
|
||||
int c, qid, nb, nr, eval;
|
||||
char buf[64], *err;
|
||||
|
@ -486,7 +469,17 @@ xfidwrite(Xfid *x)
|
|||
t = &w->body;
|
||||
wincommit(w, t);
|
||||
eval = TRUE;
|
||||
a = address(FALSE, t, w->limit, w->addr, r, 0, nr, rgetc, &eval, (uint*)&nb);
|
||||
a = address(
|
||||
FALSE,
|
||||
t,
|
||||
w->limit,
|
||||
w->addr,
|
||||
r,
|
||||
0,
|
||||
nr,
|
||||
rgetc,
|
||||
&eval,
|
||||
(uint*)&nb);
|
||||
free(r);
|
||||
if (nb < nr) {
|
||||
respond(x, &fc, Ebadaddr);
|
||||
|
@ -595,7 +588,10 @@ xfidwrite(Xfid *x)
|
|||
filemark(t->file);
|
||||
}
|
||||
q0 = textbsinsert(t, q0, r, nr, TRUE, &nr);
|
||||
textsetselect(t, t->q0, t->q1); /* insert could leave it somewhere else */
|
||||
textsetselect(
|
||||
t,
|
||||
t->q0,
|
||||
t->q1); /* insert could leave it somewhere else */
|
||||
if (qid != QWwrsel && shouldscroll(t, q0, qid))
|
||||
textshow(t, q0 + nr, q0 + nr, 1);
|
||||
textscrdraw(t);
|
||||
|
@ -618,9 +614,7 @@ xfidwrite(Xfid *x)
|
|||
winunlock(w);
|
||||
}
|
||||
|
||||
void
|
||||
xfidctlwrite(Xfid *x, Window *w)
|
||||
{
|
||||
void xfidctlwrite(Xfid* x, Window* w) {
|
||||
Fcall fc;
|
||||
int i, m, n, nb, nr, nulls;
|
||||
Rune* r;
|
||||
|
@ -647,13 +641,11 @@ xfidctlwrite(Xfid *x, Window *w)
|
|||
qlock(&w->ctllock);
|
||||
w->ctlfid = x->f->fid;
|
||||
m = 4;
|
||||
}else
|
||||
if(strncmp(p, "unlock", 6) == 0){ /* release exclusive use */
|
||||
} else if (strncmp(p, "unlock", 6) == 0) { /* release exclusive use */
|
||||
w->ctlfid = ~0;
|
||||
qunlock(&w->ctllock);
|
||||
m = 6;
|
||||
}else
|
||||
if(strncmp(p, "clean", 5) == 0){ /* mark window 'clean', seq=0 */
|
||||
} else if (strncmp(p, "clean", 5) == 0) { /* mark window 'clean', seq=0 */
|
||||
t = &w->body;
|
||||
t->eq0 = ~0;
|
||||
filereset(t->file);
|
||||
|
@ -661,21 +653,19 @@ xfidctlwrite(Xfid *x, Window *w)
|
|||
w->dirty = FALSE;
|
||||
settag = TRUE;
|
||||
m = 5;
|
||||
}else
|
||||
if(strncmp(p, "dirty", 5) == 0){ /* mark window 'dirty' */
|
||||
} else if (strncmp(p, "dirty", 5) == 0) { /* mark window 'dirty' */
|
||||
t = &w->body;
|
||||
/* doesn't change sequence number, so "Put" won't appear. it shouldn't. */
|
||||
/* doesn't change sequence number, so "Put" won't appear. it shouldn't.
|
||||
*/
|
||||
t->file->mod = TRUE;
|
||||
w->dirty = TRUE;
|
||||
settag = TRUE;
|
||||
m = 5;
|
||||
}else
|
||||
if(strncmp(p, "show", 4) == 0){ /* show dot */
|
||||
} else if (strncmp(p, "show", 4) == 0) { /* show dot */
|
||||
t = &w->body;
|
||||
textshow(t, t->q0, t->q1, 1);
|
||||
m = 4;
|
||||
}else
|
||||
if(strncmp(p, "name ", 5) == 0){ /* set file name */
|
||||
} else if (strncmp(p, "name ", 5) == 0) { /* set file name */
|
||||
pp = p + 5;
|
||||
m = 5;
|
||||
q = memchr(pp, '\n', e - pp);
|
||||
|
@ -700,8 +690,7 @@ out:
|
|||
filemark(w->body.file);
|
||||
winsetname(w, r, nr);
|
||||
m += (q + 1) - pp;
|
||||
}else
|
||||
if(strncmp(p, "dump ", 5) == 0){ /* set dump string */
|
||||
} else if (strncmp(p, "dump ", 5) == 0) { /* set dump string */
|
||||
pp = p + 5;
|
||||
m = 5;
|
||||
q = memchr(pp, '\n', e - pp);
|
||||
|
@ -718,8 +707,7 @@ out:
|
|||
}
|
||||
w->dumpstr = runetobyte(r, nr);
|
||||
m += (q + 1) - pp;
|
||||
}else
|
||||
if(strncmp(p, "dumpdir ", 8) == 0){ /* set dump directory */
|
||||
} else if (strncmp(p, "dumpdir ", 8) == 0) { /* set dump directory */
|
||||
pp = p + 8;
|
||||
m = 8;
|
||||
q = memchr(pp, '\n', e - pp);
|
||||
|
@ -736,28 +724,23 @@ out:
|
|||
}
|
||||
w->dumpdir = runetobyte(r, nr);
|
||||
m += (q + 1) - pp;
|
||||
}else
|
||||
if(strncmp(p, "delete", 6) == 0){ /* delete for sure */
|
||||
} else if (strncmp(p, "delete", 6) == 0) { /* delete for sure */
|
||||
colclose(w->col, w, TRUE);
|
||||
m = 6;
|
||||
}else
|
||||
if(strncmp(p, "del", 3) == 0){ /* delete, but check dirty */
|
||||
} else if (strncmp(p, "del", 3) == 0) { /* delete, but check dirty */
|
||||
if (!winclean(w, TRUE)) {
|
||||
err = "file dirty";
|
||||
break;
|
||||
}
|
||||
colclose(w->col, w, TRUE);
|
||||
m = 3;
|
||||
}else
|
||||
if(strncmp(p, "get", 3) == 0){ /* get file */
|
||||
} else if (strncmp(p, "get", 3) == 0) { /* get file */
|
||||
get(&w->body, nil, nil, FALSE, XXX, nil, 0);
|
||||
m = 3;
|
||||
}else
|
||||
if(strncmp(p, "put", 3) == 0){ /* put file */
|
||||
} else if (strncmp(p, "put", 3) == 0) { /* put file */
|
||||
put(&w->body, nil, nil, XXX, XXX, nil, 0);
|
||||
m = 3;
|
||||
}else
|
||||
if(strncmp(p, "dot=addr", 8) == 0){ /* set dot */
|
||||
} else if (strncmp(p, "dot=addr", 8) == 0) { /* set dot */
|
||||
textcommit(&w->body, TRUE);
|
||||
clampaddr(w);
|
||||
w->body.q0 = w->addr.q0;
|
||||
|
@ -765,40 +748,33 @@ out:
|
|||
textsetselect(&w->body, w->body.q0, w->body.q1);
|
||||
settag = TRUE;
|
||||
m = 8;
|
||||
}else
|
||||
if(strncmp(p, "addr=dot", 8) == 0){ /* set addr */
|
||||
} else if (strncmp(p, "addr=dot", 8) == 0) { /* set addr */
|
||||
w->addr.q0 = w->body.q0;
|
||||
w->addr.q1 = w->body.q1;
|
||||
m = 8;
|
||||
}else
|
||||
if(strncmp(p, "limit=addr", 10) == 0){ /* set limit */
|
||||
} else if (strncmp(p, "limit=addr", 10) == 0) { /* set limit */
|
||||
textcommit(&w->body, TRUE);
|
||||
clampaddr(w);
|
||||
w->limit.q0 = w->addr.q0;
|
||||
w->limit.q1 = w->addr.q1;
|
||||
m = 10;
|
||||
}else
|
||||
if(strncmp(p, "nomark", 6) == 0){ /* turn off automatic marking */
|
||||
} else if (strncmp(p, "nomark", 6) == 0) { /* turn off automatic marking */
|
||||
w->nomark = TRUE;
|
||||
m = 6;
|
||||
}else
|
||||
if(strncmp(p, "mark", 4) == 0){ /* mark file */
|
||||
} else if (strncmp(p, "mark", 4) == 0) { /* mark file */
|
||||
seq++;
|
||||
filemark(w->body.file);
|
||||
settag = TRUE;
|
||||
m = 4;
|
||||
}else
|
||||
if(strncmp(p, "nomenu", 6) == 0){ /* turn off automatic menu */
|
||||
} else if (strncmp(p, "nomenu", 6) == 0) { /* turn off automatic menu */
|
||||
w->filemenu = FALSE;
|
||||
settag = TRUE;
|
||||
m = 6;
|
||||
}else
|
||||
if(strncmp(p, "menu", 4) == 0){ /* enable automatic menu */
|
||||
} else if (strncmp(p, "menu", 4) == 0) { /* enable automatic menu */
|
||||
w->filemenu = TRUE;
|
||||
settag = TRUE;
|
||||
m = 4;
|
||||
}else
|
||||
if(strncmp(p, "cleartag", 8) == 0){ /* wipe tag right of bar */
|
||||
} else if (strncmp(p, "cleartag", 8) == 0) { /* wipe tag right of bar */
|
||||
wincleartag(w);
|
||||
settag = TRUE;
|
||||
m = 8;
|
||||
|
@ -824,9 +800,7 @@ out:
|
|||
textscrdraw(&w->body);
|
||||
}
|
||||
|
||||
void
|
||||
xfideventwrite(Xfid *x, Window *w)
|
||||
{
|
||||
void xfideventwrite(Xfid* x, Window* w) {
|
||||
Fcall fc;
|
||||
int m, n;
|
||||
Rune* r;
|
||||
|
@ -889,7 +863,6 @@ xfideventwrite(Xfid *x, Window *w)
|
|||
goto Rescue;
|
||||
}
|
||||
qunlock(&row.lk);
|
||||
|
||||
}
|
||||
|
||||
Out:
|
||||
|
@ -908,9 +881,7 @@ xfideventwrite(Xfid *x, Window *w)
|
|||
goto Out;
|
||||
}
|
||||
|
||||
void
|
||||
xfidutfread(Xfid *x, Text *t, uint q1, int qid)
|
||||
{
|
||||
void xfidutfread(Xfid* x, Text* t, uint q1, int qid) {
|
||||
Fcall fc;
|
||||
Window* w;
|
||||
Rune* r;
|
||||
|
@ -973,9 +944,7 @@ xfidutfread(Xfid *x, Text *t, uint q1, int qid)
|
|||
fbuffree(b1);
|
||||
}
|
||||
|
||||
int
|
||||
xfidruneread(Xfid *x, Text *t, uint q0, uint q1)
|
||||
{
|
||||
int xfidruneread(Xfid* x, Text* t, uint q0, uint q1) {
|
||||
Fcall fc;
|
||||
Window* w;
|
||||
Rune *r, junk;
|
||||
|
@ -1027,9 +996,7 @@ xfidruneread(Xfid *x, Text *t, uint q0, uint q1)
|
|||
return q - q0;
|
||||
}
|
||||
|
||||
void
|
||||
xfideventread(Xfid *x, Window *w)
|
||||
{
|
||||
void xfideventread(Xfid* x, Window* w) {
|
||||
Fcall fc;
|
||||
int i, n;
|
||||
|
||||
|
@ -1064,9 +1031,7 @@ xfideventread(Xfid *x, Window *w)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
xfidindexread(Xfid *x)
|
||||
{
|
||||
void xfidindexread(Xfid* x) {
|
||||
Fcall fc;
|
||||
int i, j, m, n, nmax, isbuf, cnt, off;
|
||||
Window* w;
|
||||
|
|
Loading…
Reference in a new issue