Re: [dev] anyone played with mkinit?

2010-11-07 Thread Uriel
On Sat, Nov 6, 2010 at 4:50 AM, Jens Staal  wrote:
> http://9fans.net/archive/2009/10/375
>
> https://lug.rose-hulman.edu/svn/misc/trunk/mkinit/
>
> apparently still with bashisms due to issues with rc (does not mention
> which) but seems cool and perhaps something for sta.li?

Any issues with rc are no excuse for bashisms, actually there is never
any excuse for bashisms, /bin/sh should be more than enough.

Also the use of svn is a bad omen.

uriel



[dev] [st] multibyte patch

2010-11-07 Thread Damian Okrasa
LC_CTYPE=en_US.UTF-8 should be set for UTF-8, it has some bugs and
sometimes doesn't recognise good UTF-8 string.

http://img51.imageshack.us/img51/4591/201011072157261024x768s.png
diff -r 94c886b859a1 config.def.h
--- a/config.def.h  Sun Oct 31 20:29:22 2010 +0100
+++ b/config.def.h  Sun Nov 07 16:55:36 2010 +0100
@@ -54,12 +54,12 @@
 };
 
 /* Line drawing characters (sometime specific to each font...) */
-static char gfx[] = {
+static wchar_t gfx[] = {
['`'] = 0x01,
['a'] = 0x02,
-   ['f'] = 'o',
-   ['g'] = '+',
-   ['i'] = '#',
+   ['f'] = L'o',
+   ['g'] = L'+',
+   ['i'] = L'#',
['j'] = 0x0B,
['k'] = 0x0C,
['l'] = 0x0D,
diff -r 94c886b859a1 st.c
--- a/st.c  Sun Oct 31 20:29:22 2010 +0100
+++ b/st.c  Sun Nov 07 16:55:36 2010 +0100
@@ -9,6 +9,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -62,7 +64,7 @@
 enum { WIN_VISIBLE=1, WIN_REDRAW=2, WIN_FOCUSED=4 };
 
 typedef struct {
-   char c; /* character code  */
+   wchar_t c; /* character code  */
char mode;  /* attribute flags */
int fg; /* foreground  */
int bg; /* background  */
@@ -81,12 +83,12 @@
 /* CSI Escape sequence structs */
 /* ESC '[' [[ []  [;]] ] */
 typedef struct {
-   char buf[ESC_BUF_SIZ]; /* raw string */
+   wchar_t buf[ESC_BUF_SIZ]; /* raw string */
int len;   /* raw string length */
char priv;
int arg[ESC_ARG_SIZ];
int narg;  /* nb of args */
-   char mode;
+   wchar_t mode;
 } CSIEscape;
 
 /* Internal representation of the screen */
@@ -100,7 +102,7 @@
int bot;/* bottom scroll limit */
int mode;   /* terminal mode flags */
int esc;/* escape state flags */
-   char title[ESC_TITLE_SIZ];
+   wchar_t title[ESC_TITLE_SIZ];
int titlelen;
 } Term;
 
@@ -127,11 +129,19 @@
char s[ESC_BUF_SIZ];
 } Key;
 
+typedef struct {
+   XFontSet fs;
+   short lbearing;
+   short rbearing;
+   int ascent;
+   int descent;
+} FontInfo;
+
 /* Drawing Context */
 typedef struct {
unsigned long col[256];
-   XFontStruct* font;
-   XFontStruct* bfont;
+   FontInfo font;
+   FontInfo bfont;
GC gc;
 } DC;
 
@@ -141,7 +151,7 @@
int bx, by;
int ex, ey;
struct {int x, y;}  b, e;
-   char *clip;
+   wchar_t *clip;
 } Selection;
 
 #include "config.h"
@@ -167,14 +177,14 @@
 static void tnew(int, int);
 static void tnewline(int);
 static void tputtab(void);
-static void tputc(char);
-static void tputs(char*, int);
+static void tputc(wchar_t);
+static void tputs(wchar_t*, int);
 static void treset(void);
 static int tresize(int, int);
 static void tscrollup(int, int);
 static void tscrolldown(int, int);
 static void tsetattr(int*, int);
-static void tsetchar(char);
+static void tsetchar(wchar_t);
 static void tsetscroll(int, int);
 static void tswapscreen(void);
 
@@ -183,7 +193,7 @@
 static void ttyresize(int, int);
 static void ttywrite(const char *, size_t);
 
-static void xdraws(char *, Glyph, int, int, int);
+static void xdraws(wchar_t *, Glyph, int, int, int);
 static void xhints(void);
 static void xclear(int, int, int, int);
 static void xdrawcursor(void);
@@ -266,19 +276,19 @@
sel.ey = sel.by = e->xbutton.y/xw.ch;
 }
 
-static char *getseltext() {
-   char *str, *ptr;
+static wchar_t *getseltext() {
+   wchar_t *str, *ptr;
int ls, x, y, sz;
if(sel.bx == -1)
return NULL;
sz = (term.col+1) * (sel.e.y-sel.b.y+1);
-   ptr = str = malloc(sz);
+   ptr = str = malloc(sz*sizeof(wchar_t));
for(y = 0; y < term.row; y++) {
for(x = 0; x < term.col; x++)
if(term.line[y][x].state & GLYPH_SET && (ls = 
selected(x, y)))
*ptr = term.line[y][x].c, ptr++;
if(ls)
-   *ptr = '\n', ptr++;
+   *ptr = L'\n', ptr++;
}
*ptr = 0;
return str;
@@ -357,7 +367,7 @@
} else if(xsre->target == XA_STRING) {
res = XChangeProperty(xsre->display, xsre->requestor, 
xsre->property,
xsre->target, 8, PropModeReplace, (unsigned 
char *) sel.clip,
-   strlen(sel.clip));
+   wcslen(sel.clip));
switch(res) {
case BadAlloc:
case BadAtom:
@@ -381,7 +391,7 @@
}
 }
 
-static void selcopy(char *str) {
+static void selcopy(wchar_t *str) {
/* register the selection for both the clipboard and the primary */
Atom clipboard;
int res;
@@ -527,11 +537,19 @@
 ttyread(void) {
char buf[BUFSIZ];
int ret;
-
-   if((ret = read(cmdfd, buf, LEN(buf))) 

Re: [dev] [st] multibyte patch

2010-11-07 Thread Moritz Wilhelmy
Whatever you want, wchar_t is not the solution.