[dev] [st][PATCH v2] Cancel DCS with SUB, CAN, ESC or any CC1 code

2014-04-26 Thread Roberto E. Vargas Caballero
>From http://www.vt100.net/docs/vt510-rm/chapter4:

*The VT510 ignores all following characters until it receives a
 SUB, ST, or any other C1 control character.

So OSC, PM and APC sequence ends with a SUB (it cancels the sequence
and show a question mark as error), ST or any another C1 (8 bits)
code, or their C0 (7 bits) equivalent sequences (at this moment we
do not handle C1 codes, but we should). But it is also said that:

Cancel  CAN
1/8 Immediately cancels an escape sequence, control sequence,
or device control string in progress. In this case, the
VT510 does not display any error character.

Escape  ESC
1/11Introduces an escape sequence. ESC also cancels any escape
sequence, control sequence, or device control string in
progress.
---
 st.c | 203 +--
 1 file changed, 125 insertions(+), 78 deletions(-)

diff --git a/st.c b/st.c
index d2261e2..2a1e66b 100644
--- a/st.c
+++ b/st.c
@@ -390,6 +390,7 @@ static void tsetdirtattr(int);
 static void tsetmode(bool, bool, int *, int);
 static void tfulldirt(void);
 static void techo(char *, int);
+static bool tcontrolcode(uchar );
 static int32_t tdefcolor(int *, int *, int);
 static void tselcs(void);
 static void tdeftran(char);
@@ -399,6 +400,7 @@ static void ttyread(void);
 static void ttyresize(void);
 static void ttysend(char *, size_t);
 static void ttywrite(const char *, size_t);
+static bool iscontrol(int c);
 
 static void xdraws(char *, Glyph, int, int, int, int);
 static void xhints(void);
@@ -2134,6 +2136,7 @@ strhandle(void) {
char *p = NULL;
int j, narg, par;
 
+   term.esc &= ~(ESC_STR_END|ESC_STR);
strparse();
narg = strescseq.narg;
par = atoi(strescseq.args[0]);
@@ -2293,13 +2296,22 @@ tputtab(int n) {
tmoveto(x, term.c.y);
 }
 
+bool
+iscontrol(int c) {
+   return c < 0x20 || c == 0177 || BETWEEN(c, 0x80, 0x9f);
+}
+
 void
 techo(char *buf, int len) {
for(; len > 0; buf++, len--) {
char c = *buf;
 
-   if(BETWEEN(c, 0x00, 0x1f) || c == 0x7f) { /* control code */
-   if(c != '\n' && c != '\r' && c != '\t') {
+   if(iscontrol(c)) { /* control code */
+   if(c & 0x80) {
+   c &= 0x7f;
+   tputc("^", 1);
+   tputc("[", 1);
+   } else if(c != '\n' && c != '\r' && c != '\t') {
c ^= '\x40';
tputc("^", 1);
}
@@ -2338,57 +2350,135 @@ tselcs(void) {
   ATTR_GFX);
 }
 
+bool
+tcontrolcode(uchar ascii) {
+   static char question[UTF_SIZ] = "?";
+
+   switch(ascii) {
+   case '\t':   /* HT */
+   tputtab(1);
+   break;
+   case '\b':   /* BS */
+   tmoveto(term.c.x-1, term.c.y);
+   break;
+   case '\r':   /* CR */
+   tmoveto(0, term.c.y);
+   break;
+   case '\f':   /* LF */
+   case '\v':   /* VT */
+   case '\n':   /* LF */
+   /* go to first col if the mode is set */
+   tnewline(IS_SET(MODE_CRLF));
+   break;
+   case '\a':   /* BEL */
+   if(term.esc & ESC_STR_END) {
+   /* backwards compatibility to xterm */
+   strhandle();
+   } else {
+   if(!(xw.state & WIN_FOCUSED))
+   xseturgency(1);
+   if (bellvolume)
+   XBell(xw.dpy, bellvolume);
+   }
+   break;
+   case '\033': /* ESC */
+   csireset();
+   term.esc &= ~(ESC_CSI|ESC_ALTCHARSET|ESC_TEST);
+   term.esc |= ESC_START;
+   return 1;
+   case '\016': /* SO */
+   term.charset = 0;
+   tselcs();
+   break;
+   case '\017': /* SI */
+   term.charset = 1;
+   tselcs();
+   break;
+   case '\032': /* SUB */
+   tsetchar(question, &term.c.attr, term.c.x, term.c.y);
+   case '\030': /* CAN */
+   csireset();
+   break;
+   case '\005': /* ENQ (IGNORED) */
+   case '\000': /* NUL (IGNORED) */
+   case '\021': /* XON (IGNORED) */
+   case '\023': /* XOFF (IGNORED) */
+   case 0177:   /* DEL (IGNORED) */
+   case 0x84:   /* TODO: IND */
+   case 0x85:   /* TODO: NEL */
+   case 0x88:   /* TODO: HTS */
+   case 0x8d:   /* TODO: RI */
+   case 0x8e:   /* TODO: SS2 */
+   case 0x8f:   /* TODO: SS3 */
+   case 0x90:   /* TODO: DCS */
+   case 0x98:   /* TODO: SOS */
+   case 0x9a:   /* TODO: DECID */
+   case 0x9b:   /* TODO: CS

[dev] [dwm] trayless workflow

2014-04-26 Thread Yuri Karaban
Hello,

I browsed suckless mailing lists and I found that system tray is
discouraged in dwm and it's suggested to use tags instead.

I was always using workspace separation (with other window manager) and
I have instant messengers on dedicated workspace. But system tray is
still very useful, without switching workspace I can see that I have new
message on IM or someone has replied me in IRC.

I tried two independent tray applications (trayer and stalonetray), but
they look alien to dwm. They have fixed size floating windows, and they
overlap tiled windows. They have the same borders as other application,
and does not stand out from other applications like dmenu. And trayer
has a bad habit to grab focus after switching active tag, and it's
getting underfoot when switching focused windows with Mod-j and Mod-k.

System tray patch from patches section is working fine for me. It's less
obtrusive.

I'm not in any way asking about taking patch to upstream. I just want to
know what what is the alternative way to monitor activity of
applications which I usually monitor with the tray icons.

Probably I not understood well trayer and stalonetray options and they
can smoothly integrate into dwm.

I appreciate much any advice.

-- 
Amor vincit omnia.



Re: [dev] [dwm] trayless workflow

2014-04-26 Thread Manolo Martínez
> I just want to
> know what what is the alternative way to monitor activity of
> applications which I usually monitor with the tray icons.

I find that urgency hints are more than enough for irc. You probably
need to instruct your irc client to issue them (e.g. in irssi/config:
"bell_beeps=yes") and your terminal emulator
to understand them (e.g., for urxvt "URxvt.urgentOnBell: true" in
.Xresources).

Manolo



Re: [dev] [dwm] trayless workflow

2014-04-26 Thread Yuri Karaban
> "MM" == Manolo Martínez  writes:

Hi Manolo!

Thank you very much, it's exactly what I need :-)

It's wonderful that dwm indicate UrgencyHint on hidden tags, it covers
my needs 100%. Now I can easily get along without system tray.

>> I just want to know what what is the alternative way to monitor
>> activity of applications which I usually monitor with the tray
>> icons.

MM>> I find that urgency hints are more than enough for irc. You
MM>> probably need to instruct your irc client to issue them
MM>> (e.g. in irssi/config: "bell_beeps=yes") and your terminal
MM>> emulator to understand them (e.g., for urxvt
MM>> "URxvt.urgentOnBell: true" in .Xresources).

-- 
In necessariis unitas, in dubiis libertas, in omnibus caritas



[dev] [PATCH] add break;s for last cases in switch statements

2014-04-26 Thread Markus Teich
---

Heyho,

here is the patch. For cases ending with return; I did not add a break since it
serves the same functionallity in this context.

--Markus


 st.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/st.c b/st.c
index d2261e2..49df792 100644
--- a/st.c
+++ b/st.c
@@ -1228,6 +1228,7 @@ ttynew(void) {
opt_io, strerror(errno));
}
}
+   break;
}
 }
 
@@ -1673,6 +1674,7 @@ tdefcolor(int *attr, int *npar, int l) {
default:
fprintf(stderr,
"erresc(38): gfx attr %d unknown\n", attr[*npar]);
+   break;
}
 
return idx;
@@ -2387,6 +2389,7 @@ tputc(char *c, int len) {
 * strhandle();
 */
}
+   break;
}
return;
}
@@ -2550,6 +2553,7 @@ tputc(char *c, int len) {
fprintf(stderr, "erresc: unknown sequence ESC 
0x%02X '%c'\n",
(uchar) ascii, isprint(ascii)? 
ascii:'.');
term.esc = 0;
+   break;
}
}
/*
-- 
1.8.3.2