ref: bc06169420581a3cb32582974411bc4fdec81b32
parent: d54559068ac288be60dbc868a3ea5dae11e08a14
author: Roberto E. Vargas Caballero <[email protected]>
date: Sun Aug 14 08:09:22 EDT 2022
Move threadmain to x.c This is the first step to make the st code actually running because we are not going to execute vt code anymore.
--- a/config.h
+++ b/config.h
@@ -1,156 +1,8 @@
/* See LICENSE file for copyright and license details. */
-/*
- * appearance
- *
- * font: see http://freedesktop.org/software/fontconfig/fontconfig-user.html
- */
-static char *font = "Liberation Mono:pixelsize=12:antialias=true:autohint=true";
-static int borderpx = 2;
-
-/*
- * What program is execed by st depends of these precedence rules:
- * 1: program passed with -e
- * 3: shell environment variable
- * 4: /bin/rc
- */
-char *stty_args = "stty raw pass8 nl -echo -iexten -cstopb 38400";
-
-/* identification sequence returned in DA and DECID */
-char *vtiden = "\033[?6c";
-
-/* Kerning / character bounding-box multipliers */
-static float cwscale = 1.0;
-static float chscale = 1.0;
-
-/*
- * word delimiter string
- *
- * More advanced example: L" `'\"()[]{}"
- */
-Rune *worddelimiters = L" ";
-
-/* selection timeouts (in milliseconds) */
-static unsigned int doubleclicktimeout = 300;
-static unsigned int tripleclicktimeout = 600;
-
/* alt screens */
-int allowaltscreen = 1;
+extern int allowaltscreen;
-/* allow certain non-interactive (insecure) window operations such as:
- setting the clipboard text */
-int allowwindowops = 0;
-
-/*
- * draw latency range in ms - from new content/keypress/etc until drawing.
- * within this range, st draws when content stops arriving (idle). mostly it's
- * near minlatency, but it waits longer for slow updates to avoid partial draw.
- * low minlatency will tear/flicker more, as it can "detect" idle too early.
- */
-static double minlatency = 8;
-static double maxlatency = 33;
-
-/*
- * blinking timeout (set to 0 to disable blinking) for the terminal blinking
- * attribute.
- */
-static unsigned int blinktimeout = 800;
-
-/*
- * thickness of underline and bar cursors
- */
-static unsigned int cursorthickness = 2;
-
-/*
- * bell volume. It must be a value between -100 and 100. Use 0 for disabling
- * it
- */
-static int bellvolume = 0;
-
-/* default TERM value */
-char *termname = "st-256color";
-
-/*
- * spaces per tab
- *
- * When you are changing this value, don't forget to adapt the »it« value in
- * the st.info and appropriately install the st.info in the environment where
- * you use this st version.
- *
- * it#$tabspaces,
- *
- * Secondly make sure your kernel is not expanding tabs. When running `stty
- * -a` »tab0« should appear. You can tell the terminal to not expand tabs by
- * running following command:
- *
- * stty tabs
- */
-unsigned int tabspaces = 8;
-
-/* Terminal colors (16 first used in escape sequence) */
-static const char *colorname[] = {
- /* 8 normal colors */
- "black",
- "red3",
- "green3",
- "yellow3",
- "blue2",
- "magenta3",
- "cyan3",
- "gray90",
-
- /* 8 bright colors */
- "gray50",
- "red",
- "green",
- "yellow",
- "#5c5cff",
- "magenta",
- "cyan",
- "white",
-
- [255] = 0,
-
- /* more colors can be added after 255 to use with DefaultXX */
- "#cccccc",
- "#555555",
- "gray90", /* default foreground colour */
- "black", /* default background colour */
-};
-
-
-/*
- * Default colors (colorname index)
- * foreground, background, cursor, reverse cursor
- */
-unsigned int defaultfg = 258;
-unsigned int defaultbg = 259;
-unsigned int defaultcs = 256;
-static unsigned int defaultrcs = 257;
-
-/*
- * Default shape of cursor
- * 2: Block ("█")
- * 4: Underline ("_")
- * 6: Bar ("|")
- * 7: Snowman ("☃")
- */
-static unsigned int cursorshape = 2;
-
-/*
- * Default columns and rows numbers
- */
-
-static unsigned int cols = 80;
-static unsigned int rows = 24;
-
-/*
- * Color used to display font attributes when fontconfig selected a font which
- * doesn't match the ones requested.
- */
-static unsigned int defaultattr = 11;
-
-
#ifdef NO
/*
* Internal mouse shortcuts.
@@ -439,12 +291,3 @@
{ XK_F35, XK_NO_MOD, "\033[23;5~", 0, 0},
};
#endif
-
-/*
- * Printable characters in ASCII, used to estimate the advance width
- * of single wide characters.
- */
-static char ascii_printable[] =
- " !\"#$%&'()*+,-./0123456789:;<=>?"
- "@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_"
- "`abcdefghijklmnopqrstuvwxyz{|}~";
--- a/main.c
+++ b/main.c
@@ -250,7 +250,7 @@
}
void
-threadmain(int argc, char **argv)
+old_threadmain(int argc, char **argv)
{
int rflag;
int i, blkbg;
--- a/mkfile
+++ b/mkfile
@@ -3,13 +3,10 @@
TARG=vt
OFILES=\
- main.$O\
st.$O\
- vt.$O\
x.$O\
- fs.$O\
-HFILES=cons.h st.h win.h
+HFILES=st.h win.h
BIN=/$objtype/bin
</sys/src/cmd/mkone
--- a/st.c
+++ b/st.c
@@ -209,6 +209,12 @@
static int iofd = 1;
static int cmdfd;
static int pid;
+char *vtiden = "\033[?6c";
+Rune *worddelimiters = L" ";
+int allowaltscreen = 1;
+char *stty_args = "stty raw pass8 nl -echo -iexten -cstopb 38400";
+char *termname = "st-256color";
+unsigned int tabspaces = 8;
static const uchar utfbyte[UTF_SIZ + 1] = {0x80, 0, 0xC0, 0xE0, 0xF0};
static const uchar utfmask[UTF_SIZ + 1] = {0xC0, 0x80, 0xE0, 0xF0, 0xF8};
@@ -1740,7 +1746,7 @@
static void
strhandle(void)
{
- char *p = nil, *dec;
+ char *p = nil;
int j, narg, par;
const struct { int idx; char *str; } osc_table[] = {
{ defaultfg, "foreground" },
@@ -1769,17 +1775,6 @@
if (narg > 1)
xsettitle(strescseq.args[1]);
return;
- case 52:
- if (narg > 2 && allowwindowops) {
- dec = base64dec(strescseq.args[2]);
- if (dec) {
- xsetsel(dec);
- xclipcopy();
- } else {
- fprint(2, "erresc: invalid base64\n");
- }
- }
- return;
case 10:
case 11:
case 12:
@@ -1826,6 +1821,7 @@
case 'k': /* old title set compatibility */
xsettitle(strescseq.args[0]);
return;
+ case 52: /* not implemented because is insecure */
case 'P': /* DCS -- Device Control String */
case '_': /* APC -- Application Program Command */
case '^': /* PM -- Privacy Message */
--- a/x.c
+++ b/x.c
@@ -1,9 +1,56 @@
#include <u.h>
#include <libc.h>
+#include <thread.h>
#include "st.h"
#include "win.h"
+#include "config.h"
+char *opt_io;
+char *opt_line;
+char **opt_cmd;
+
+/* Terminal colors (16 first used in escape sequence) */
+static const char *colorname[] = {
+ /* 8 normal colors */
+ "black",
+ "red3",
+ "green3",
+ "yellow3",
+ "blue2",
+ "magenta3",
+ "cyan3",
+ "gray90",
+
+ /* 8 bright colors */
+ "gray50",
+ "red",
+ "green",
+ "yellow",
+ "#5c5cff",
+ "magenta",
+ "cyan",
+ "white",
+
+ [255] = 0,
+
+ /* more colors can be added after 255 to use with DefaultXX */
+ "#cccccc",
+ "#555555",
+ "gray90", /* default foreground colour */
+ "black", /* default background colour */
+};
+
+unsigned int defaultfg = 258;
+unsigned int defaultbg = 259;
+unsigned int defaultcs = 256;
+
+static unsigned int defaultrcs = 257;
+static unsigned int cols = 80;
+static unsigned int rows = 24;
+static unsigned int defaultattr = 11;
+
+
void
xbell(void)
{
@@ -86,4 +133,55 @@
void
xximspot(int, int)
{
+}
+
+void
+run(void)
+{
+}
+
+void
+xinit(int cols, int rows)
+{
+ USED(cols);
+ USED(rows);
+}
+
+void
+usage(void)
+{
+ sysfatal("vt: bad usage\n");
+}
+
+void
+threadmain(int argc, char **argv)
+{
+ ARGBEGIN {
+ case 'a':
+ allowaltscreen = 0;
+ break;
+ case 'e':
+ if (argc > 0)
+ --argc, ++argv;
+ goto run;
+ case 'o':
+ opt_io = EARGF(usage());
+ break;
+ case 'l':
+ opt_line = EARGF(usage());
+ break;
+ default:
+ usage();
+ } ARGEND;
+
+run:
+ if (argc > 0) /* eat all remaining arguments */
+ opt_cmd = argv;
+
+ cols = MAX(cols, 1);
+ rows = MAX(rows, 1);
+ tnew(cols, rows);
+ xinit(cols, rows);
+ selinit();
+ run();
}