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