[hackers] [scroll] Fix GNU getop || Jochen Sprickerhof
commit a0db4efd2e01b0458fe1f0724bff0b4cfc42c35c Author: Jochen Sprickerhof AuthorDate: Fri Apr 24 00:15:54 2020 +0200 Commit: Jochen Sprickerhof CommitDate: Fri Apr 24 00:15:54 2020 +0200 Fix GNU getop diff --git a/up.sh b/up.sh index 95ae93c..a730f8c 100755 --- a/up.sh +++ b/up.sh @@ -1,6 +1,7 @@ #!/bin/sh set -eu +export POSIXLY_CORRECT=1 jot 50 > tmp.log
[hackers] [scroll] swap x and y to more logical || Jan Klemkow
commit 8fa398224de3b1ba6b87968ae428a48fbb25a24c Author: Jan Klemkow AuthorDate: Fri Apr 24 00:08:53 2020 +0200 Commit: Jan Klemkow CommitDate: Fri Apr 24 00:09:17 2020 +0200 swap x and y to more logical diff --git a/scroll.c b/scroll.c index f8de6c0..ef9d5cd 100644 --- a/scroll.c +++ b/scroll.c @@ -230,7 +230,7 @@ getcursorposition(int *x, int *y) if ((n = read(STDIN_FILENO, input, sizeof(input)-1)) == -1) die("reading cursor position"); input[n] = '\0'; - } while (sscanf(input, "\033[%d;%dR", x, y) != 2); + } while (sscanf(input, "\033[%d;%dR", y, x) != 2); if (*x <= 0 || *y <= 0) die("invalid cursor position: x=%d y=%d", *x, *y); @@ -258,7 +258,7 @@ redraw() /* wind back bottom pointer by shown history */ for (; bottom != NULL && TAILQ_NEXT(bottom, entries) != NULL && - rows < x - 2; rows++) + rows < y - 2; rows++) bottom = TAILQ_NEXT(bottom, entries); if (rows == 0) @@ -299,10 +299,10 @@ scrollup(int n) /* wind back scrollend pointer by one page plus n */ for (; TAILQ_NEXT(scrollend, entries) != NULL && - rows < x + n; rows++) + rows < y + n; rows++) scrollend = TAILQ_NEXT(scrollend, entries); - rows -= x; + rows -= y; if (rows <= 0) return; @@ -319,19 +319,19 @@ scrollup(int n) write(STDOUT_FILENO, scrollend->buf + 1, scrollend->size - 1); else write(STDOUT_FILENO, scrollend->buf, scrollend->size); - if (x + n >= ws.ws_row) + if (y + n >= ws.ws_row) bottom = TAILQ_NEXT(bottom, entries); /* print rows lines and move bottom forward to the new screen bottom */ for (; rows > 1; rows--) { scrollend = TAILQ_PREV(scrollend, tailhead, entries); - if (x + n >= ws.ws_row) + if (y + n >= ws.ws_row) bottom = TAILQ_NEXT(bottom, entries); write(STDOUT_FILENO, scrollend->buf, scrollend->size); } /* move cursor from line n to the old bottom position */ - if (x + n < ws.ws_row) { - dprintf(STDOUT_FILENO, "\033[%d;%dH", x + n, y); + if (y + n < ws.ws_row) { + dprintf(STDOUT_FILENO, "\033[%d;%dH", y + n, y); write(STDOUT_FILENO, "\033[?25h", 6); /* show cursor */ } else dprintf(STDOUT_FILENO, "\033[%d;0H", ws.ws_row);
[hackers] [scroll] Fix up test || Jochen Sprickerhof
commit fdb54c317eb9215cbfe063c7086a9cefba334f25 Author: Jochen Sprickerhof AuthorDate: Fri Apr 24 00:04:59 2020 +0200 Commit: Jochen Sprickerhof CommitDate: Fri Apr 24 00:04:59 2020 +0200 Fix up test diff --git a/ptty.c b/ptty.c index d4b49e9..c99c010 100644 --- a/ptty.c +++ b/ptty.c @@ -130,7 +130,7 @@ main(int argc, char *argv[]) /* handle cursor position request */ if (strcmp("\033[6n", buf) == 0) { - dprintf(mfd, "\033[1;25R", 1, 1); + dprintf(mfd, "\033[25;1R", 1, 1); continue; } diff --git a/up.sh b/up.sh index 329476e..95ae93c 100755 --- a/up.sh +++ b/up.sh @@ -5,4 +5,4 @@ set -eu jot 50 > tmp.log (sleep 1; printf "\033[5;2~"; sleep 1; ) \ - | ktrace -i ./ptty ./scroll ksh -c "tail -fn 50 tmp.log" > out.log + | ./ptty ./scroll tail -fn 50 tmp.log > out.log
[hackers] [scroll] fix ptty test program. don't quit after pos request || Jan Klemkow
commit 1ce09d0ab8b474c9f2b293080fc2c17b571aff14 Author: Jan Klemkow AuthorDate: Thu Apr 23 23:42:56 2020 +0200 Commit: Jan Klemkow CommitDate: Thu Apr 23 23:42:56 2020 +0200 fix ptty test program. don't quit after pos request diff --git a/ptty.c b/ptty.c index 7f6df51..d4b49e9 100644 --- a/ptty.c +++ b/ptty.c @@ -131,7 +131,7 @@ main(int argc, char *argv[]) /* handle cursor position request */ if (strcmp("\033[6n", buf) == 0) { dprintf(mfd, "\033[1;25R", 1, 1); - break; + continue; } if (write(STDOUT_FILENO, buf, n) == -1)
[hackers] [scroll] add script for scroll up testing || Jan Klemkow
commit 0c291ab3b61f2cd4c520a2b5c18724fc58276d2b Author: Jan Klemkow AuthorDate: Thu Apr 23 23:04:26 2020 +0200 Commit: Jan Klemkow CommitDate: Thu Apr 23 23:09:18 2020 +0200 add script for scroll up testing diff --git a/ptty.c b/ptty.c index ca3eb85..7f6df51 100644 --- a/ptty.c +++ b/ptty.c @@ -130,7 +130,7 @@ main(int argc, char *argv[]) /* handle cursor position request */ if (strcmp("\033[6n", buf) == 0) { - dprintf(mfd, "\033[%d;%dR", 1, 1); + dprintf(mfd, "\033[1;25R", 1, 1); break; } diff --git a/up.sh b/up.sh new file mode 100755 index 000..329476e --- /dev/null +++ b/up.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +set -eu + +jot 50 > tmp.log + +(sleep 1; printf "\033[5;2~"; sleep 1; ) \ + | ktrace -i ./ptty ./scroll ksh -c "tail -fn 50 tmp.log" > out.log
[hackers] [scroll] Fix setting bottom pointer while scrolling || Jochen Sprickerhof
commit 68e4cf9bea15e2ac33224f8b96d7f5ff58ac6e77 Author: Jochen Sprickerhof AuthorDate: Thu Apr 23 22:26:28 2020 +0200 Commit: Jochen Sprickerhof CommitDate: Thu Apr 23 22:26:28 2020 +0200 Fix setting bottom pointer while scrolling diff --git a/scroll.c b/scroll.c index 5b09893..f8de6c0 100644 --- a/scroll.c +++ b/scroll.c @@ -246,8 +246,6 @@ addline(char *buf, size_t size) line->buf = earealloc(NULL, size); memcpy(line->buf, buf, size); - bottom = line; - TAILQ_INSERT_HEAD(, line, entries); } @@ -536,6 +534,13 @@ main(int argc, char *argv[]) if (*c == '\n') { addline(buf, pos); + /* only advance bottom if scroll is */ + /* at the end of the scroll back */ + if (bottom == NULL || + TAILQ_PREV(bottom, tailhead, + entries) == TAILQ_FIRST()) + bottom = TAILQ_FIRST(); + memset(buf, 0, size); pos = 0; }
Re: [hackers] Announcing libschrift (a TrueType font rendering library)
On 2020-04-23, Silvan Jegen wrote: > I had a quick look and currently it looks like it's mostly useful for > rendering of fonts in X. I wonder how an interface would look like that > could also be used for text rendering for a Wayland client. I assume the > library would instead just render to some graphics memory to be rendered > by the compositor, but I am not completely sure. I think the interface would look the same for Wayland, but the missing piece is something to composite the glyphs into the application's window buffer, which is handled by XRender in the demo. If you are rendering to shared memory, pixman (which is essentially XRender in a library) can be used similarly. You can create a glyph cache, load the glyph images produced by libschrift into it, and then use pixman_composite_glyphs to render them onto your frame. For OpenGL/Vulkan, it's the same on X11 and Wayland, since the client is doing direct rendering in both cases. I believe it's generally done by creating an "atlas" texture containing a bunch of glyphs at different positions, and then rendering subregions of it onto your frame. Most code using freetype directly could probably be adapted to libschrift fairly easily.
[hackers] [dwm][patch] dwm crashes when opening 50+ clients (tile layout)
Many users new to dwm find themselves caught out by being kicked out to the login manager (dwm crashing) when they open 50+ clients for demonstration purposes. The number of clients reported varies depending on the resolution of the monitor. The cause of this is due to how the default tile layout calculates the height of the next client based on the position of the previous client. Because clients have a minimum size the (ty) position can exceed that of the window height, resulting in (m->wh - ty) becoming negative. The negative height stored as an unsigned int results in a very large height ultimately resulting in dwm crashing. This patch adds safeguards to prevent the ty and my positions from exceeding that of the window height. --- dwm.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/dwm.c b/dwm.c index fb1e326..9fd0286 100644 --- a/dwm.c +++ b/dwm.c @@ -1689,11 +1689,13 @@ tile(Monitor *m) if (i < m->nmaster) { h = (m->wh - my) / (MIN(n, m->nmaster) - i); resize(c, m->wx, m->wy + my, mw - (2*c->bw), h - (2*c->bw), 0); - my += HEIGHT(c); + if (my + HEIGHT(c) < m->wh) + my += HEIGHT(c); } else { h = (m->wh - ty) / (n - i); resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), 0); - ty += HEIGHT(c); + if (ty + HEIGHT(c) < m->wh) + ty += HEIGHT(c); } } -- 2.17.1
Re: [hackers] Announcing libschrift (a TrueType font rendering library)
Hi Thomas Thomas Oltmann wrote: > Last year at slcon6, I demo'd a toy TrueType font renderer (*) to a > couple people. > Someone there suggested it'd be really useful to have this as a proper > library for suckless projects to use, > and so after a complete rework to make it actually usable, I'm finally > able to release it under the name libschrift! > You can find it here: https://www.github.com/tomolt/libschrift > > What you'll notice is that, similar to other font rendering libraries, > libschrifts API is very low-level; > In future, I'll probably write a wrapper library that abstracts away > most of this. > For right now, there's at least an example/demo application called sftdemo. > sftdemo shows how to use libschrift to render text to an X11 window > completely without Xft or FreeType2. > To do this, sftdemo uses the same underlying interface that Xft is > also built upon. > > Still, you shouldn't use libschrift for anything serious quite yet. > Most notably, compound glyph support is still missing, > so some characters like Umlauts or accents will likely not work yet. > > As a proof of concept, I might at some point write a patch for dmenu > (or something like it) > that replaces all of its Xft / FreeType2 usage with libschrift. > > I can keep you all posted if you're interested. That's a really cool project! I am interested in linguistics and, to a lesser degree, in 2D graphics. Lately I was thinking that I really should look into font rendering as that is where those two interests meet :P this library is a good starting point for me! I had a quick look and currently it looks like it's mostly useful for rendering of fonts in X. I wonder how an interface would look like that could also be used for text rendering for a Wayland client. I assume the library would instead just render to some graphics memory to be rendered by the compositor, but I am not completely sure. Cheers, Silvan