Compare commits
4 Commits
e43e9ebeca
...
de09819ff5
Author | SHA1 | Date | |
---|---|---|---|
de09819ff5 | |||
7f7b725378 | |||
15d0bd5bd6 | |||
d2e40f9636 |
43
termtest.c
43
termtest.c
@ -27,14 +27,17 @@
|
||||
#include <poll.h>
|
||||
#include <termios.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <glob.h>
|
||||
|
||||
#include <curses.h>
|
||||
#include <term.h>
|
||||
|
||||
#define CSI "\x1b["
|
||||
#define OSC "\x1b]"
|
||||
#define DCS "\x1bP"
|
||||
#define ST "\x1b\\"
|
||||
#define ST8 "\x9c"
|
||||
#define BEL "\x07"
|
||||
#define ST "\x9c"
|
||||
|
||||
extern char **environ;
|
||||
static struct termios saved_termios;
|
||||
@ -202,7 +205,7 @@ int main(int argc, char *argv[]) {
|
||||
// - see acolors.sh from xterm's vttests, it changes terminal colours
|
||||
// (and urxvt passed that, at least apparently)
|
||||
|
||||
printf("-- Blink attribute\n");
|
||||
printf("-- Bold and blink attributes\n");
|
||||
bool bbc_supported = enter_bold_mode && enter_blink_mode
|
||||
&& set_a_foreground && set_a_background && exit_attribute_mode;
|
||||
printf("Terminfo: %d\n", bbc_supported);
|
||||
@ -255,30 +258,34 @@ int main(int argc, char *argv[]) {
|
||||
const char *windowid = getenv("WINDOWID");
|
||||
if (windowid) {
|
||||
printf("WINDOWID=%s\n", windowid);
|
||||
printf("There should be a picture. Press a key.\n");
|
||||
poll(NULL, 0, 50 /* wait for a refresh */);
|
||||
|
||||
char buf[1000] = "";
|
||||
snprintf(buf, sizeof buf, "/usr/lib/w3m:%s", getenv("PATH"));
|
||||
setenv("PATH", buf, true /* replace */);
|
||||
|
||||
// TODO:
|
||||
// - run w3mimgdisplay now, hardcoded visual check
|
||||
// - I guess I'll need a picture to show
|
||||
// - /usr/share/pixmaps/debian-logo.png
|
||||
// - /usr/share/icons/HighContrast/48x48/stock/gtk-yes.png
|
||||
// - we get run from a relative path, so not sure about local
|
||||
// - or we can create our own picture, something easily compressible
|
||||
// - can even pass that as an fd during fork and use /dev/fd/N
|
||||
glob_t gb;
|
||||
glob("/usr/share/pixmaps/*.xpm", 0, NULL, &gb);
|
||||
glob("/usr/share/pixmaps/*.png", GLOB_APPEND, NULL, &gb);
|
||||
|
||||
FILE *fp = popen("w3mimgdisplay >/dev/null", "w");
|
||||
fprintf(fp, "0;1;0;0;%d;%d;;;;;%s\n4;\n3;", 100, 100, gb.gl_pathv[0]);
|
||||
pclose(fp);
|
||||
globfree(&gb);
|
||||
|
||||
comm("", true);
|
||||
}
|
||||
|
||||
printf("-- Sixel graphics\n");
|
||||
// TODO:
|
||||
// - hardcoded visual check
|
||||
comm(CSI "4c" DCS "0;0;0;q??~~??~~??iTiTiT" ST, false);
|
||||
|
||||
printf("-- Mouse protocol\n");
|
||||
printf("Maximise the terminal window and click the rightmost column.\n");
|
||||
// TODO: Bug the user into resizing it wide enough, or at least making
|
||||
// the font smaller. Or maybe just warn, and say how many columns there
|
||||
// need to be (255 - 32 + 1 = 224).
|
||||
while (!ioctl(STDIN_FILENO, TIOCGWINSZ, &ws) && ws.ws_col < 223)
|
||||
comm("Your terminal needs to be at least 223 columns wide.\n"
|
||||
"Press a key once you've made it wide enough.\n", true);
|
||||
printf("Click the rightmost column, if it's possible.\n");
|
||||
|
||||
int mouses[] = { 1005, 1006, 1015, 1016 };
|
||||
for (size_t i = 0; i < sizeof mouses / sizeof *mouses; i++) {
|
||||
if (decrqm_supported)
|
||||
@ -296,10 +303,10 @@ int main(int argc, char *argv[]) {
|
||||
if (!strncmp(selection, OSC "52;", 5)) {
|
||||
printf("We have received the selection from the terminal!" CSI "1m\n");
|
||||
char *semi = strrchr(selection, ';');
|
||||
*strpbrk(semi, BEL ST) = 0;
|
||||
*strpbrk(semi, BEL ST8) = 0;
|
||||
FILE *fp = popen("base64 -d", "w");
|
||||
fprintf(fp, "%s", semi + 1);
|
||||
fclose(fp);
|
||||
pclose(fp);
|
||||
printf(CSI "m\n");
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user