abaco: cleanup, handle image/x-icon, don't use backspace as a hotkey, and remove urlconvience()/related functions
This commit is contained in:
parent
170913631b
commit
73eea8402b
3 changed files with 9 additions and 58 deletions
|
@ -73,6 +73,7 @@ static struct {
|
|||
"image/pjpeg", "jpg -t9",
|
||||
"image/png", "png -t9",
|
||||
"image/ppm", "ppm -t9",
|
||||
"image/x-icon", "ico -c",
|
||||
nil, nil,
|
||||
};
|
||||
|
||||
|
@ -713,11 +714,6 @@ pagetype(Page *p, Rune r, Point xy)
|
|||
b->key(b, p, r);
|
||||
return;
|
||||
}
|
||||
/* ^H: same as 'Back' */
|
||||
if(r == 0x08){
|
||||
wingohist(p->w, FALSE);
|
||||
return;
|
||||
}
|
||||
|
||||
x = 0;
|
||||
y = 0;
|
||||
|
|
|
@ -164,7 +164,7 @@ textbswidth(Text *t, Rune c)
|
|||
int skipping;
|
||||
|
||||
/* there is known to be at least one character to erase */
|
||||
if(c == 0x08) /* ^H: erase character */
|
||||
if(c == Kbs) /* ^H: erase character */
|
||||
return 1;
|
||||
q = t->q0;
|
||||
skipping = TRUE;
|
||||
|
@ -175,7 +175,7 @@ textbswidth(Text *t, Rune c)
|
|||
--q;
|
||||
break;
|
||||
}
|
||||
if(c == 0x17){
|
||||
if(c == Ketb){
|
||||
eq = isalnum(r);
|
||||
if(eq && skipping) /* found one; stop skipping */
|
||||
skipping = FALSE;
|
||||
|
@ -246,14 +246,14 @@ texttype(Text *t, Rune r)
|
|||
case Kend:
|
||||
textshow(t, t->rs.nr, t->rs.nr, FALSE);
|
||||
return;
|
||||
case 0x01: /* ^A: beginning of line */
|
||||
case Ksoh: /* ^A: beginning of line */
|
||||
/* go to where ^U would erase, if not already at BOL */
|
||||
nb = 0;
|
||||
if(t->q0>0 && t->rs.r[t->q0-1]!='\n')
|
||||
nb = textbswidth(t, 0x15);
|
||||
nb = textbswidth(t, Knack);
|
||||
textshow(t, t->q0-nb, t->q0-nb, TRUE);
|
||||
return;
|
||||
case 0x05: /* ^E: end of line */
|
||||
case Kenq: /* ^E: end of line */
|
||||
q0 = t->q0;
|
||||
while(q0<t->rs.nr && t->rs.r[q0]!='\n')
|
||||
q0++;
|
||||
|
@ -265,9 +265,9 @@ texttype(Text *t, Rune r)
|
|||
|
||||
textshow(t, t->q0, t->q0, TRUE);
|
||||
switch(r){
|
||||
case 0x08: /* ^H: erase character */
|
||||
case 0x15: /* ^U: erase line */
|
||||
case 0x17: /* ^W: erase word */
|
||||
case Kbs: /* ^H: erase character */
|
||||
case Knack: /* ^U: erase line */
|
||||
case Ketb: /* ^W: erase word */
|
||||
if(t->q0 == 0) /* nothing to erase */
|
||||
return;
|
||||
nb = textbswidth(t, r);
|
||||
|
|
|
@ -70,57 +70,12 @@ getattr(int conn, char *s)
|
|||
return (Runestr){runesmprint("%s", buf), n};
|
||||
}
|
||||
|
||||
// tired of typing http://, tired of going to google first.
|
||||
void
|
||||
justgoogleit(Url *u)
|
||||
{
|
||||
Rune *s;
|
||||
|
||||
s = ucvt(u->src.r+2);
|
||||
free(u->src.r);
|
||||
u->src.r = runesmprint("http://www.google.com/search?hl=en&ie=UTF-8&q=%S", s);
|
||||
free(s);
|
||||
u->src.nr = runestrlen(u->src.r);
|
||||
}
|
||||
|
||||
void
|
||||
addhttp(Url *u)
|
||||
{
|
||||
Rune *s;
|
||||
if(validurl(u->src.r))
|
||||
return;
|
||||
s = u->src.r;
|
||||
u->src.r = runesmprint("http://%S", u->src.r);
|
||||
free(s);
|
||||
u->src.nr = runestrlen(u->src.r);
|
||||
}
|
||||
|
||||
struct{
|
||||
void (*f)(Url*);
|
||||
Rune *lead;
|
||||
int len;
|
||||
} ctab[] = {
|
||||
justgoogleit, L"g ", 2,
|
||||
addhttp, L"", 0,
|
||||
};
|
||||
|
||||
void
|
||||
urlconvience(Url *u)
|
||||
{
|
||||
int i;
|
||||
|
||||
for(i = 0; u->src.nr >= ctab[i].len && runestrncmp(u->src.r, ctab[i].lead, ctab[i].len) != 0; i++)
|
||||
;
|
||||
ctab[i].f(u);
|
||||
}
|
||||
|
||||
int
|
||||
urlopen(Url *u)
|
||||
{
|
||||
char buf[BUFSIZE];
|
||||
int cfd, fd, conn, n;
|
||||
|
||||
urlconvience(u);
|
||||
snprint(buf, sizeof(buf), "%s/clone", webmountpt);
|
||||
cfd = open(buf, ORDWR);
|
||||
if(cfd < 0)
|
||||
|
|
Loading…
Reference in a new issue