Re: [dev] [st] toggle font

2012-10-16 Thread Roberto E. Vargas Caballero
 Surely, it would be better to use a separate control input stream,
 stdctl (or nstdctl), for configuration.

Are you talking about keep, for example, file descriptor 3 for control
operations?



Re: [dev] [st] toggle font

2012-10-16 Thread Bjartur Thorlacius
On Tue, Oct 16, 2012 at 06:25:40PM +0200, Roberto E. Vargas Caballero wrote:
  Surely, it would be better to use a separate control input stream,
  stdctl (or nstdctl), for configuration.
 
 Are you talking about keep, for example, file descriptor 3 for control
 operations?
Yes.



Re: [dev] [st] toggle font

2012-10-13 Thread Bjartur Thorlacius

Edgaras wrote:

On Wed, Oct 10, 2012 at 09:28:33PM +0100, Nick wrote:

Quoth Roberto E. Vargas Caballero:

I also need this feature, but maybe could be done in other way. I talked
about this with other persons of the list, and we liked let st be configured
using the stdin of st, so you can do it something like:

  configurator | st

And, for example, you could use dmenu and select the font you want to use.


Eugh. That isn't the way anything else is configured. It's a pretty
weird interface. config.h, argv switches and potentially keybindings
are reasonable ways to configure programs. stdin is just silly.



I wouldn't say that. I would say it depends very strongly on the application.
For example for quite some time I have an idea of general key-binder, something
like xbindkeys, except that it would not read any config files, but it would
read configuration from stdin. This would allow simple key rebinding while
application is already running without introducing inconsistent configuration
loadings, i.e. from file and then some other way for rebinding on the fly. What
I want to say that stdin for configuration/commands/options for (maybe just
certain)gui applications can be a nice option (obviously for cli applications
that is not the case, because there stdin is main input for data).

Surely, it would be better to use a separate control input stream, 
stdctl (or nstdctl), for configuration.




Re: [dev] [st] toggle font

2012-10-11 Thread Nick
On Thu, Oct 11, 2012 at 08:27:55AM +0300, Edgaras wrote:
 On Thu, Oct 11, 2012 at 05:25:58AM +0200, Christoph Lohmann wrote:
  Noone is really
  using dmenu. It’s a bloated interface to text strings. Hopefully it will
  die soon.
  
 I think dmenu is doing it job pretty well. And I'm not sure I understand where
 it is bloated.

I think Christoph is just trolling. Either that or being wrong.



Re: [dev] [st] toggle font

2012-10-11 Thread Stephen Paul Weber

Somebody claiming to be sta...@cs.tu-berlin.de wrote:

This patch (against tip) introduces an array of font names in the config
instead FONT and allows to cycle through them with Ctrl-PgUp at runtime.


I also need multiple fonts, but I find keeping several builds of st around 
works fine for me.


--
Stephen Paul Weber, @singpolyma
See http://singpolyma.net for how I prefer to be contacted
edition right joseph


signature.asc
Description: Digital signature


Re: [dev] [st] toggle font

2012-10-11 Thread Christoph Lohmann
Greetings.

On Thu, 11 Oct 2012 15:56:54 +0200 Stephen Paul Weber 
singpol...@singpolyma.net wrote:
 Somebody claiming to be sta...@cs.tu-berlin.de wrote:
 This patch (against tip) introduces an array of font names in the config
 instead FONT and allows to cycle through them with Ctrl-PgUp at runtime.
 
 I also need multiple fonts, but I find keeping several builds of st around 
 works fine for me.

% st -f $basefont


Sincerely,

Christoph Lohmann




Re: [dev] [st] toggle font

2012-10-11 Thread Carlos Torres
On Thu, Oct 11, 2012 at 9:56 AM, Christoph Lohmann 2...@r-36.net wrote:

 Greetings.

 On Thu, 11 Oct 2012 15:56:54 +0200 Stephen Paul Weber 
 singpol...@singpolyma.net wrote:
  Somebody claiming to be sta...@cs.tu-berlin.de wrote:
  This patch (against tip) introduces an array of font names in the config
  instead FONT and allows to cycle through them with Ctrl-PgUp at runtime.
 
  I also need multiple fonts, but I find keeping several builds of st
 around
  works fine for me.

 % st -f $basefont


Thats insane! i prefer to maintain multiple config files



 Sincerely,

 Christoph Lohmann





Re: [dev] [st] toggle font

2012-10-11 Thread Christoph Lohmann
Greetings.

On Thu, 11 Oct 2012 17:04:23 +0200 Carlos Torres vlaadbr...@gmail.com wrote:
 On Thu, Oct 11, 2012 at 9:56 AM, Christoph Lohmann 2...@r-36.net wrote:
 
  Greetings.
 
  On Thu, 11 Oct 2012 15:56:54 +0200 Stephen Paul Weber 
  singpol...@singpolyma.net wrote:
   Somebody claiming to be sta...@cs.tu-berlin.de wrote:
   This patch (against tip) introduces an array of font names in the config
   instead FONT and allows to cycle through them with Ctrl-PgUp at runtime.
  
   I also need multiple fonts, but I find keeping several builds of st
  around
   works fine for me.
 
  % st -f $basefont
 
 
 Thats insane! i prefer to maintain multiple config files

I  prefer  to  maintain multiple configuration daemons on different dbus
service names.


Sincerely,

Christoph Lohmann




Re: [dev] [st] toggle font

2012-10-11 Thread Roberto E. Vargas Caballero
 Eugh. That isn't the way anything else is configured. It's a pretty
 weird interface. config.h, argv switches and potentially keybindings
 are reasonable ways to configure programs. stdin is just silly.


St, like all others graphic terminal emualtors, receive escape sequences
which configure it, change color, set tittle screen, set blink ..., so add
new private sequences for things like chage font is not only no stupid, is
the correct way in this case.

Once you have the sequence, which can only be inserted from the own terminal
(for example with an echo), next step is allow these sequences in the non
used standard input, so st could accept them from others programs.



Re: [dev] [st] toggle font

2012-10-11 Thread Aurélien Aptel
On Thu, Oct 11, 2012 at 6:13 PM, Roberto E. Vargas Caballero
k...@shike2.com wrote:
 St, like all others graphic terminal emualtors, receive escape sequences
 which configure it, change color, set tittle screen, set blink ..., so add
 new private sequences for things like chage font is not only no stupid, is
 the correct way in this case.

Urxvt has this [1], we can use the same.

1: http://unix.stackexchange.com/a/14431



Re: [dev] [st] toggle font

2012-10-11 Thread stanio
Hi,

* Stephen Paul Weber singpol...@singpolyma.net [2012-10-11 15:56]:
 Somebody claiming to be sta...@cs.tu-berlin.de wrote:
 This patch (against tip) introduces an array of font names in the config
 instead FONT and allows to cycle through them with Ctrl-PgUp at runtime.
 
 I also need multiple fonts, but I find keeping several builds of st
 around works fine for me.

I have 5 of them. Works fine: they live in separate dirs with only
Makefile an config.h not symlinked to the master-st dir.

Some features are fun to implement, but then you use them a day or two
and forget. But since some days ago, every day I like this font
switching on the fly more and more. And it comes effectively at no cost
-- neither conceptual, nor syntactical.

cheers
--s_



Re: [dev] [st] toggle font

2012-10-10 Thread Roberto E. Vargas Caballero
 I missed this feature a lot when light conditions and distance to
 display change, often so with a notebook, even more when different
 displays plugged. Of course, tmux helps -- kill, start new st, attach to
 the right session --, but I like this approach more.

I also need this feature, but maybe could be done in other way. I talked
about this with other persons of the list, and we liked let st be configured
using the stdin of st, so you can do it something like:

 configurator | st

And, for example, you could use dmenu and select the font you want to use.



Re: [dev] [st] toggle font

2012-10-10 Thread Nick
Quoth Roberto E. Vargas Caballero:
 I also need this feature, but maybe could be done in other way. I talked
 about this with other persons of the list, and we liked let st be configured
 using the stdin of st, so you can do it something like:
 
  configurator | st
 
 And, for example, you could use dmenu and select the font you want to use.

Eugh. That isn't the way anything else is configured. It's a pretty 
weird interface. config.h, argv switches and potentially keybindings 
are reasonable ways to configure programs. stdin is just silly.



Re: [dev] [st] toggle font

2012-10-10 Thread Kurt H Maier
On Wed, Oct 10, 2012 at 09:28:33PM +0100, Nick wrote:
 Quoth Roberto E. Vargas Caballero:
  I also need this feature, but maybe could be done in other way. I talked
  about this with other persons of the list, and we liked let st be configured
  using the stdin of st, so you can do it something like:
  
   configurator | st
  
  And, for example, you could use dmenu and select the font you want to use.
 
 Eugh. That isn't the way anything else is configured. It's a pretty 
 weird interface. config.h, argv switches and potentially keybindings 
 are reasonable ways to configure programs. stdin is just silly.
 

What's wrong with environment variables?



Re: [dev] [st] toggle font

2012-10-10 Thread Christoph Lohmann
Greetings.

On Thu, 11 Oct 2012 05:25:58 +0200 Roberto E. Vargas Caballero 
k...@shike2.com wrote:
  I missed this feature a lot when light conditions and distance to
  display change, often so with a notebook, even more when different
  displays plugged. Of course, tmux helps -- kill, start new st, attach to
  the right session --, but I like this approach more.
 
 I also need this feature, but maybe could be done in other way. I talked
 about this with other persons of the list, and we liked let st be configured
 using the stdin of st, so you can do it something like:
 
  configurator | st
 
 And, for example, you could use dmenu and select the font you want to use.

There  is  xdotool(1)  and friends for such weird stuff. Noone is really
using dmenu. It’s a bloated interface to text strings. Hopefully it will
die soon.


Sincerely,

Christoph Lohmann




Re: [dev] [st] toggle font

2012-10-10 Thread Edgaras
On Wed, Oct 10, 2012 at 09:28:33PM +0100, Nick wrote:
 Quoth Roberto E. Vargas Caballero:
  I also need this feature, but maybe could be done in other way. I talked
  about this with other persons of the list, and we liked let st be configured
  using the stdin of st, so you can do it something like:
  
   configurator | st
  
  And, for example, you could use dmenu and select the font you want to use.
 
 Eugh. That isn't the way anything else is configured. It's a pretty 
 weird interface. config.h, argv switches and potentially keybindings 
 are reasonable ways to configure programs. stdin is just silly.
 

I wouldn't say that. I would say it depends very strongly on the application.
For example for quite some time I have an idea of general key-binder, something
like xbindkeys, except that it would not read any config files, but it would
read configuration from stdin. This would allow simple key rebinding while
application is already running without introducing inconsistent configuration
loadings, i.e. from file and then some other way for rebinding on the fly. What
I want to say that stdin for configuration/commands/options for (maybe just
certain)gui applications can be a nice option (obviously for cli applications
that is not the case, because there stdin is main input for data).



[dev] [st] toggle font

2012-10-09 Thread stanio
Hi,

This patch (against tip) introduces an array of font names in the config
instead FONT and allows to cycle through them with Ctrl-PgUp at runtime.

I missed this feature a lot when light conditions and distance to
display change, often so with a notebook, even more when different
displays plugged. Of course, tmux helps -- kill, start new st, attach to
the right session --, but I like this approach more.

Someone might find it useful.

cheers,
--s_
diff -r ba208156a8af config.def.h
--- a/config.def.h  Tue Oct 09 19:40:37 2012 +0200
+++ b/config.def.h  Tue Oct 09 22:33:55 2012 +0200
@@ -1,5 +1,9 @@
 
-#define FONT Liberation Mono:pixelsize=12:antialias=false:autohint=false
+static char* fonts[] = {
+   Liberation Mono:pixelsize=12:antialias=false:autohint=false,
+   Liberation Mono:pixelsize=14:antialias=false:autohint=false,
+   Liberation Mono:pixelsize=24:antialias=false:autohint=false
+};
 
 /* Space in pixels around the terminal buffer */
 #define BORDER 2
diff -r ba208156a8af st.c
--- a/st.c  Tue Oct 09 19:40:37 2012 +0200
+++ b/st.c  Tue Oct 09 22:33:55 2012 +0200
@@ -73,6 +73,7 @@
 #define Y2ROW(y) (((y) - BORDER)/xw.ch)
 
 #define VT102ID \033[?6c
+#define FONT   fonts[currfont]
 
 enum glyph_attribute {
ATTR_NULL  = 0,
@@ -335,6 +336,8 @@
 static void selpaste(void);
 static void selscroll(int, int);
 
+static void togglefont(void);
+
 static int utf8decode(char *, long *);
 static int utf8encode(long *, char *);
 static int utf8size(char *);
@@ -378,6 +381,7 @@
 static char *opt_embed = NULL;
 static char *opt_class = NULL;
 static char *opt_font = NULL;
+static unsigned int currfont = 0;
 
 void *
 xmalloc(size_t len) {
@@ -2566,6 +2570,20 @@
 }
 
 void
+togglefont(){
+   int col, row;
+
+   currfont = (++currfont) % LEN(fonts);
+   initfonts(FONT);
+   col = (xw.w - 2*BORDER) / xw.cw;
+   row = (xw.h - 2*BORDER) / xw.ch;
+   tresize(col, row);
+   xresize(col, row);
+   ttyresize();
+   draw();
+}
+
+void
 kpress(XEvent *ev) {
XKeyEvent *e = ev-xkey;
KeySym ksym;
@@ -2574,11 +2592,13 @@
int len;
int meta;
int shift;
+   int ctrl;
Status status;
 
if (IS_SET(MODE_KBDLOCK))
return;
 
+   ctrl = e-state  ControlMask;
meta = e-state  Mod1Mask;
shift = e-state  ShiftMask;
len = XmbLookupString(xw.xic, e, buf, sizeof(buf), ksym, status);
@@ -2589,6 +2609,11 @@
/* 2. hardcoded (overrides X lookup) */
} else {
switch(ksym) {
+   case XK_Prior:
+   case XK_Next:
+   if(ctrl)
+   togglefont();
+   break;
case XK_Up:
case XK_Down:
case XK_Left: