about summary refs log tree commit diff stats
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
...
* move around more modulesbptato2023-09-1454-121/+121
| | | | | | | | | | * ips -> io/ * loader related stuff -> loader/ * tempfile -> extern/ * buffer, forkserver -> server/ * lineedit, window -> display/ * cell -> types/ * opt -> types/
* move some modules to local/bptato2023-09-145-6/+6
| | | | makes a bit more sense than the previous arrangement
* Switch buffer -> client connection to client -> bufferbptato2023-09-143-37/+29
| | | | | | | | | | | | We now connect to buffers from the client, instead of connecting buffers to the client. This has the following advantages: * Simplifies the client event loop. * Makes the client a real client (no more serversocket dependency). * Slightly more secure, as we no longer have to trust buffers not lying about their process ids. * Facilitates the potential future addition of connections from several clients to a single buffer.
* fix ansi color parsing of multiple valuesbptato2023-09-131-1/+0
| | | | | Increasing the index breaks parsing, because that is already done in getParam().
* twtstr: simplifybptato2023-09-132-13/+8
| | | | | | * remove unused function isAlphaAscii * swap pushHex for less casting * remove == overload for char/rune (we did not really use it anyway)
* toml: fix underscore number separatorbptato2023-09-131-1/+1
| | | | | | Underscores should not be added to repr. Also, was_num should only start as true if the first character is a number, and must be true after the while loop.
* Do not use mailcap for text/plainbptato2023-09-131-0/+5
|
* fix compile errorbptato2023-09-131-1/+1
| | | | aaaaaa
* toml: simplifybptato2023-09-131-4/+2
| | | | I meant to put this in the previous commit
* toml: fix bugs in parseNumberbptato2023-09-131-12/+15
| | | | | The input c was not considered, so positive/negative/non-decimal number parsing was incorrect.
* toml: do not stream inputbptato2023-09-131-4/+1
| | | | | | | | | It is more efficient to just read the whole file into memory than to... read the whole file into memory, but one piece at a time, while calling the rather slow readLine function for each chunk. (Also, configuration files are rather small, so even a proper streaming implementation would be pointless.)
* toml: add support for hex/octal numbersbptato2023-09-131-9/+45
|
* color: fix parseLegacyColor bugsbptato2023-09-132-10/+14
| | | | | | * lower-case the input string. * do not fall back to black on error. (i.e. remove the special cased parseLegacyColor0 in cascade)
* layout: make table rowspan occupy several rowsbptato2023-09-112-20/+51
| | | | | Now cells with a rowspan > 1 actually occupy several rows. The implementation is quite ugly but it should work for now.
* layout: fix table row group regressionbptato2023-09-101-9/+29
| | | | | Turns out we had the row groups separated for a reason: we need them so we can implicitly sort rows based on their row group type.
* container: accept numbers in cursorLeft, cursorRight, etc.bptato2023-09-091-8/+8
| | | | | | These functions now take a numeric argument to determine how many cells/lines to move. Also, update the default config so e.g. 9j now works.
* layout: simplify preBuildTableRowsbptato2023-09-091-36/+13
| | | | the iterator here was rather pointless
* layout: remove commented out hackbptato2023-09-091-10/+0
| | | | | | Specifically, we used to set the width computed value of table cells manually in the past. It was a hack that never worked very well, and has been unnecessary ever since we switched to SizeConstraints.
* layout: add table rowspanbptato2023-09-092-11/+57
|
* fix compilation on 1.6.14bptato2023-09-091-3/+3
| | | | changing addr semantics strikes again
* buffer: remove url referencebptato2023-09-091-2/+3
| | | | The same reference is already stored in BufferSource as location.
* javascript: fix a GC bugbptato2023-09-092-5/+23
| | | | | | | GC_unref may indirectly call nim_finalize_for_js, which could mess up execution of checkDestroy. I haven't encountered it in refc, but it's definitely present in orc.
* blob: use JSDictbptato2023-09-091-10/+14
|
* tojs: remove JSDictbptato2023-09-091-12/+0
| | | | it's broken anyway, and unused currently
* remove obsolete commentbptato2023-09-091-1/+0
|
* event: use JSDictbptato2023-09-091-20/+18
|
* fetch: use JSDictbptato2023-09-094-46/+139
|
* javascript: add JSDict typebptato2023-09-094-14/+46
| | | | And use that in extern().
* add extern, refactor some term functionsbptato2023-09-096-71/+122
| | | | | | | | | | | * Add an extern() call. Maybe it should be defined on client. It certainly should accept a dictionary instead of the enum type we use now. Perhaps it should return the error code? I'll leave it undocumented until I figure this out. * Refactor enableRawMode, unblockStdin, etc. so that they operate on the term object instead of global state. * Move editor to a separate folder, and factor out runprocess into a different module.
* ouchbptato2023-09-081-1/+1
|
* regex: avoid infinite loopbptato2023-09-081-1/+7
| | | | | A capture size of 0 (e.g. |) no longer sends the regex matcher into an infinite loop.
* dom: align some return values with their webidlbptato2023-09-082-13/+13
| | | | | Certain functions were returning types that do not align with the WebIDL defined in the dom standard.
* Add vi-style numeric prefixes, make gotoLine 1-basedbptato2023-09-083-14/+52
| | | | | | | | * it is now possible to jump to the nth line by typing {n}G * gotoLine is now 1-based, so to go to the first line you would use pager.gotoLine(1) * it is now allowed to return a function from a keybinding (which will be subsequently executed as a regular keybinding)
* container: add separate commands for 0 and ^bptato2023-09-081-0/+9
| | | | | Just as in vi, 0 puts the cursor at the beginning of the current line, and ^ puts the cursor at the position of the first non-blank character.
* url: simplifybptato2023-09-081-26/+10
| | | | | * remove unused parseURL overload * slightly refactor URL ctor and parseURL
* cell: remove old hackbptato2023-09-081-4/+0
| | | | looks like the compiler can now deal with this by itself.
* fetch: allow string input, allow init dictionarybptato2023-09-082-4/+9
|
* buffer.click: implement preventDefaultbptato2023-09-081-8/+16
|
* URL: fix missing searchParams when baseURL is givenbptato2023-09-081-0/+3
| | | | The base.isSome branch was missing the searchParams initialization.
* atob, btoa: handle latin-1 correctlybptato2023-09-081-12/+36
|
* Add btoa, atobbptato2023-09-073-0/+38
|
* toml: complain more on unexpected EOFbptato2023-09-071-2/+3
|
* container: remove strformat dependencybptato2023-09-071-2/+4
|
* container: remove attrsbptato2023-09-071-3/+0
| | | | It was unused; we just set the width and height instead.
* dom: set input type to text if not givenbptato2023-09-071-0/+2
| | | | | | | HTMLInputElement.inputString depends on inputType not being unknown. (Maybe we should move this logic out of the html parser module entirely and just set text as the default value...)
* twtstr: remove some unused procsbptato2023-09-071-22/+0
| | | | | | | * substr for Rune with 1 param: gone, ideally the other should be removed too * clearControls: gone, not used anymore. * split for Rune: gone, not used anymore.
* twtstr: remove toLowerAscii2bptato2023-09-072-23/+10
|
* url: optimizebptato2023-09-071-15/+21
| | | | | | | * get rid of a copy by the initial strip() call * get rid of a copy by an avoidable substr() call Also, replace Letters with AsciiAlpha for consistency's sake.
* url: fix \n, \t not being properly removedbptato2023-09-071-1/+3
| | | | | | For some reason we were only stripping tabs and newlines from the beginning/end of the string. The standard says they should be ignored completely.
* toml: remove unused importbptato2023-09-071-1/+0
|
an class="p">(&brush.font, prevoff->left->text); if(tw > rect.width / 3) tw = rect.width / 3; w += tw + brush.font.height; if(w > rect.width) break; } } static void update_items(char *pattern) { unsigned int plen = strlen(pattern); Item *i, *j; if(!pattern) return; if(!title || *pattern) cmdw = cwidth; else cmdw = twidth; item = j = NULL; nitem = 0; for(i = allitem; i; i=i->next) if(!plen || !strncmp(pattern, i->text, plen)) { if(!j) item = i; else j->right = i; i->left = j; i->right = NULL; j = i; nitem++; } for(i = allitem; i; i=i->next) if(plen && strncmp(pattern, i->text, plen) && strstr(i->text, pattern)) { if(!j) item = i; else j->right = i; i->left = j; i->right = NULL; j = i; nitem++; } curroff = prevoff = nextoff = sel = item; update_offsets(); } /* creates brush structs for brush mode drawing */ static void draw_menu() { unsigned int offx = 0; Item *i; brush.rect = rect; brush.rect.x = 0; brush.rect.y = 0; draw(dpy, &brush, False, 0); /* print command */ if(!title || text[0]) { cmdw = cwidth; if(cmdw && item) brush.rect.width = cmdw; draw(dpy, &brush, False, text); } else { cmdw = twidth; brush.rect.width = cmdw; draw(dpy, &brush, False, title); } offx += brush.rect.width; if(curroff) { brush.rect.x = offx; brush.rect.width = seek; offx += brush.rect.width; draw(dpy, &brush, False, (curroff && curroff->left) ? "<" : 0); /* determine maximum items */ for(i = curroff; i != nextoff; i=i->right) { brush.border = False; brush.rect.x = offx; brush.rect.width = textwidth(&brush.font, i->text); if(brush.rect.width > rect.width / 3) brush.rect.width = rect.width / 3; brush.rect.width += brush.font.height; if(sel == i) { swap((void **)&brush.fg, (void **)&brush.bg); draw(dpy, &brush, True, i->text); swap((void **)&brush.fg, (void **)&brush.bg); } else draw(dpy, &brush, False, i->text); offx += brush.rect.width; } brush.rect.x = rect.width - seek; brush.rect.width = seek; draw(dpy, &brush, False, nextoff ? ">" : 0); } XCopyArea(dpy, brush.drawable, win, brush.gc, 0, 0, rect.width, rect.height, 0, 0); XFlush(dpy); } static void kpress(XKeyEvent * e) { KeySym ksym; char buf[32]; int num, prev_nitem; unsigned int i, len = strlen(text); buf[0] = 0; num = XLookupString(e, buf, sizeof(buf), &ksym, 0); if(IsFunctionKey(ksym) || IsKeypadKey(ksym) || IsMiscFunctionKey(ksym) || IsPFKey(ksym) || IsPrivateKeypadKey(ksym)) return; /* first check if a control mask is omitted */ if(e->state & ControlMask) { switch (ksym) { case XK_H: case XK_h: ksym = XK_BackSpace; break; case XK_I: case XK_i: ksym = XK_Tab; break; case XK_J: case XK_j: ksym = XK_Return; break; case XK_N: case XK_n: ksym = XK_Right; break; case XK_P: case XK_p: ksym = XK_Left; break; case XK_U: case XK_u: text[0] = 0; update_items(text); draw_menu(); return; break; case XK_bracketleft: ksym = XK_Escape; break; default: /* ignore other control sequences */ return; break; } } switch (ksym) { case XK_Left: if(!(sel && sel->left)) return; sel=sel->left; if(sel->right == curroff) { curroff = prevoff; update_offsets(); } break; case XK_Tab: if(!sel) return; strncpy(text, sel->text, sizeof(text)); update_items(text); break; case XK_Right: if(!(sel && sel->right)) return; sel=sel->right; if(sel == nextoff) { curroff = nextoff; update_offsets(); } break; case XK_Return: if(e->state & ShiftMask) { if(text) fprintf(stdout, "%s", text); } else if(sel) fprintf(stdout, "%s", sel->text); else if(text) fprintf(stdout, "%s", text); fflush(stdout); done = True; break; case XK_Escape: ret = 1; done = True; break; case XK_BackSpace: if((i = len)) { prev_nitem = nitem; do { text[--i] = 0; update_items(text); } while(i && nitem && prev_nitem == nitem); update_items(text); } break; default: if(num && !iscntrl((int) buf[0])) { buf[num] = 0; if(len > 0) strncat(text, buf, sizeof(text)); else strncpy(text, buf, sizeof(text)); update_items(text); } } draw_menu(); } static char * read_allitems() { static char *maxname = NULL; char *p, buf[1024]; unsigned int len = 0, max = 0; Item *i, *new; i = 0; while(fgets(buf, sizeof(buf), stdin)) { len = strlen(buf); if (buf[len - 1] == '\n') buf[len - 1] = 0; p = estrdup(buf); if(max < len) { maxname = p; max = len; } new = emalloc(sizeof(Item)); new->next = new->left = new->right = NULL; new->text = p; if(!i) allitem = new; else i->next = new; i = new; } return maxname; } int main(int argc, char *argv[]) { int i; XSetWindowAttributes wa; char *maxname; XEvent ev; /* command line args */ for(i = 1; i < argc; i++) { if (argv[i][0] == '-') switch (argv[i][1]) { case 'v': fprintf(stdout, "%s", version); exit(0); break; case 't': if(++i < argc) title = argv[i]; else usage(); break; default: usage(); break; } else usage(); } dpy = XOpenDisplay(0); if(!dpy) error("gridmenu: cannot open dpy\n"); screen = DefaultScreen(dpy); root = RootWindow(dpy, screen); maxname = read_allitems(); /* grab as early as possible, but after reading all items!!! */ while(XGrabKeyboard(dpy, root, True, GrabModeAsync, GrabModeAsync, CurrentTime) != GrabSuccess) usleep(1000); /* style */ loadcolors(dpy, screen, &brush, BGCOLOR, FGCOLOR, BORDERCOLOR); loadfont(dpy, &brush.font, FONT); wa.override_redirect = 1; wa.background_pixmap = ParentRelative; wa.event_mask = ExposureMask | ButtonPressMask | KeyPressMask; rect.width = DisplayWidth(dpy, screen); rect.height = labelheight(&brush.font); rect.y = DisplayHeight(dpy, screen) - rect.height; rect.x = 0; win = XCreateWindow(dpy, root, rect.x, rect.y, rect.width, rect.height, 0, DefaultDepth(dpy, screen), CopyFromParent, DefaultVisual(dpy, screen), CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa); XDefineCursor(dpy, win, XCreateFontCursor(dpy, XC_xterm)); XFlush(dpy); /* pixmap */ brush.gc = XCreateGC(dpy, root, 0, 0); brush.drawable = XCreatePixmap(dpy, win, rect.width, rect.height, DefaultDepth(dpy, screen)); XFlush(dpy); if(maxname) cwidth = textwidth(&brush.font, maxname) + brush.font.height; if(cwidth > rect.width / 3) cwidth = rect.width / 3; if(title) { twidth = textwidth(&brush.font, title) + brush.font.height; if(twidth > rect.width / 3) twidth = rect.width / 3; } cmdw = title ? twidth : cwidth; text[0] = 0; update_items(text); XMapRaised(dpy, win); draw_menu(); XFlush(dpy); /* main event loop */ while(!XNextEvent(dpy, &ev)) { switch (ev.type) { case KeyPress: kpress(&ev.xkey); break; case Expose: if(ev.xexpose.count == 0) { draw_menu(); } break; default: break; } if(done) break; } XUngrabKeyboard(dpy, CurrentTime); XFreePixmap(dpy, brush.drawable); XFreeGC(dpy, brush.gc); XDestroyWindow(dpy, win); XCloseDisplay(dpy); return ret; }