st

st fork
git clone git://git.rr3.xyz/st
Log | Files | Refs | README | LICENSE

commit 04b106c5f0e37cc1b74fb7adfb6429647f4eaf39
parent 16b24eac12ba4a920a5cdbaa76942a2167956f92
Author: robert <robertrussell.72001@gmail.com>
Date:   Wed, 29 Dec 2021 19:41:14 -0800

Change multiline comment style

Diffstat:
Mst.c | 101+++++++++++++++++++++++++++----------------------------------------------------
Mx.c | 96++++++++++++++++++++++++++-----------------------------------------------------
2 files changed, 65 insertions(+), 132 deletions(-)

diff --git a/st.c b/st.c @@ -97,13 +97,11 @@ typedef struct { int mode; int type; int snap; - /* - * Selection variables: + /* Selection variables: * nb – normalized coordinates of the beginning of the selection * ne – normalized coordinates of the end of the selection * ob – original coordinates of the beginning of the selection - * oe – original coordinates of the end of the selection - */ + * oe – original coordinates of the end of the selection */ struct { int x, y; } nb, ne, ob, oe; @@ -278,7 +276,8 @@ selextend(int col, int row, int type, int done) selnormalize(); sel.type = type; - if (oldey != sel.oe.y || oldex != sel.oe.x || oldtype != sel.type || sel.mode == SEL_EMPTY) + if (oldey != sel.oe.y || oldex != sel.oe.x || oldtype != sel.type + || sel.mode == SEL_EMPTY) tsetdirt(MIN(sel.nb.y, oldsby), MAX(sel.ne.y, oldsey)); sel.mode = done ? SEL_IDLE : SEL_READY; @@ -337,10 +336,8 @@ selsnap(int *x, int *y, int direction) switch (sel.snap) { case SNAP_WORD: - /* - * Snap around if the word wraps around at the end or - * beginning of a line. - */ + /* Snap around if the word wraps around at the end or + * beginning of a line. */ prevgp = &term.line[*y][*x]; prevdelim = ISDELIM(prevgp->u); for (;;) { @@ -376,11 +373,9 @@ selsnap(int *x, int *y, int direction) } break; case SNAP_LINE: - /* - * Snap around if the the previous line or the current one + /* Snap around if the the previous line or the current one * has set ATTR_WRAP at its end. Then the whole next or - * previous line will be selected. - */ + * previous line will be selected. */ *x = (direction < 0) ? 0 : term.col - 1; if (direction < 0) { for (; *y > 0; *y += direction) { @@ -439,15 +434,13 @@ getsel(void) ptr += utf8enc(gp->u, ptr); } - /* - * Copy and pasting of line endings is inconsistent + /* Copy and pasting of line endings is inconsistent * in the inconsistent terminal and GUI world. * The best solution seems like to produce '\n' when * something is copied from st and convert '\n' to * '\r', when something to be pasted is received by * st. - * FIXME: Fix the computer world. - */ + * FIXME: Fix the computer world. */ if ((y < sel.ne.y || lastx >= linelen) && (!(last->mode & ATTR_WRAP) || sel.type == SEL_RECTANGULAR)) *ptr++ = '\n'; @@ -683,12 +676,10 @@ ttywriteraw(const char *s, size_t n) ssize_t r; size_t lim = 256; - /* - * Remember that we are using a pty, which might be a modem line. + /* Remember that we are using a pty, which might be a modem line. * Writing too much will clog the line. That's why we are doing this * dance. - * FIXME: Migrate the world to Plan 9. - */ + * FIXME: Migrate the world to Plan 9. */ while (n > 0) { FD_ZERO(&wfd); FD_ZERO(&rfd); @@ -702,19 +693,15 @@ ttywriteraw(const char *s, size_t n) die("select failed: %s\n", strerror(errno)); } if (FD_ISSET(cmdfd, &wfd)) { - /* - * Only write the bytes written by ttywrite() or the + /* Only write the bytes written by ttywrite() or the * default of 256. This seems to be a reasonable value - * for a serial line. Bigger values might clog the I/O. - */ + * for a serial line. Bigger values might clog the I/O. */ if ((r = write(cmdfd, s, (n < lim)? n : lim)) < 0) goto write_error; if (r < n) { - /* - * We weren't able to write out everything. + /* We weren't able to write out everything. * This means the buffer is getting full - * again. Empty it. - */ + * again. Empty it. */ if (n < lim) lim = ttyread(); n -= r; @@ -1003,9 +990,7 @@ tsetchar(Rune u, const Glyph *attr, int x, int y) "│", "≤", "≥", "π", "≠", "£", "·", /* x - ~ */ }; - /* - * The table is proudly stolen from rxvt. - */ + /* The table is proudly stolen from rxvt. */ if (term.trantbl[term.charset] == CS_GRAPHIC0 && BETWEEN(u, 0x41, 0x7e) && vt100_0[u - 0x41]) utf8dec(vt100_0[u - 0x41], &u, UTF_SIZ); @@ -1694,10 +1679,8 @@ strhandle(void) fprintf(stderr, "erresc: invalid color j=%d, p=%s\n", j, p ? p : "(null)"); } else { - /* - * TODO if defaultbg color is changed, borders - * are dirty - */ + /* TODO if defaultbg color is changed, borders + * are dirty */ redraw(); } return; @@ -2004,10 +1987,8 @@ tcontrolcode(uchar ascii) term.esc &= ~(ESC_STR_END|ESC_STR); } -/* - * returns 1 when the sequence is finished and it hasn't to read - * more characters for this sequence, otherwise 0 - */ +/* returns 1 when the sequence is finished and it hasn't to read + * more characters for this sequence, otherwise 0 */ int eschandle(uchar ascii) { @@ -2112,12 +2093,10 @@ tputc(Rune u) if (IS_SET(MODE_PRINT)) tprinter(c, len); - /* - * STR sequence must be checked before anything else + /* STR sequence must be checked before anything else * because it uses all following characters until it * receives a ESC, a SUB, a ST or any other C1 control - * character. - */ + * character. */ if (term.esc & ESC_STR) { if (u == '\a' || u == 030 || u == 032 || u == 033 || ISCONTROLC1(u)) { @@ -2127,19 +2106,15 @@ tputc(Rune u) } if (strescseq.len+len >= strescseq.siz) { - /* - * Here is a bug in terminals. If the user never sends + /* Here is a bug in terminals. If the user never sends * some code to stop the str or esc command, then st * will stop responding. But this is better than * silently failing with unknown characters. At least * then users will report back. * - * In the case users ever get fixed, here is the code: - */ - /* - * term.esc = 0; - * strhandle(); - */ + * In the case users ever get fixed, here is the code: */ + /* term.esc = 0; + * strhandle(); */ if (strescseq.siz > (SIZE_MAX - UTF_SIZ) / 2) return; strescseq.siz *= 2; @@ -2152,16 +2127,12 @@ tputc(Rune u) } check_control_code: - /* - * Actions of control codes must be performed as soon they arrive + /* Actions of control codes must be performed as soon they arrive * because they can be embedded inside a control sequence, and - * they must not cause conflicts with sequences. - */ + * they must not cause conflicts with sequences. */ if (control) { tcontrolcode(u); - /* - * control codes are not shown ever - */ + /* control codes are not shown ever */ if (!term.esc) term.lastc = 0; return; @@ -2188,10 +2159,8 @@ check_control_code: /* sequence already finished */ } term.esc = 0; - /* - * All characters which form part of a sequence are not - * printed - */ + /* All characters which form part of a sequence are not + * printed */ return; } if (selected(term.c.x, term.c.y)) @@ -2276,11 +2245,9 @@ tresize(int col, int row) return; } - /* - * slide screen to keep cursor where we expect it - + /* slide screen to keep cursor where we expect it - * tscrollup would work here, but we can optimize to - * memmove because we're freeing the earlier lines - */ + * memmove because we're freeing the earlier lines */ for (i = 0; i <= term.c.y - row; i++) { free(term.line[i]); free(term.alt[i]); diff --git a/x.c b/x.c @@ -163,16 +163,12 @@ static void (*handler[LASTEvent])(XEvent *) = { [MotionNotify] = bmotion, [ButtonPress] = bpress, [ButtonRelease] = brelease, -/* - * Uncomment if you want the selection to disappear when you select something - * different in another window. - */ +/* Uncomment if you want the selection to disappear when you select something + * different in another window. */ /* [SelectionClear] = selclear_, */ [SelectionNotify] = selnotify, -/* - * PropertyNotify is only turned on when there is some INCR transfer happening - * for the selection retrieval. - */ +/* PropertyNotify is only turned on when there is some INCR transfer happening + * for the selection retrieval. */ [PropertyNotify] = propnotify, [SelectionRequest] = selrequest, }; @@ -486,41 +482,33 @@ selnotify(XEvent *e) } if (e->type == PropertyNotify && nitems == 0 && rem == 0) { - /* - * If there is some PropertyNotify with no data, then + /* If there is some PropertyNotify with no data, then * this is the signal of the selection owner that all * data has been transferred. We won't need to receive - * PropertyNotify events anymore. - */ + * PropertyNotify events anymore. */ MODBIT(xw.attrs.event_mask, 0, PropertyChangeMask); XChangeWindowAttributes(xw.dpy, xw.win, CWEventMask, &xw.attrs); } if (type == incratom) { - /* - * Activate the PropertyNotify events so we receive + /* Activate the PropertyNotify events so we receive * when the selection owner does send us the next - * chunk of data. - */ + * chunk of data. */ MODBIT(xw.attrs.event_mask, 1, PropertyChangeMask); XChangeWindowAttributes(xw.dpy, xw.win, CWEventMask, &xw.attrs); - /* - * Deleting the property is the transfer start signal. - */ + /* Deleting the property is the transfer start signal. */ XDeleteProperty(xw.dpy, xw.win, (int)property); continue; } - /* - * As seen in getsel: + /* As seen in getsel: * Line endings are inconsistent in the terminal and GUI world * copy and pasting. When receiving some selection data, * replace all '\n' with '\r'. - * FIXME: Fix the computer world. - */ + * FIXME: Fix the computer world. */ repl = data; last = data + nitems * format / 8; while ((repl = memchr(repl, '\n', last - repl))) { @@ -537,10 +525,8 @@ selnotify(XEvent *e) ofs += nitems * format / 32; } while (rem > 0); - /* - * Deleting the property again tells the selection owner to send the - * next data chunk in the property. - */ + /* Deleting the property again tells the selection owner to send the + * next data chunk in the property. */ XDeleteProperty(xw.dpy, xw.win, (int)property); } @@ -579,10 +565,8 @@ selrequest(XEvent *e) (uchar *) &string, 1); xev.property = xsre->property; } else if (xsre->target == xsel.xtarget || xsre->target == XA_STRING) { - /* - * xith XA_STRING non ascii characters may be incorrect in the - * requestor. It is not our problem, use utf8. - */ + /* xith XA_STRING non ascii characters may be incorrect in the + * requestor. It is not our problem, use utf8. */ clipboard = XInternAtom(xw.dpy, "CLIPBOARD", 0); if (xsre->selection == XA_PRIMARY) { seltext = xsel.primary; @@ -750,9 +734,7 @@ xsetcolorname(int x, const char *name) return 0; } -/* - * Absolute coordinates. - */ +/* Absolute coordinates. */ void xclear(int x1, int y1, int x2, int y2) { @@ -821,11 +803,9 @@ xloadfont(Font *f, FcPattern *pattern) XGlyphInfo extents; int wantattr, haveattr; - /* - * Manually configure instead of calling XftMatchFont + /* Manually configure instead of calling XftMatchFont * so that we can use the configured pattern for - * "missing glyph" lookups. - */ + * "missing glyph" lookups. */ configured = FcPatternDuplicate(pattern); if (!configured) return 1; @@ -847,10 +827,8 @@ xloadfont(Font *f, FcPattern *pattern) if ((XftPatternGetInteger(pattern, "slant", 0, &wantattr) == XftResultMatch)) { - /* - * Check if xft was unable to find a font with the appropriate - * slant but gave us one anyway. Try to mitigate. - */ + /* Check if xft was unable to find a font with the appropriate + * slant but gave us one anyway. Try to mitigate. */ if ((XftPatternGetInteger(f->match->pattern, "slant", 0, &haveattr) != XftResultMatch) || haveattr < wantattr) { f->badslant = 1; @@ -912,10 +890,8 @@ xloadfonts(const char *fontstr, double fontsize) FcResultMatch) { usedfontsize = -1; } else { - /* - * Default font size is 12, if none given. This is to - * have a known usedfontsize value. - */ + /* Default font size is 12, if none given. This is to + * have a known usedfontsize value. */ FcPatternAddDouble(pattern, FC_PIXEL_SIZE, 12); usedfontsize = 12; } @@ -1220,13 +1196,11 @@ xmakeglyphfontspecs(XftGlyphFontSpec *specs, const Glyph *glyphs, int len, int x 1, 0, &fcres); fcsets[0] = font->set; - /* - * Nothing was found in the cache. Now use + /* Nothing was found in the cache. Now use * some dozen of Fontconfig calls to get the * font for one single character. * - * Xft and fontconfig are design failures. - */ + * Xft and fontconfig are design failures. */ fcpattern = FcPatternDuplicate(font->pattern); fccharset = FcCharSetCreate(); @@ -1434,9 +1408,7 @@ xdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og) if (IS_SET(MODE_HIDE)) return; - /* - * Select the right color for the right mode. - */ + /* Select the right color for the right mode. */ g.mode &= ATTR_BOLD|ATTR_ITALIC|ATTR_UNDERLINE|ATTR_STRUCK|ATTR_WIDE; if (IS_SET(MODE_REVERSE)) { @@ -1793,10 +1765,8 @@ krelease(XEvent *e) void cmessage(XEvent *e) { - /* - * See xembed specs - * http://standards.freedesktop.org/xembed-spec/xembed-spec-latest.html - */ + /* See xembed specs + * http://standards.freedesktop.org/xembed-spec/xembed-spec-latest.html */ if (e->xclient.message_type == xw.xembed && e->xclient.format == 32) { if (e->xclient.data.l[1] == XEMBED_FOCUS_IN) { win.mode |= MODE_FOCUSED; @@ -1832,11 +1802,9 @@ run(void) /* Waiting for window mapping */ do { XNextEvent(xw.dpy, &ev); - /* - * This XFilterEvent call is required because of XOpenIM. It + /* This XFilterEvent call is required because of XOpenIM. It * does filter out the key event and some client message for - * the input method too. - */ + * the input method too. */ if (XFilterEvent(&ev, None)) continue; if (ev.type == ConfigureNotify) { @@ -1880,8 +1848,7 @@ run(void) (handler[ev.type])(&ev); } - /* - * To reduce flicker and tearing, when new content or event + /* To reduce flicker and tearing, when new content or event * triggers drawing, we first wait a bit to ensure we got * everything, and if nothing new arrives - we draw. * We start with trying to wait minlatency ms. If more content @@ -1889,8 +1856,7 @@ run(void) * and eventually draw even without idle after maxlatency ms. * Typically this results in low latency while interacting, * maximum latency intervals during `cat huge.txt`, and perfect - * sync with periodic updates from animations/key-repeats/etc. - */ + * sync with periodic updates from animations/key-repeats/etc. */ if (FD_ISSET(ttyfd, &rfd) || xev) { if (!drawing) { trigger = now;