add acme-lsp helpers and Toolbox, use COLOR_EMPTY more and dont lock windows when updating cursor (possibly dangerous, we'll see); v9001-a04

This commit is contained in:
Iris Lightshard 2022-02-25 00:20:04 -07:00
parent 2b1cefce23
commit 232d3e06f6
Signed by: nilix
GPG key ID: 3B7FBC22144E6398
25 changed files with 107 additions and 34 deletions

View file

@ -44,9 +44,29 @@ Users unfamiliar with `acme` in general should check the following resources:
After building, run `./install.sh`; If run as a regular user, it will install to `~/bin/9`; if run as root, it will overwrite the systemwide `acme` in `$PLAN9/bin` After building, run `./install.sh`; If run as a regular user, it will install to `~/bin/9`; if run as root, it will overwrite the systemwide `acme` in `$PLAN9/bin`
## TODO ## helpers
- [ ] compile helpers The `scripts` directory contains some helpers, mostly just shortcuts for [acme-lsp](https://github.com/fhs/acme-lsp). Copy them to your `$PATH` and let 'em rip.
Of particular interest:
- `agols`: pass a colon-separated list of workspaces to start `acme-lsp` for go development
- `atsls`: run without arguments to start `acme-lsp` for javascript/typescript development
- `acls`: run without arguments to start `acme-lsp` for C/C++ development
For `acls` to work right with plan9port C stuff you will need to add your `$PLAN9/include` directory to the compile flags in either the project `.clangd` file or your `~/.config/clangd/config.yaml`:
```
CompileFlags:
Add:
- "-I/usr/lib/plan9/include"
```
See also:
- [plumbing rules](https://nilfm.cc/git/dotfiles/tree/plumbing) - my plumbing rules, includes opening headers by right-click on the filename in an include directive
The `Toolbox` file contains a compilation of `sam` command language (`Edit` scripts) that may be useful.
## thanks ## thanks

8
Toolbox Normal file
View file

@ -0,0 +1,8 @@
# Compiled Edit scripts
[ Edit 1,$-1d ] # clear win
[ Edit x/^[ ]*/ a/# / ] # comment (replace # with comment prefix)
[ Edit x/^[ ]*# ?/ x/# ?/d ] # uncomment (replace # with comment prefix)
[ Edit s/^[ ]//g ] # unindent
[ Edit s/^/ /g ] # indent
[ Edit x/[^\n]\n[^\n]/ s/\n/ / ] # join lines

13
acme.c
View file

@ -43,7 +43,7 @@ Rune snarfrune[NSnarf + 1];
char* fontnames[2] = {PRIMARY_FONT, SECONDARY_FONT}; char* fontnames[2] = {PRIMARY_FONT, SECONDARY_FONT};
char version[] = "acme9k v9001-a03"; char version[] = "acme9k v9001-a04";
Command* command; Command* command;
@ -512,7 +512,7 @@ void mousethread(void* v) {
static Alt alts[NMALT + 1]; static Alt alts[NMALT + 1];
/* make sure we don't recklessly refresh the ticks */ /* make sure we don't recklessly refresh the ticks */
Text* oldbarttext; Text* oldbarttext = nil;
USED(v); USED(v);
threadsetname("mousethread"); threadsetname("mousethread");
@ -676,8 +676,11 @@ void mousethread(void* v) {
} }
Continue: Continue:
/* won't refresh ticks if scrolling didn't change the active frame! */ /* won't refresh ticks if scrolling didn't change the active frame! */
if (oldbarttext != barttext && (m.buttons) && t) { if (
textsettick(t, t->row); (oldbarttext != barttext && (m.buttons & (8 | 16)) ||
m.buttons & (1 | 2 | 4)) &&
t) {
textsettick(barttext, &row);
} }
qunlock(&row.lk); qunlock(&row.lk);
break; break;
@ -988,7 +991,7 @@ Cursor2 boxcursor2 = {
0xFF, 0xFF, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}; 0xFF, 0xFF, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}};
void iconinit(void) { void iconinit(void) {
Rectangle r, r1; Rectangle r;
Image* tmp; Image* tmp;
if (tagcols[BACK] == nil) { if (tagcols[BACK] == nil) {

23
cols.c
View file

@ -11,6 +11,7 @@
#include <libsec.h> #include <libsec.h>
#include "dat.h" #include "dat.h"
#include "fns.h" #include "fns.h"
#include "config.h"
static Rune Lheader[] = {'N', 'e', 'w', ' ', 'C', 'u', 't', ' ', 'P', 'a', static Rune Lheader[] = {'N', 'e', 'w', ' ', 'C', 'u', 't', ' ', 'P', 'a',
's', 't', 'e', ' ', 'S', 'n', 'a', 'r', 'f', ' ', 's', 't', 'e', ' ', 'S', 'n', 'a', 'r', 'f', ' ',
@ -24,7 +25,7 @@ void colinit(Column* c, Rectangle r) {
draw( draw(
screen, screen,
r, r,
allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, 0x222222FF), allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, COLOR_EMPTY),
nil, nil,
ZP); ZP);
c->r = r; c->r = r;
@ -42,7 +43,7 @@ void colinit(Column* c, Rectangle r) {
draw( draw(
screen, screen,
r1, r1,
allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, 0x222222FF), allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, COLOR_EMPTY),
nil, nil,
ZP); ZP);
textinsert(t, 0, Lheader, 38, TRUE); textinsert(t, 0, Lheader, 38, TRUE);
@ -124,7 +125,7 @@ Window* coladd(Column* c, Window* w, Window* clone, int y) {
draw( draw(
screen, screen,
r1, r1,
allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, 0x222222FF), allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, COLOR_EMPTY),
nil, nil,
ZP); ZP);
@ -192,7 +193,7 @@ Found:
draw( draw(
screen, screen,
r, r,
allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, 0x222222FF), allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, COLOR_EMPTY),
nil, nil,
ZP); ZP);
return; return;
@ -253,7 +254,7 @@ void colresize(Column* c, Rectangle r) {
draw( draw(
screen, screen,
r1, r1,
allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, 0x222222FF), allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, COLOR_EMPTY),
nil, nil,
ZP); ZP);
r1.max.y = r.max.y; r1.max.y = r.max.y;
@ -274,7 +275,7 @@ void colresize(Column* c, Rectangle r) {
draw( draw(
screen, screen,
r2, r2,
allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, 0x222222FF), allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, COLOR_EMPTY),
nil, nil,
ZP); ZP);
r1.min.y = r2.max.y; r1.min.y = r2.max.y;
@ -330,7 +331,7 @@ void colsort(Column* c) {
draw( draw(
screen, screen,
r1, r1,
allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, 0x222222FF), allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, COLOR_EMPTY),
nil, nil,
ZP); ZP);
r.min.y = r1.max.y; r.min.y = r1.max.y;
@ -431,7 +432,7 @@ Pack:
draw( draw(
screen, screen,
r, r,
allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, 0x222222FF), allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, COLOR_EMPTY),
nil, nil,
ZP); ZP);
y1 = r.max.y; y1 = r.max.y;
@ -463,7 +464,7 @@ Pack:
draw( draw(
screen, screen,
r, r,
allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, 0x222222FF), allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, COLOR_EMPTY),
nil, nil,
ZP); ZP);
for (j = i + 1; j < c->nw; j++) for (j = i + 1; j < c->nw; j++)
@ -485,7 +486,7 @@ Pack:
draw( draw(
screen, screen,
r, r,
allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, 0x222222FF), allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, COLOR_EMPTY),
nil, nil,
ZP); ZP);
y1 = r.max.y; y1 = r.max.y;
@ -572,7 +573,7 @@ Found:
draw( draw(
screen, screen,
r, r,
allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, 0x222222FF), allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, COLOR_EMPTY),
nil, nil,
ZP); ZP);
r.min.y = r.max.y; r.min.y = r.max.y;

View file

@ -25,7 +25,7 @@
/* button colors: dirty file (mod) indicator and column handles */ /* button colors: dirty file (mod) indicator and column handles */
#define COLOR_BTN_MD 0x1F9B92FF #define COLOR_BTN_MD 0x1F9B92FF
#define COLOR_BTN_CO 0x586E75FF #define COLOR_BTN_CO 0x002B36FF
/* button 2 and 3 selection colors */ /* button 2 and 3 selection colors */

3
look.c
View file

@ -845,10 +845,11 @@ Window* openfile(Text* t, Expand* e) {
textshow(t, r.q0, r.q1, 1); textshow(t, r.q0, r.q1, 1);
winsettag(t->w); winsettag(t->w);
seltext = t; seltext = t;
if (e->jump) if (e->jump) {
moveto( moveto(
mousectl, mousectl,
addpt(frptofchar(&t->fr, t->fr.p0), Pt(4, font->height - 4))); addpt(frptofchar(&t->fr, t->fr.p0), Pt(4, font->height - 4)));
}
return w; return w;
} }

25
rows.c
View file

@ -12,6 +12,7 @@
#include <libsec.h> #include <libsec.h>
#include "dat.h" #include "dat.h"
#include "fns.h" #include "fns.h"
#include "config.h"
static Rune Lcolhdr[] = {'N', 'e', 'w', 'c', 'o', 'l', ' ', 'K', 'i', 'l', static Rune Lcolhdr[] = {'N', 'e', 'w', 'c', 'o', 'l', ' ', 'K', 'i', 'l',
'l', ' ', 'P', 'u', 't', 'a', 'l', 'l', ' ', 'D', 'l', ' ', 'P', 'u', 't', 'a', 'l', 'l', ' ', 'D',
@ -24,7 +25,7 @@ void rowinit(Row* row, Rectangle r) {
draw( draw(
screen, screen,
r, r,
allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, 0x222222FF), allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, COLOR_EMPTY),
nil, nil,
ZP); ZP);
row->r = r; row->r = r;
@ -48,7 +49,7 @@ void rowinit(Row* row, Rectangle r) {
draw( draw(
screen, screen,
r1, r1,
allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, 0x222222FF), allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, COLOR_EMPTY),
nil, nil,
ZP); ZP);
textinsert(t, 0, Lcolhdr, 29, TRUE); textinsert(t, 0, Lcolhdr, 29, TRUE);
@ -82,7 +83,7 @@ Column* rowadd(Row* row, Column* c, int x) {
draw( draw(
screen, screen,
r, r,
allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, 0x222222FF), allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, COLOR_EMPTY),
nil, nil,
ZP); ZP);
r1 = r; r1 = r;
@ -95,7 +96,7 @@ Column* rowadd(Row* row, Column* c, int x) {
draw( draw(
screen, screen,
r1, r1,
allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, 0x222222FF), allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, COLOR_EMPTY),
nil, nil,
ZP); ZP);
r.min.x = r1.max.x; r.min.x = r1.max.x;
@ -132,7 +133,7 @@ void rowresize(Row* row, Rectangle r) {
draw( draw(
screen, screen,
r1, r1,
allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, 0x222222FF), allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, COLOR_EMPTY),
nil, nil,
ZP); ZP);
r.min.y = r1.max.y; r.min.y = r1.max.y;
@ -152,7 +153,7 @@ void rowresize(Row* row, Rectangle r) {
draw( draw(
screen, screen,
r2, r2,
allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, 0x222222FF), allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, COLOR_EMPTY),
nil, nil,
ZP); ZP);
r1.min.x = r2.max.x; r1.min.x = r2.max.x;
@ -218,7 +219,7 @@ Found:
draw( draw(
screen, screen,
r, r,
allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, 0x222222FF), allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, COLOR_EMPTY),
nil, nil,
ZP); ZP);
r.max.x = p.x; r.max.x = p.x;
@ -230,7 +231,7 @@ Found:
draw( draw(
screen, screen,
r, r,
allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, 0x222222FF), allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, COLOR_EMPTY),
nil, nil,
ZP); ZP);
r.min.x = r.max.x; r.min.x = r.max.x;
@ -258,7 +259,7 @@ Found:
draw( draw(
screen, screen,
r, r,
allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, 0x222222FF), allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, COLOR_EMPTY),
nil, nil,
ZP); ZP);
return; return;
@ -274,7 +275,7 @@ Found:
draw( draw(
screen, screen,
r, r,
allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, 0x222222FF), allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, COLOR_EMPTY),
nil, nil,
ZP); ZP);
colresize(c, r); colresize(c, r);
@ -633,7 +634,7 @@ int rowload(Row* row, char* file, int initing) {
draw( draw(
screen, screen,
Rpt(r1.min, r2.max), Rpt(r1.min, r2.max),
allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, 0x222222FF), allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, COLOR_EMPTY),
nil, nil,
ZP); ZP);
colresize(c1, r1); colresize(c1, r1);
@ -643,7 +644,7 @@ int rowload(Row* row, char* file, int initing) {
draw( draw(
screen, screen,
r2, r2,
allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, 0x222222FF), allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, COLOR_EMPTY),
nil, nil,
ZP); ZP);
} }

2
scripts/Lassist Executable file
View file

@ -0,0 +1,2 @@
#!/bin/sh
exec L assist

2
scripts/Lcomp Executable file
View file

@ -0,0 +1,2 @@
#!/bin/sh
exec L comp

2
scripts/Ldef Executable file
View file

@ -0,0 +1,2 @@
#!/bin/sh
exec L def

2
scripts/Lfmt Executable file
View file

@ -0,0 +1,2 @@
#!/bin/sh
exec L fmt

2
scripts/Lhov Executable file
View file

@ -0,0 +1,2 @@
#!/bin/sh
exec L hov

2
scripts/Limpls Executable file
View file

@ -0,0 +1,2 @@
#!/bin/sh
exec L impls

2
scripts/Lrefs Executable file
View file

@ -0,0 +1,2 @@
#!/bin/sh
exec L refs

2
scripts/Lrn Executable file
View file

@ -0,0 +1,2 @@
#!/bin/sh
exec L rn

2
scripts/Lsig Executable file
View file

@ -0,0 +1,2 @@
#!/bin/sh
exec L sig

2
scripts/Lsyms Executable file
View file

@ -0,0 +1,2 @@
#!/bin/sh
exec L syms

2
scripts/Ltype Executable file
View file

@ -0,0 +1,2 @@
#!/bin/sh
exec L type

2
scripts/Lws Executable file
View file

@ -0,0 +1,2 @@
#!/bin/sh
exec L ws

2
scripts/Lws+ Executable file
View file

@ -0,0 +1,2 @@
#!/bin/sh
exec L ws+

2
scripts/Lws- Executable file
View file

@ -0,0 +1,2 @@
#!/bin/sh
exec L ws-

3
scripts/acls Executable file
View file

@ -0,0 +1,3 @@
#!/bin/sh
export CFLAGS="-I${PLAN9}/include"
exec acme-lsp -server '(\.c)|(\.h)|(\.cc)|(\.hh)|(\.cpp)|(\.hpp)$:clangd -log=error --background-index --limit-results=500 --completion-style=bundled'

2
scripts/agols Executable file
View file

@ -0,0 +1,2 @@
#!/bin/sh
exec acme-lsp -server '([/\\]go\.mod)|([/\\]go\.sum)|(\.go)$:gopls serve' -workspaces $@

2
scripts/atsls Executable file
View file

@ -0,0 +1,2 @@
#!/bin/sh
exec acme-lsp -server '(\.ts)|(\.js)|(\.jsx)|(\.tsx)$:typescript-language-server --stdio'

4
text.c
View file

@ -59,10 +59,14 @@ void textsettick(Text* t, Row* r) {
_textsettick(t, &cptr->tag); _textsettick(t, &cptr->tag);
for (wcnt = 0; wcnt < cptr->nw; wcnt++) { for (wcnt = 0; wcnt < cptr->nw; wcnt++) {
wptr = cptr->w[wcnt]; wptr = cptr->w[wcnt];
/*if (!wptr->isdir) {
winlock(wptr, 'M'); winlock(wptr, 'M');
}*/
_textsettick(t, &wptr->tag); _textsettick(t, &wptr->tag);
_textsettick(t, &wptr->body); _textsettick(t, &wptr->body);
/*if (!wptr->isdir) {
winunlock(wptr); winunlock(wptr);
}*/
} }
} }
/* force redraw to refresh all ticks; /* force redraw to refresh all ticks;