summaryrefslogtreecommitdiff
path: root/sys/src/cmd/acme
AgeCommit message (Collapse)Author
2022-03-15acme: fix hiding of top windows when loading a dump file (thanks Xiao-Yong)Igor Böhm
When loading an acme dump file that contains a window with only one tag line, there are cases where acme hides that window (i.e. not even its tag is visible). The following commands reproduce the issue: % ed <<EOE 1 i /tmp /lib/font/bit/pelm/unicode.8.font /lib/font/bit/pelm/unicode.8.font 0 f 0 5 175 175 1 5 40 175 1 0 /sys/src/cmd/acme/ Del Snarf Get | Look f 0 4 330 330 3 4 27 330 1 0 /tmp/ Del Snarf Get | Look . ,w /tmp/test.dump Q EOE % window -dx 900 -dy 600 'acme -l /tmp/test.dump' This issue was introduced in commit 47b7dc5ccd77bc247ab15cfab3a7a8f955771c70.
2022-01-04acme: fix window and scrollbar display glitches at bottom fringe of columnIgor Böhm
The following patch fixes acme display glitches at the bottom fringe of columns when adding/moving/resizing windows. Here an example of an easy to reproduce case: • https://invidio.xamh.de/watch?v=iLekQrxycaM …opening acme and resizing a column to the right is all that is needed. The functions winresize(…) and textresize(…) are extended with an additional parameter `fillfringe` to indicate if a window/tag shall fill a potential fringe area that would otherwise remain white. The changes have been inspired by the approach taken in plan9port acme.
2021-11-05acme: fix leaking memory allocated by getenv("font")Igor Böhm
If the font chosen for acme is retrieved via `getenv("font")` its memory is leaked: <snip> if(fontnames[0] == nil) fontnames[0] = getenv("font"); ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > getenv(…) mallocs memory if(fontnames[0] == nil) fontnames[0] = "/lib/font/bit/vga/unicode.font"; if(access(fontnames[0], 0) < 0){ fprint(2, "acme: can't access %s: %r\n", fontnames[0]); exits("font open"); } if(fontnames[1] == nil) fontnames[1] = fontnames[0]; fontnames[0] = estrdup(fontnames[0]); ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > if the `getenv("font")` path was taken above, this assignment > will leak its memory. </snap> The following leak/acid session demonstrates the issue: <snip> cpu% leak -s 212252 src(0x002000cb); // 1 cpu% acid 212252 /proc/212252/text:amd64 plan 9 executable /sys/lib/acid/port /sys/lib/acid/amd64 acid: src(0x002000cb) /sys/src/cmd/acme/acme.c:107 102 fprint(2, "usage: acme [-aib] [-c ncol] [-f font] [-F fixedfont] [-l loadfile | file...]\n"); 103 exits("usage"); 104 }ARGEND 105 106 if(fontnames[0] == nil) >107 fontnames[0] = getenv("font"); 108 if(fontnames[0] == nil) 109 fontnames[0] = "/lib/font/bit/vga/unicode.font"; 110 if(access(fontnames[0], 0) < 0){ 111 fprint(2, "acme: can't access %s: %r\n", fontnames[0]); 112 exits("font open"); acid: </snap> The fix tries to first check if a font has been set via command line options in which case the font string is malloced via estrdup(…). If no font has been selected on the command line getenv("font") is used. If no getenv("font") var is found we malloc a default font via estrdup(…). <snip> if(fontnames[0] != nil) fontnames[0] = estrdup(fontnames[0]); else if((fontnames[0] = getenv("font")) == nil) fontnames[0] = estrdup("/lib/font/bit/vga/unicode.font"); if(access(fontnames[0], 0) < 0){ fprint(2, "acme: can't access %s: %r\n", fontnames[0]); exits("font open"); } if(fontnames[1] == nil) fontnames[1] = fontnames[0]; fontnames[1] = estrdup(fontnames[1]); </snap> This resolves the memory leak reported by leak(1).
2021-11-05acme: fix plumb message leaks (thanks igor)cinap_lenrek
2021-10-05acme: remove superfluous print arguments (patch from plan9port)Igor Böhm
2021-10-06acme: don't let tag button draw over tag border.james palmer
2021-04-14acme: fix border size, autoindent undo: imported from plan9port (thanks jxy)Ori Bernstein
origin: https://github.com/9fans/plan9port/pull/493 https://github.com/9fans/plan9port/pull/489 https://github.com/9fans/plan9port/pull/461
2021-04-02acme: fix suicide *and* resource leak in ecmd.c (thanks igor)cinap_lenrek
To reproduce the suicide try running the following in acme: • 'Edit B <ls lib' by select and middle clicking in a window that is in your $home. There is a very high chance acme will commit suicide like this: <snip> cpu% broke echo kill>/proc/333310/ctl # acme cpu% acid 333310 /proc/333310/text:amd64 plan 9 executable /sys/lib/acid/port /sys/lib/acid/amd64 acid: lstk() edittext(nr=0x31,q=0x0,r=0x45aa10)+0x8 /sys/src/cmd/acme/ecmd.c:135 xfidwrite(x=0x461230)+0x28a /sys/src/cmd/acme/xfid.c:479 w=0x0 qid=0x5 fc=0x461390 t=0x1 nr=0x100000031 r=0x45aa10 eval=0x3100000000 a=0x405621 nb=0x500000001 err=0x419310 q0=0x100000000 tq0=0x80 tq1=0x8000000000 buf=0x41e8d800000000 xfidctl(arg=0x461230)+0x35 /sys/src/cmd/acme/xfid.c:52 x=0x461230 launcheramd64(arg=0x461230,f=0x22357e)+0x10 /sys/src/libthread/amd64.c:11 0xfefefefefefefefe ?file?:0 </snap> The suicide issue is caused by the following chain of events: • /sys/src/cmd/acme/ecmd.c:/^edittext is called at /sys/src/cmd/acme/xfid.c:479 passing nil as its first parameter: <snip> ... case QWeditout: r = fullrunewrite(x, &nr); if(w) err = edittext(w, w->wrselrange.q1, r, nr); else err = edittext(nil, 0, r, nr); ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ... </snap> ...and /sys/src/cmd/acme/ecmd.c:/^edittext dereferences the first parameter that is *nil* at the first statement: <snip> char* edittext(Window *w, int q, Rune *r, int nr) { File *f; f = w->body.file; ^^^^^^^^^^^^^^^^^^^^^ This will crash if 'w' is *nil* switch(editing){ ... </snap> Moving the the derefernce of 'w' into the case where it is needed (see above patch) fixes the suicude. The memory leak is fixed in /sys/src/cmd/acme/ecmd.c:/^filelist. The current implementation of filelist(...) breaks its contract with its caller, thereby leading to a memory leak in /sys/src/cmd/acme/ecmd.c:/^B_cmd and /sys/src/cmd/acme/ecmd.c:/^D_cmd. The contract /sys/src/cmd/acme/ecmd.c:/^filelist seems to have with its callers is that in case of success it fills up a 'collection' that callers can then clear with a call to clearcollection(...). The fix above honours this contract and thereby removes the leak. After you apply the patch the following two tests should succeed: • Execute by select and middle click in a Tag: 'Edit B lib/profile' • Execute by select and middle click in a Tag: 'Edit B <ls lib' The former lead to a resource leak that is now fixed. The latter lead to a suicide that is now fixed by moving the statement that dereferences the parameter to the location where it is needed, which is not the path used in the case of 'Edit B <ls'. Cheers, Igor
2021-02-03acme: fix use after free in warning() call (thanks igor)cinap_lenrek
2020-12-19acme: use global user string variable instead of getuser()cinap_lenrek
2020-12-19acme: use getuser() in fsinit()cinap_lenrek
2020-09-29acme: revert stray changesOri Bernstein
forgot I had local changes when testing, re-revert scrolling.
2020-09-22acme: import changes from plan9port (thanks jxy)Ori Bernstein
Import the following improvements and bugfixes from plan9port: 4650064a acme: scale window bodies on resize, not including tag space d28913a9 acme: save/restore multiline tags in Dump/Load d2df5d6c acme: fix crash in X |cat with multiple windows 3d6e5cb5 acme: preserve window position and selection during Get
2020-08-03mergecinap_lenrek
2020-08-03acme: reverting scroll change, causes continuous scrolling with scrollwheelcinap_lenrek
2020-08-01pre-lib9p servers: fix incorrect Tversion handlingkvik
version(5) says: If the server does not understand the client's version string, it should respond with an Rversion message (not Rerror) with the version string the 7 characters ``unknown''. Pre-lib9p file servers -- all except cwfs(4) -- do return Rerror. lib9p(2) follows the above spec, although ignoring the next part concerning comparison after period-stripping. It assumes an Fcall.version starting with "9P" is correctly formed and returns the only supported version of the protocol, which seems alright. This patch brings pre-lib9p servers in accordance with the spec.
2020-06-11acme: implement position-dependent scroll-wheel scrollingkvik
This brings acme scrolling behaviour in line with that of 9front's rio and sam, where the amount scrolled varies with a vertical position of the pointer within the window, similar to how the scrollbar works. At some point it would be good to implement a line-at-a-time scrolling when the Shift key is pressed, as seen in rio. For this to happen the acme keyboard input needs to be rewritten in terms of /dev/kbd instead of relying on keyboard(2) -- that is, the /dev/cons interface.
2020-06-07acme: add missing logf.ccinap_lenrek
2020-06-06acme: import event log from plan9port (thanks fshahriar)Ori Bernstein
Based off the following 3 commits: 4a3fb87264f8bc03fc62f00ef335056f30d18023 45f8ba54143323f08a21343633764caa59aa3ea3 fdf6ef333705c844bcf3ccf2f93b2773f1a6aa41 Reading /mnt/acme/log reports a log of window create, put, focus, and delete events, as they happen. It blocks until the next event is available. Example log output: 8 new /Users/rsc/foo.go 8 put /Users/rsc/foo.go 8 del /Users/rsc/foo.go This lets acme-aware programs react to file writes, for example compiling code, running a test, or updating an import block.
2020-05-31acme: implement 'scratch' ctl command (thanks Drew DeVault)kvik
The new command marks the target window as a scratch window -- a window whose state cannot be "dirtied" by changes made to its body, therefore avoiding warnings about unsaved changes when deleting the window or exiting acme. Existing examples of scratch windows are error, directory, and guide windows, whose scratchness is set internally. With the new command users and programs alike can create their own scratch windows. This is put to use in acme's own win(1).
2020-05-10acme: add missed error checkskvik
2020-05-07fix typo: mouse->xy, not w->mc.xyOri Bernstein
2020-05-06Reset click count on mouse motion.Ori Bernstein
2020-05-02make bind(2) error handling consistentcinap_lenrek
The mount() and bind() syscalls return -1 on error, and the mountid sequence number on success. The manpage states that the mountid sequence number is a positive integer, but the kernels implementation currently uses a unsigned 32-bit integer and does not guarantee that the mountid will not become negative. Most code just cares about the error, so test for the -1 error value only.
2020-04-25tweak selection criteriaOri Bernstein
grow selection from point of click, not start of selection region. starting at the beginning of the selection region causes the match logic to kick in, which is confusing.
2020-04-25triple click selection in acmeOri Bernstein
see the last 2 commits.
2020-02-13acme(1): fix scrolling when swiping text at the top or bottom of a framespew
2020-01-31fix double free in acme.Ori Bernstein
in acmerrorproc(): sendp(s); free(s); in waitthread(): recv(&err) free(err) We only want waitthread to free.
2020-01-19mergecinap_lenrek
2020-01-19Apply http://www.9paste.net/qrstuv/patch/acme-movetodelmesg/Roberto E. Vargas Caballero
2020-01-19acme: fix off by one in colclose(), make dellist() code consistentcinap_lenrek
2020-01-19acme: Restore call to movetodel() in colcloseRoberto E. Vargas Caballero
2019-12-06fix some acme memory leaksOri Bernstein
(imported from plan9port 7ca1c90109e17dced4b38fbaadea9d2cf39871b7, some tag restoration lines not relevant.)
2019-12-04acme: Apply each -/+ only once (#156)Ori Bernstein
When plumbing an address like `3-`, Acme selects line 1, and similarly `3+` selects line 5. The same problem can be observed for character addresses (`#123+`) but _not_ for ones like `+`, `.+` or `/foo/+`: The problem only occurs when a number is followed by a direction (`-`/`+`). Following along with the example `3-` through `address` (in addr.c): We read `3` into `c` and match the `case` on line 239. The `while` loop on line 242ff reads additional digits into `c` and puts the first non-digit back by decrementing the index `q`. Then we find the range for line 3 on line 251 and continue. On the next iteration, we set `prevc` to the last `c`, but since that part read ahead _into `c`_, `c` is currently the _next_ character we will read, `-`, and now `prevc` is too. Then in the case block (line 210) the condition on line 211 holds and Acme believes that it has read two `-` in sequence and modifies the range to account for the “first” `-`. The “second” `-` gets applied after the loop is done, on line 292. So the general problem is: While reading numbers, Acme reads the next character after the number into `c`. It decrements the counter to ensure it will read it again on the next iteration, but it still uses it to update `prevc`. This change solves the problem by reading digits into `nc` instead. This variable is used to similar effect in the block for directions (line 212) and fills the role of “local `c` that we can safely use to read ahead” nicely. (imported from plan9front a82a8b6368274d77d42f526e379b74e79c137e26)
2019-12-04acme: avoid division by zero when resizing col (#189)Ori Bernstein
To reproduce, create a column with at least two windows and resize acme to have almost zero height. (imported from plan9port commit 76b9347a5fa3a0970527c6ee1b97ef1c714f636b)
2019-12-04acme, sam: handle >1GB files correctlyOri Bernstein
imported from plan9port, edfe3c016fe6ef10c55f7a17aab668214ec21efc
2018-10-20acme: fix fd checks - initialize Window.rdselfd to -1 not 0cinap_lenrek
2018-10-20fix misleading/wrong fd checksBurnZeZ
2018-08-03acme: pass pointer to int type to avoid pointer to int cast warningcinap_lenrek
2018-08-01acme: add spacesindent modespew
2016-11-17cmd: remove a bit of unused stuffftrvxmtrx
2016-07-24make error handling in 9p service loops consistentcinap_lenrek
when we get eof, stop the loop immidiately and do not rely on the read to eventually return an error. when convM2S() fails to decode the message, error out and stop the loop. there is no point in continuing.
2014-12-17acme: allow typing '\n' in window tagsmischief
2014-12-11acme: fix buffer overrun in xfidutfread() and xfidruneread(), cleanupcinap_lenrek
the utf8 buffers b1 where allocated from fbufalloc() which gives us BUFSIZE bytes, but Xfid->count can be bigger than that. so just emalloc() the requested number of bytes. when converting from Runes to utf-8, we have to account for the terminating '\0' byte snprint() places, so fix the maxrune number calculation instead of using BUFSIZE+1 as buffer size.
2014-09-11acme: remove unused #includeBurnZeZ
2014-08-16Fix acme crash: Get D in a new window with D being an existing directoryiru
2014-04-01sam, acme: fix character classes quoting for 21-bit runescinap_lenrek
quote handling was broken with 21-bit runes. nextrec() returned quoted rune as long rune | (Runemax+1) to escape it. with 16-bit runes, storing that long into 16-bit Rune would automatically remove the escaping, but with 21-bit runes, Rune is uint32 so the escaping would remain. we now use (Runemask+1) instead, and mask the escaping off explicitely when storing back to Rune.
2013-11-22acme: fix arrow key oddity (thanks mark van atten and erik)cinap_lenrek
from 9atom/acmearrowfun patch: reported by mark van atten In Plan 9 acme, if you type {} then go back and type text between the brackets {Curiouser and curiouser!} the right arrow is blocked when you want to go over the closing bracket to continue typing to its right. (If you first go to the left, and then back to the right, it works.) Same for the other brackets: [ ], ( ), < >. noted that brackets are not necessary. same behavior with any character. fix is to textcommit before moving.
2013-10-20acme: attempt to fix tag lines collapsing to zero height on window move ↵cinap_lenrek
(issue 189) we'r getting a rectangle taller than a single line from coladd() which causes textresize() to collapse the tag text to zero height. should probably fix coladd() instead.
2013-09-11acme: use threadexitsall() to tear down mouse and keyboard procs on errorcinap_lenrek