Re: [dev] Sandy editor

2011-05-26 Thread Hiltjo Posthuma
I agree with pancake. I also noticed the selection of text using the
mouse is very laggy / slow (using xterm). Anyway I'll keep an eye on
this project since it seems promising to me.

Kind regards,
Hiltjo



Re: [dev] mret

2011-05-26 Thread Nick
On Wed, May 25, 2011 at 10:38:08PM +0100, Connor Lane Smith wrote:
> imo (and stealing some ideas from Kurt) you should have separate boxes
> which are filled with the output of the given command; you just type a
> command and the box appears and starts to be filled. You can then type
> your next command whenever you want, completely asynchronously, and
> that's added on the end, and starts to be filled, too.

Being able to queue commands would be nice for the use case
of playing something in mplayer, then realising in the next
few minutes it will come to an end and wanting to append
something else. I'm aware less command-centric media players
can do this, but I am rather fond of mplayer.



[dev] suckless games collection?

2011-05-26 Thread pancake
I found this chess implementation in obfuscated C. I'm sure than 
cleaning it up
(deobfuscating it) will make it ready to be in the cathegory of 
"suckless games"


  http://nanochess.110mb.com/chess1_es.html

What do you think about creating a 'sgames' project? collecting 
minimalistic simple

games? I wrote a word guess game few time ago named 'wg' which can be merged
into this project.

--pancake



Re: [dev] suckless games collection?

2011-05-26 Thread Le Tian
On Thu, May 26, 2011 at 5:01 AM, pancake  wrote:

> I found this chess implementation in obfuscated C. I'm sure than cleaning
> it up
> (deobfuscating it) will make it ready to be in the cathegory of "suckless
> games"
>
>  
> http://nanochess.110mb.codemandm/chess1_es.html
>
> What do you think about creating a 'sgames' project? collecting
> minimalistic simple
> games? I wrote a word guess game few time ago named 'wg' which can be
> merged
> into this project.
>
> --pancake
>
> A nice idea, I'm fond of little console games, that do not consume much of
your time.
I will give it a try if we have some.
Tian


Re: [dev] suckless games collection?

2011-05-26 Thread pancake

On 05/26/11 10:58, Le Tian wrote:



On Thu, May 26, 2011 at 5:01 AM, pancake > wrote:


I found this chess implementation in obfuscated C. I'm sure than
cleaning it up
(deobfuscating it) will make it ready to be in the cathegory of
"suckless games"

http://nanochess.110mb.codemandm/chess1_es.html


What do you think about creating a 'sgames' project? collecting
minimalistic simple
games? I wrote a word guess game few time ago named 'wg' which can
be merged
into this project.

--pancake

A nice idea, I'm fond of little console games, that do not consume 
much of your time.

I will give it a try if we have some.
Tian

http://lolcathost.org/b/wg.tar.gz

i think this is the last version i have... i should check my laptops and 
timestamps




Re: [dev] suckless games collection?

2011-05-26 Thread pancake

On 05/26/11 10:58, Le Tian wrote:



On Thu, May 26, 2011 at 5:01 AM, pancake > wrote:


I found this chess implementation in obfuscated C. I'm sure than
cleaning it up
(deobfuscating it) will make it ready to be in the cathegory of
"suckless games"

http://nanochess.110mb.codemandm/chess1_es.html


What do you think about creating a 'sgames' project? collecting
minimalistic simple
games? I wrote a word guess game few time ago named 'wg' which can
be merged
into this project.

--pancake

A nice idea, I'm fond of little console games, that do not consume 
much of your time.

I will give it a try if we have some.
Tian
well.. this is not 'suckless', but a funny text mode game i wrote many 
years ago.. dont read
the code..as long as it's write-only. I decided to code this game only 
when I was drunk, it
results in an interesting experiment, because when drunk all the code 
take sense and you
can patch or add stuff without problems, but without alcohol, the code 
just sucks.


It's a text based platform game. The maps are just text files that can 
be done with any

text editor.

  http://hg.youterm.com/pag/

About LOCs.. it's 760LOC in C. But the code should be cleaned up and 
probably refactorized.


--pancake



Re: [dev] suckless games collection?

2011-05-26 Thread Le Tian
On Thu, May 26, 2011 at 5:16 AM, pancake  wrote:

> On 05/26/11 10:58, Le Tian wrote:
>
>>
>>
>> On Thu, May 26, 2011 at 5:01 AM, pancake > panc...@youterm.com>> wrote:
>>
>>I found this chess implementation in obfuscated C. I'm sure than
>>cleaning it up
>>(deobfuscating it) will make it ready to be in the cathegory of
>>"suckless games"
>>
>>http://nanochess.110mb.codemandm/chess1_es.html
>>
>>
>>
>>What do you think about creating a 'sgames' project? collecting
>>minimalistic simple
>>games? I wrote a word guess game few time ago named 'wg' which can
>>be merged
>>into this project.
>>
>>--pancake
>>
>> A nice idea, I'm fond of little console games, that do not consume much of
>> your time.
>> I will give it a try if we have some.
>> Tian
>>
> well.. this is not 'suckless', but a funny text mode game i wrote many
> years ago.. dont read
> the code..as long as it's write-only. I decided to code this game only when
> I was drunk, it
> results in an interesting experiment, because when drunk all the code take
> sense and you
> can patch or add stuff without problems, but without alcohol, the code just
> sucks.
>
> It's a text based platform game. The maps are just text files that can be
> done with any
> text editor.
>
>  http://hg.youterm.com/pag/
>
> About LOCs.. it's 760LOC in C. But the code should be cleaned up and
> probably refactorized.
>
> --pancake
>
> "I decided to code this game only when I was drunk" lol!
some man or help would be nice, can't figure out the rules
-- 
Tian


Re: [dev] mret

2011-05-26 Thread hiro
> Being able to queue commands would be nice for the use case
> of playing something in mplayer, then realising in the next
> few minutes it will come to an end and wanting to append
> something else. I'm aware less command-centric media players
> can do this, but I am rather fond of mplayer.

mplayer has the -quiet flag at least, I'm quite sure you can disable
it's interactive features, too. I just don't want to read the man
"page".



Re: [dev] Sandy editor

2011-05-26 Thread hiro
Anselm please make HTML mails bounce. Every year at my birthday I get
HTML mail with happy smileys and large, colored, full-caps fonts. I
tried to read suckless instead and now I got eye cancer.
I'll also leave the last piece of cake for you.



[dev] [st] code cleanup

2011-05-26 Thread anonymous
Attached.
diff -r 2effc50d2c4f st.c
--- a/st.c  Sun May 22 16:57:27 2011 +0200
+++ b/st.c  Thu May 26 14:30:53 2011 +0400
@@ -473,8 +473,7 @@
 
 void
 selnotify(XEvent *e) {
-   unsigned long nitems;
-   unsigned long ofs, rem;
+   unsigned long nitems, ofs, rem;
int format;
unsigned char *data;
Atom type;
@@ -484,7 +483,7 @@
if(XGetWindowProperty(xw.dpy, xw.win, XA_PRIMARY, ofs, BUFSIZ/4,
False, AnyPropertyType, &type, &format,
&nitems, &rem, &data)) {
-   fprintf(stderr, "Clipboard allocation failed\n");
+   fputs("Clipboard allocation failed\n", stderr);
return;
}
ttywrite((const char *) data, nitems * format / 8);
@@ -531,7 +530,7 @@
 
/* all done, send a notification to the listener */
if(!XSendEvent(xsre->display, xsre->requestor, True, 0, (XEvent *) 
&xev))
-   fprintf(stderr, "Error sending SelectionNotify event\n");
+   fputs("Error sending SelectionNotify event\n", stderr);
 }
 
 void
@@ -594,8 +593,7 @@
 void
 bmotion(XEvent *e) {
if(sel.mode) {
-   int oldey = sel.ey,
-   oldex = sel.ex;
+   int oldey = sel.ey, oldex = sel.ex;
getbuttoninfo(e, NULL, &sel.ex, &sel.ey);
 
if(oldey != sel.ey || oldex != sel.ex) {
@@ -675,7 +673,7 @@
static int col;
fprintf(stderr, " %02x '%c' ", c, isprint(c)?c:'.');
if(++col % 10 == 0)
-   fprintf(stderr, "\n");
+   fputc('\n', stderr);
 }
 
 void
@@ -753,7 +751,7 @@
term.row = row, term.col = col;
term.line = malloc(term.row * sizeof(Line));
term.alt  = malloc(term.row * sizeof(Line));
-   for(row = 0 ; row < term.row; row++) {
+   for(row = 0; row < term.row; row++) {
term.line[row] = malloc(term.col * sizeof(Glyph));
term.alt [row] = malloc(term.col * sizeof(Glyph));
}
@@ -1007,7 +1005,7 @@
switch(escseq.mode) {
default:
unknown:
-   fprintf(stderr, "erresc: unknown csi ");
+   fputs("erresc: unknown csi ", stderr);
csidump();
/* die(""); */
break;


Re: [dev] Sandy editor

2011-05-26 Thread Yoshi Rokuko
+--- Rafa Garcia Gallego ---+
> >
> > * I tend to prefer a mode editor, because there are less keybindings
[...]
> 
> I too have mixed feelings about this. On one hand modeless editing
> seems saner and we shouldn't really need that many commands. On the
> other hand, vi-like modal editing feels so powerful it is almost a
> pity to abandon.
>

i tend to prefer a modeless editor - we shouldn't need that many commands
 
> > these ones will be saner (without modes):
> > - ^[hjkl] - move around
> > - ^[HJKL] - move around selecting text
> > - ^[fb] - go next/prev page
> > - ^[np] - go next/prev page
> > - ^k - find manpage on word under cursor
> > - ^w - save
> > - ^W - save as
> > - ^q - quit
> > - ^Z - save+quit (it's similar to vim's ZZ)
> > - ^! - prompt to run program on selected/full text (indent, etc..)
> > - ^z - must not be handled, because it's used by the shell for
> > backgrounding apps
> 
> Those seem fine for now. There should be something to move around
> word-by-word (and also reminder to self: I have to reimplement
> word-by-word movement).
>

what we really want is:
^U -> Delete from cursor to start of line.
^W -> Delete word before the cursor.
^H -> Delete character before the cursor.
^A -> Move cursor to start of the line.
^E -> Move cursor to end of the line.

regards, yoshi 




Re: [dev] Re: sbase

2011-05-26 Thread Connor Lane Smith
On 26 May 2011 07:39, Anselm R Garbe  wrote:
> As for sbase I'm still sceptical this is a good idea as it
> re-implements perfectly sound 9base tools, but avoids the real tricky
> ones such as rc, mk or awk.

I, basically, disagree. The Plan 9 tools were written for another
operating system: ls has no -a flag, but you can use -q to list the 9P
QIDs? Fantastic. You can't distinguish between a failed match and an
error in grep, because Plan 9's exit returns a string? Even better.

No other utils that I have found are designed just to be simple and
hackable, with only a few useful flags, and not all the cruft. There's
9base, but all the benefits Plan 9 brings are totally screwed by the
marshalling back into Unix. Using P9P is a compromise, not an
alternative userspace.

-rwxr-xr-x  1 cls cls 604908 May 26 11:47 9base/cat/cat
-rwxr-xr-x  1 cls cls  21268 May 26 11:47 sbase/cat

My intention is to build a userspace for Unix which is very simple
(see my earlier post), and actually *designed* for Unix, not just a
compatibility shim. I tend to prefer Unix tools which are actually,
you know, Unix tools.

Regarding awk, we should probably use bwk. I haven't decided what to
do about make or the shell, yet.

Thanks,
cls



Re: [dev] [dwm] Button ClkStatusText + xinerama

2011-05-26 Thread Nicolas Capit
Hello,

I just tried to change this part of the code:

diff -r ba590e72eb2a dwm.c
--- a/dwm.c Sat May 21 20:26:26 2011 +0100
+++ b/dwm.c Thu May 26 14:33:45 2011 +0200
@@ -442,7 +442,7 @@
}
else if(ev->x < x + blw)
click = ClkLtSymbol;
-   else if(ev->x > selmon->wx + selmon->ww - TEXTW(stext))
+   else if(ev->x > selmon->ww - TEXTW(stext))
click = ClkStatusText;
else
click = ClkWinTitle;

And it seems ok now. I am able to click on the status text as expected in
xinerama with 2 screens.
(so maybe the selmon->ww refers from the left of the xinerama and not just of
the screen???)

Do you think this patch could have a side effect?
And if it is ok, could you add this for the next release?

Thanks,
capitn

On Thu, 28 Apr 2011 12:35:59 +
Anselm R Garbe  wrote:

> Hi,
> 
> On Thu, Apr 28, 2011 at 02:32:47PM +0200, Nicolas Capit wrote:
> > I configured dwm (5.9) with something like this in config.h:
> > 
> > static Button buttons[] = {
> > /* clickevent mask  button  function
> > argument */
> > { ClkStatusText,0,  Button1,spawn,  
> > {.v = (const char*[]){"xclock", NULL}} },
> > ...
> > 
> > Everything works fine with 1 screen: When I click on the status text then a
> > xclock appears.
> > 
> > If I plug another screen to my configuration with xinerama config then this
> > behaviour works only on the first screen. If I click on the status text 
> > (when
> > it is displayed) on the second screen then it is like I click on the window
> > title (ClkWinTitle); no xclock.
> > 
> > I think there is something to do at line 446 of dwm.c to calculate the right
> > position of the status text in xinerama but I am not sure.
> > 
> > else if(ev->x > selmon->wx + selmon->ww - TEXTW(stext))
> > click = ClkStatusText;
> > 
> > If someone can take a look at this part of the code it will be great :-)
> 
> Thanks for reporting. Will look into this.
> 
> Thanks,
>   Anselm
> 
> 



Re: [dev] Sandy editor

2011-05-26 Thread pancake
i have noticed that the sucky terminal cannot handle shift+control, so 
my bindings for

^[hjkl] ^[HJKL] does not work... So i'll think in other keybindings for it..

Another thing that i have noticed is that you can't nest keybindings. 
This is, i want to have
a single key to save and quit, so i put the same key hook twice but 
first is saving, which popups
a filename dialog if no filename defined and if save is success then 
quits, else just shows an

error.

This is probably the only case there I think this is useful, so it will 
be probably better to

define a specific function instead of nesting keybindings.

What do you think?

On 05/26/11 13:53, Yoshi Rokuko wrote:

+--- Rafa Garcia Gallego ---+

* I tend to prefer a mode editor, because there are less keybindings

[...]

I too have mixed feelings about this. On one hand modeless editing
seems saner and we shouldn't really need that many commands. On the
other hand, vi-like modal editing feels so powerful it is almost a
pity to abandon.


i tend to prefer a modeless editor - we shouldn't need that many commands


these ones will be saner (without modes):
- ^[hjkl] - move around
- ^[HJKL] - move around selecting text
- ^[fb] - go next/prev page
- ^[np] - go next/prev page
- ^k - find manpage on word under cursor
- ^w - save
- ^W - save as
- ^q - quit
- ^Z - save+quit (it's similar to vim's ZZ)
- ^! - prompt to run program on selected/full text (indent, etc..)
- ^z - must not be handled, because it's used by the shell for
backgrounding apps

Those seem fine for now. There should be something to move around
word-by-word (and also reminder to self: I have to reimplement
word-by-word movement).


what we really want is:
^U ->  Delete from cursor to start of line.
^W ->  Delete word before the cursor.
^H ->  Delete character before the cursor.
^A ->  Move cursor to start of the line.
^E ->  Move cursor to end of the line.

regards, yoshi







Re: [dev] Sandy editor

2011-05-26 Thread Connor Lane Smith
On 26 May 2011 14:14, pancake  wrote:
> i have noticed that the sucky terminal cannot handle shift+control, so my
> bindings for
> ^[hjkl] ^[HJKL] does not work... So i'll think in other keybindings for it..

This is the problem with curses: it's the common denominator, and as a
result is rather awful. I honestly think a true 'suckless editor' has
to drop curses in favour of actually being able to interact with
keyboard events, instead of just reading a stream of escape sequences.
That doesn't really help with sandy, admittedly, but I think it's
worth keeping in mind.

cls



Re: [dev] Sandy editor

2011-05-26 Thread pancake

On 05/26/11 01:33, Rafa Garcia Gallego wrote:

Hi,

Thanks a lot for your detailed mail.

On Thu, May 26, 2011 at 12:33 AM, pancake  wrote:

About moving sandy to hg.suckless.orgshould be discussed with Anselm. We can
setup a cron sync to clone your repo.. But it would be better to have it
there.

I'm fine with moving the main repo to suckless.org. I'm not specially
attached to sourceforge.
sourceforge sucks a lot. full of security bugs, filled with banners, 
bloated interface... i would prefer to fetch suckless code from a 
suckless site :)

I think this editor fits very well in the suckless philosophy and project.
Maybe other projects like star should then also move.. So this requires some
discussion in other trhread.

I'm glad you think that :-D.


Anselm?

BUGS:

bug1) In BSDs regcomp(3) if you pass "" as first argument, you get a
segfault.

I didn't really have a BSD at hand to test it. I have tried applying
your patch about this, but it seems to make sandy segfault in my linux
if I open a .c file. It's late, I'll try again tomorrow.


yep, my patch is not right at all.. i have noticed that there are other 
regexpes that does not compile well without a GNU libc.. what about 
musl? sandy runs fine if you just remove the i_die() when regcomp() fails.


In fact, i dont think an editor should not allow you to edit a file 
because a highlight regexp does not compiles :) I would make this 
silently fail. And prepare a bunch of regexp test suite to ensure 
everything works in all available libc's.

bug2) Segfault I commented in the previous mail

I was able to reproduce the segfault:

   - write some text
   - press ^x
   - move cursor to select some text
   - press 'y'
   - got segflute in sandy.c:636

Applied, thanks!



NOTES
=
* ncurses sucks. but it's the only portable solution atm. at some point we
can
  write a suckless curses library, removing all the old stuff and make it
cleaner.
  - So.. minor changes would be required to make your editor run without
ncurses.

That'd really be great. I tried to get it working against pdcurses,
but then I couldn't select() stdin and the command pipe at the same
time. I looked for a fd to select() for input and got tired of
pdcurses soon :)


yep.. i saw some comments talking about nonblocking stdin problems.. so 
this should be rethinked/bugfixed.


In r2 i wrote libr_cons, a library for working on text mode on *nix and 
w32 terminals without depending on curses. We can get code from there to 
build our

curses-like-suckless-library.

* Remove utf8 enable/disable option. or make it compile-time option-only (-u
flag)
  - I think nowadays all our apps should be utf8 ready

Will do. You wouldn't belive how old can a Solaris installation get around, tho.


uhm, do we mind about crappy systems? I still think that sandy will work 
fine on a non-UTF8 terminal editing non-UTF8 text if you remove the 
display of hidden chars (tab, space)





* Non-printable characters are printed (i know this is in config.h)
  - I prefer not to see what it's not going to be seen
  - What do you guys like? do you
  - If you print those chars, I suggest you to also display \r and \n chars
  - Imho it's smarter if you just see the text

h. Do you mean printing non-printing characters like ^A? Or are
you talking about the funny little dots and arrows that appear in
place of spaces and tabs? I'm unsure about those.
im talking about the space+tab funny chars. those are utf8 and they 
would break on a non-utf8 console.. and just makes the code a little 
more complicated, without any aparent benefit (at least for me, i never 
display invisible chars in my coding sessions..)


btw, put this in config.h to remove those chars.

static const char   tabstr[3]  = { ' ', 0 };
static const char   spcstr[3]  = { ' ', 0 };

but I would like to discuss with the rest of ppl in the ml to know if 
somebody find useful to view those chars. Else i would prefer to get rid 
of them.


BTW; if you print those special chars, also print newline, as long as 
sometimes is useful to know if any line is longer than expected.


but IMHO i would prefer to drop it.

* Strings with escaped quotes are not correctly highlighted
* i_die does not resets terminal configuration

I called reset_shell_mode() there. Thanks!


good. much better now :)

* Linking fails in OSX because missing ncursesw name
  - there's a ncurses5-config that works like pkg-config and this
should be used to make this portable
  - Or just drop the 'w' in the ncursesw5 libname (-lncurses works fine)

Just dropped the 'w' for simplicity's sake. Thanks!



thanks

* I would prefer not to depend on dmenu/xsel
  - The terminal is usually implementing this copypasta into the Xselection
buffer
  - On OSX/WayLand/W32 takes no sense to use this
  - I have an implementation of dmenu in text mode (ANSI, without curses)
  - about xsel... i would prefer to be able to use copypasta, without
depending on X11
- write 'csel' which stores the buffer in a

Playing music (was: Re: [dev] mret)

2011-05-26 Thread Bjartur Thorlacius
On 5/26/11, hiro <23h...@googlemail.com> wrote:
> mplayer has the -quiet flag at least, I'm quite sure you can disable
> it's interactive features, too. I just don't want to read the man
> "page".
This. I'm on Windows ATM, but if I recall correctly:
xargs -n0 mplayer -slave -quiet &>/dev/null
Where -slave tells mplayer to not take over the shell. Buffer by line,
and detach and reattach as needed. And avoid spaces in filenames, as
xargs can't handle them, unless you do:
tr $'\n' '' |xargs -n0 mplayer -slave -quiet &>/dev/null
No idea wheather it works or not.
Assuming /n/songs is buffered linewise you may also consider:
xargs -n0 sh -c 'mplayer -slave >/n/nowplaying 

Re: Playing music (was: Re: [dev] mret)

2011-05-26 Thread hiro
Hmm. How do you "buffer linewise"?
I think sqweek did some nice playlist file system, I can't find it right now.



Re: [dev] Re: sbase

2011-05-26 Thread markus schnalke
[2011-05-26 07:39] Anselm R Garbe 
> 
> Afaik tac sucks more, as it is quite an arbitrary command, not part of
> Plan 9 and can be imitated with a awk one liner like
> 
> awk '{a[i++]=$0} END {for (j=i-1; j>=0;) print a[j--] }'

Okay, but who want's to type this line by hand?

IMO tac *should be included* in some Unix toolchain, but as a
shell/awk script, containing this line. This would be software
leverage.

Unfortunately it seems as if this concept is just too often handed
over to the administrators. If programs are distributed, people focus
on performance and write them in C instead ...



> Don't get me wrong, I think this sbase thing is a great excercise but
> I really do believe there is more interesting stuff that we should
> rather focus on.

I fully agree.


meillo



Re: [dev] Re: sbase

2011-05-26 Thread pancake
The tac.c i pushed few time ago is magnitudes faster than awk.

That was the reasom why nibble and me wrote it.

On 26/05/2011, at 20:45, markus schnalke  wrote:

> [2011-05-26 07:39] Anselm R Garbe 
>> 
>> Afaik tac sucks more, as it is quite an arbitrary command, not part of
>> Plan 9 and can be imitated with a awk one liner like
>> 
>> awk '{a[i++]=$0} END {for (j=i-1; j>=0;) print a[j--] }'
> 
> Okay, but who want's to type this line by hand?
> 
> IMO tac *should be included* in some Unix toolchain, but as a
> shell/awk script, containing this line. This would be software
> leverage.
> 
> Unfortunately it seems as if this concept is just too often handed
> over to the administrators. If programs are distributed, people focus
> on performance and write them in C instead ...
> 
> 
> 
>> Don't get me wrong, I think this sbase thing is a great excercise but
>> I really do believe there is more interesting stuff that we should
>> rather focus on.
> 
> I fully agree.
> 
> 
> meillo
> 



Re: [dev] Re: sbase

2011-05-26 Thread Kurt H Maier
Here is a half-assed old version of chmod, in the vein of v5 chmod.
It has a man page and informative ed-style error messages, but no
recursion or POSIX-style 'symbolic mode expressions.'  I'll refactor
it to use util/recurse later.  I don't really care about 'symbolic
mode expressions.'

-- 
# Kurt H Maier
/* See LICENSE file for copyright and license details. */
#include 
#include 
#include 
#include 
#include "util.h"

int
main(int argc, char *argv[])
{
  int retval, filecount, i;
  mode_t mode;
  char *input;
  
  mode = 0;
  filecount = argc-1;
  input = argv[1];

  if ( argc < 3 ) {
eprintf("?\n");
exit(EXIT_FAILURE);
  }

  while ( *input ) {
if (*input < '0' || *input > '7') {
  eprintf("?\n");
  exit(EXIT_FAILURE);
} 
mode = ( mode << 3 ) | ( *input - '0' ) ;
input++;
  }
  
  retval=0;
  for (i=2; i <= filecount; i++) {
 retval =  chmod( argv[i], mode ); 
	 if (retval != 0) { printf ("? \n");  }
  }
  exit(EXIT_SUCCESS);
 }


chmod.1
Description: Binary data


Re: [dev] Sandy editor

2011-05-26 Thread Rafa Garcia Gallego
Hi,

On Thu, May 26, 2011 at 3:14 PM, pancake  wrote:
> i have noticed that the sucky terminal cannot handle shift+control, so my
> bindings for
> ^[hjkl] ^[HJKL] does not work... So i'll think in other keybindings for it..

Yeah. If I recall, the old sandy prototype (ugly gtk+) used
Control+Shift keybindings, but they went away when I noticed terminal
emulators don't report them as such. Once you press Ctrl, the next key
you hit gives you one control char. That's it. Not sure it's a curses
thing as much as a terminal limitation.


> Another thing that i have noticed is that you can't nest keybindings. This
> is, i want to have
> a single key to save and quit, so i put the same key hook twice but first is
> saving, which popups
> a filename dialog if no filename defined and if save is success then quits,
> else just shows an
> error.
> This is probably the only case there I think this is useful, so it will be
> probably better to
> define a specific function instead of nesting keybindings.
> What do you think?

That's definitely keep the source simpler and I'm not sure we need
chain keybindings. You can define the conditions (e.g. t_mod) and get
it to do a different thing depending on whether the file has been
modified or not (somewhat close to what Ctrl-Q does right now). If in
need, you can write your own t_ function real easy.


On Thu, May 26, 2011 at 5:44 PM, pancake  wrote:
> sourceforge sucks a lot. full of security bugs, filled with banners, bloated
> interface... i would prefer to fetch suckless code from a suckless site :)

Great then. So long sourceforge, hello suckless.


> Anselm?

He already asked my for my ssh key :)


> yep, my patch is not right at all.. i have noticed that there are other
> regexpes that does not compile well without a GNU libc.. what about musl?
> sandy runs fine if you just remove the i_die() when regcomp() fails.

I'm not even sure all embedded libc variants have a regex engine
(maybe bionic didn't when I looked at it a while back? I don't really
remember). We absolutely should get rid of a GNU dependency if
possible, compile to static, use a saner curses implementation if
there is any.


> In fact, i dont think an editor should not allow you to edit a file because
> a highlight regexp does not compiles :) I would make this silently fail. And
> prepare a bunch of regexp test suite to ensure everything works in all
> available libc's.

Maybe that's right. The thing may fail also if you search for an empty
regex tho. I should probably try to get my hands on a BSD box to try
these things. Maybe using libc's regcomp/regexec was not that
realiable after all. Any saner alternatives?


> yep.. i saw some comments talking about nonblocking stdin problems.. so this
> should be rethinked/bugfixed.
>
> In r2 i wrote libr_cons, a library for working on text mode on *nix and w32
> terminals without depending on curses. We can get code from there to build
> our
> curses-like-suckless-library.

Well, if there is a suckless framework (gods, do I hate that word!),
be it "slcurses", or a suckless X toolkit really, to write a text-only
program, I'd be glad to find time and port sandy to that.

Writing the framework itself is probably out of my scope right now, sadly.


>>> * Remove utf8 enable/disable option. or make it compile-time option-only
>>> (-u
>>> flag)
>>>  - I think nowadays all our apps should be utf8 ready
>>
>> Will do. You wouldn't belive how old can a Solaris installation get
>> around, tho.
>>
>>
> uhm, do we mind about crappy systems? I still think that sandy will work
> fine on a non-UTF8 terminal editing non-UTF8 text if you remove the display
> of hidden chars (tab, space)

Yeah, you got me on this one. I'll drop the flag, declare isutf8 a
const and let everyone figure it out. Will push when the repo is
hosted at suckless.


>>> * Non-printable characters are printed (i know this is in config.h)
>>>  - I prefer not to see what it's not going to be seen
>>>  - What do you guys like? do you
>>>  - If you print those chars, I suggest you to also display \r and \n
>>> chars
>>>  - Imho it's smarter if you just see the text
>>
>> h. Do you mean printing non-printing characters like ^A? Or are
>> you talking about the funny little dots and arrows that appear in
>> place of spaces and tabs? I'm unsure about those.
>
> im talking about the space+tab funny chars. those are utf8 and they would
> break on a non-utf8 console.. and just makes the code a little more
> complicated, without any aparent benefit (at least for me, i never display
> invisible chars in my coding sessions..)
>
> btw, put this in config.h to remove those chars.
>
> static const char   tabstr[3]  = { ' ', 0 };
> static const char   spcstr[3]  = { ' ', 0 };
>
> but I would like to discuss with the rest of ppl in the ml to know if
> somebody find useful to view those chars. Else i would prefer to get rid of
> them.
>
> BTW; if you print those special chars, also print newline, as long as
> sometimes is us

Re: [dev] Sandy editor

2011-05-26 Thread Rafa Garcia Gallego
Hey,

On Thu, May 26, 2011 at 10:41 AM, Hiltjo Posthuma
 wrote:
> I agree with pancake. I also noticed the selection of text using the
> mouse is very laggy / slow (using xterm). Anyway I'll keep an eye on
> this project since it seems promising to me.

That might be the screen updating every time you move the mouse. You
probably have a 64bit ncurses with NCURSES_MOUSE_VERSION 2 (or
greater?).

If you try defining NCURSES_MOUSE_VERSION to 1, you'll get what I have
in my netbook: fast mouse selection without screen updates
(REPORT_MOUSE_POSITION simply does not fit in the mouse mask, yet
another example of why ncurses sucks).

Cheers,
Rafa.



Re: [dev] Sandy editor

2011-05-26 Thread Rafa Garcia Gallego
On Thu, May 26, 2011 at 9:53 PM, Rafa Garcia Gallego
 wrote:
> I'll take a quick look at the quote regexes now, but since I don't
> really know which are working where :S I hope nothing bad comes out of
> this.

That was really dumb. I defined the regexes to match for a quoted text
(several times) as (read as a C string):

"\"(\\.|[^\"])*\""

when I meant:

"\"(.|[^\"])*\""

AFAIK \. is not standard regex, whereas \\ is. But I forgot to
double-escape in C. Fixed in local, will push to tip.

Sorry for the noise.



Re: [dev] Sandy editor

2011-05-26 Thread Hiltjo Posthuma
> That might be the screen updating every time you move the mouse. You
> probably have a 64bit ncurses with NCURSES_MOUSE_VERSION 2 (or
> greater?).

I run 32-bit ncurses (i686).

> If you try defining NCURSES_MOUSE_VERSION to 1, you'll get what I have
> in my netbook: fast mouse selection without screen updates
> (REPORT_MOUSE_POSITION simply does not fit in the mouse mask, yet
> another example of why ncurses sucks).

Thanks I'll give that a try.



Re: [dev] Sandy editor

2011-05-26 Thread pancake
Im in the irc.oftc.net#suckless right now.

On 26/05/2011, at 21:53, Rafa Garcia Gallego  
wrote:

> Hi,
> 
> On Thu, May 26, 2011 at 3:14 PM, pancake  wrote:
>> i have noticed that the sucky terminal cannot handle shift+control, so my
>> bindings for
>> ^[hjkl] ^[HJKL] does not work... So i'll think in other keybindings for it..
> 
> Yeah. If I recall, the old sandy prototype (ugly gtk+) used
> Control+Shift keybindings, but they went away when I noticed terminal
> emulators don't report them as such. Once you press Ctrl, the next key
> you hit gives you one control char. That's it. Not sure it's a curses
> thing as much as a terminal limitation.
> 

Maybe its a terminal limitation.. I think emacs this this my chaining over nine 
thousand control keycodes.
> 
>> Another thing that i have noticed is that you can't nest keybindings. This
>> is, i want to have
>> a single key to save and quit, so i put the same key hook twice but first is
>> saving, which popups
>> a filename dialog if no filename defined and if save is success then quits,
>> else just shows an
>> error.
>> This is probably the only case there I think this is useful, so it will be
>> probably better to
>> define a specific function instead of nesting keybindings.
>> What do you think?
> 
> That's definitely keep the source simpler and I'm not sure we need
> chain keybindings. You can define the conditions (e.g. t_mod) and get
> it to do a different thing depending on whether the file has been
> modified or not (somewhat close to what Ctrl-Q does right now). If in
> need, you can write your own t_ function real easy.
> 

Ok.  Will try that way
> 
> On Thu, May 26, 2011 at 5:44 PM, pancake  wrote:
>> sourceforge sucks a lot. full of security bugs, filled with banners, bloated
>> interface... i would prefer to fetch suckless code from a suckless site :)
> 
> Great then. So long sourceforge, hello suckless.
> 
> 
>> Anselm?
> 
> He already asked my for my ssh key :)
> 

Yay. Anselm is silent. 
> 
>> yep, my patch is not right at all.. i have noticed that there are other
>> regexpes that does not compile well without a GNU libc.. what about musl?
>> sandy runs fine if you just remove the i_die() when regcomp() fails.
> 
> I'm not even sure all embedded libc variants have a regex engine
> (maybe bionic didn't when I looked at it a while back? I don't really
> remember). We absolutely should get rid of a GNU dependency if
> possible, compile to static, use a saner curses implementation if
> there is any.
> 

Not really :/ unless we write one or use the one in awk.
> 
>> In fact, i dont think an editor should not allow you to edit a file because
>> a highlight regexp does not compiles :) I would make this silently fail. And
>> prepare a bunch of regexp test suite to ensure everything works in all
>> available libc's.
> 
> Maybe that's right. The thing may fail also if you search for an empty
> regex tho. I should probably try to get my hands on a BSD box to try
> these things. Maybe using libc's regcomp/regexec was not that
> realiable after all. Any saner alternatives?
> 
> 
>> yep.. i saw some comments talking about nonblocking stdin problems.. so this
>> should be rethinked/bugfixed.
>> 
>> In r2 i wrote libr_cons, a library for working on text mode on *nix and w32
>> terminals without depending on curses. We can get code from there to build
>> our
>> curses-like-suckless-library.
> 
> Well, if there is a suckless framework (gods, do I hate that word!),
> be it "slcurses", or a suckless X toolkit really, to write a text-only
> program, I'd be glad to find time and port sandy to that.
> 

What about naming it Cursless? I think dvtm did some work on it.

> Writing the framework itself is probably out of my scope right now, sadly.
> 

Yep. Its not something to focus now.
> 
 * Remove utf8 enable/disable option. or make it compile-time option-only
 (-u
 flag)
 - I think nowadays all our apps should be utf8 ready
>>> 
>>> Will do. You wouldn't belive how old can a Solaris installation get
>>> around, tho.
>>> 
>>> 
>> uhm, do we mind about crappy systems? I still think that sandy will work
>> fine on a non-UTF8 terminal editing non-UTF8 text if you remove the display
>> of hidden chars (tab, space)
> 
> Yeah, you got me on this one. I'll drop the flag, declare isutf8 a
> const and let everyone figure it out. Will push when the repo is
> hosted at suckless.
> 

Why not just remove that utf const?
> 
 * Non-printable characters are printed (i know this is in config.h)
 - I prefer not to see what it's not going to be seen
 - What do you guys like? do you
 - If you print those chars, I suggest you to also display \r and \n
 chars
 - Imho it's smarter if you just see the text
>>> 
>>> h. Do you mean printing non-printing characters like ^A? Or are
>>> you talking about the funny little dots and arrows that appear in
>>> place of spaces and tabs? I'm unsure about those.
>> 
>> im talking about the space+tab funny 

Re: [dev] Sandy editor

2011-05-26 Thread John Matthewman
Hi there - I had been looking for a simple little editor for a while.
Thanks for sharing.

On 5/27/11, Rafa Garcia Gallego  wrote:
> That is indeed a great idea. I'll try to stick with the UNIX defaults,
> fill in with Emacs when in doubt and remove META when possible.

Yea, probably a good idea (of course, ignoring Emacs' chained
keybindings). Sandy would benefit from a better set of default
bindings. Though for reference you might want to look at something
like mg [http://www.openbsd.org/cgi-bin/man.cgi?query=mg], or one of
the other micro Emacs implementations, as they'll have the most
important bindings and commands, and you won't have to sift through
all of the extra garbage that is Emacs.

I also have two wishes:

- Make it possible to turn off highlighting (syntax highlighting,
highlighting the current line) and colour. I'm sure I'm not the only
person who doesn't need that stuff..?
- Keep it as a modeless editor! ;)

John