Re: [dwm] dietline - minimalistic readline implementation

From: pancake <pancake_AT_youterm.com>
Date: Wed, 23 Jan 2008 16:43:53 +0100

Oops I forgot to say that it supports a dmenu-mode (this code inherits from
the old eread program I send to the list few months ago).

Usage is quite simple:

int main(int argc, char **argv)
{
        char *ret;

        dl_init();
        dl_prompt = "$ ";

        do {
                ret = dl_readline(argc, argv);
                if (ret) {
                        printf(" [line] '%s'\n", ret);
                        dl_hist_add(ret);
                }
        } while(ret!=NULL);

        dl_free();
}

Have fun!

--pancake

On Wed, Jan 23, 2008 at 04:31:57PM +0100, pancake wrote:
> As I request in a previous mail I have developed a readline-like
> library in a minimalistic way avoiding the unnecessary overhead
> and dependency with a single portable c file.
>
> I have tested this on NetBSD, GNU/linux and native w32 and works
> pretty fine.
>
> The library currently supports autocompletion of a single word
> using argc, argv (this is just a PoC). Allows to change the prompt,
> and change some configuration stuff for it.
>
> No vi or emacs mode yet (should i read inputrc?).
>
> Current support:
>
> - history log
> - navigate history with ^n/^p or up/down keys
> - autocompletion for one keyword (no nested yet)
> - tab key hooked for autocompletion
> - support to change the prompt
> - handle ^C and ^D
>
> You can download the implementation here:
>
> http://news.nopcode.org/dietline.c
>
> To test it on w32 just put __UNIX__ to 0 and __WINDOWS__ to 1 :)
>
> $ gcc dietline.c
> $ ./a.out foo bar foobar foocowblob foocowguai
> = foo<tab>
> foo foobar foocowblob foocowguai
> = foocow<tab>
> foocowblob foocowguai
> = foocowb<tab>
> = foocowblob
>
> I plan to use this library instead of readline for radare (radare.nopcode.org)
> so I plan to continue working on it.
>
> Patches and ideas are welcome.
>
> --pancake
>
Received on Wed Jan 23 2008 - 15:05:51 UTC

This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 15:16:52 UTC