gnugo-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnugo-devel] gnugo Readline Support? (patches attached)


From: Andrew S. Morrison
Subject: [gnugo-devel] gnugo Readline Support? (patches attached)
Date: Tue, 28 Oct 2003 13:39:36 -0500
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030624

I like gnugo very much. I ran to the mall to buy a go board the other day, but found my go needs unfulfilled - so of course I turned to my computer.

Besides liking gnugo, I also like GNU Readline, so I added optional readline support to gnugo-3.4. I was a bit unhappy with the lack of good command line editing going on and thought others might be too ... It can be configured in with

> ./configure --with-readline

The default is to not use readline. If --with-readline is given, it'll check for the required libraries and if they're available, add them to LIBS, and #define READLINE 1. interface/play_ascii.c has a preprocessor if block checking to see if READLINE is defined. If not, it does the normal thing. Otherwise, it'll get a string using readline and put it in readline history. It will free the line returned from readline after the command has been processed.

I've attached a patch for configure.in and play_ascii.c - on the off chance that adding readline support is worth your time :)

Thanks again for gnugo!


Andrew Morrison
address@hidden
31,34d30
< AC_ARG_WITH(readline,
<  [  --with-readline     try to use GNU readline for command reading
<   --without-readline  do not use GNU readline (default)])
< 
279,292d274
< dnl -------- redline support -------------------
< 
< if test "$with_readline" != no ; then
< 
<     dnl check for a working termcap and readline library
<     AC_SEARCH_LIBS(termcap,readline)
< 
<     if test "$ac_cv_search_tparm" != "no" ; then
<       AC_DEFINE(READLINE,1,[Enable GNU Readline support])
<       LIBS="$LIBS -lreadline -ltermcap"
<     fi
<       
< fi
< 
30,34d29
< #ifdef READLINE
< # include <readline/readline.h>
< # include <readline/history.h>
< #endif
< 
635,636c630
< 
< #ifndef READLINE
---
>       
638c632
<               mprintf("%s(%d): ", color_to_string(gameinfo->to_move), movenum 
+ 1);
---
>       mprintf("%s(%d): ", color_to_string(gameinfo->to_move), movenum + 1);
641,653c635,639
<               line_ptr = line;
<               if (!fgets(line, 80, stdin)) {
<                       printf("\nThanks! for playing GNU Go.\n\n");
<                       return ;
<               }
< #else
<               snprintf(line,79,"%s(%d): ", 
color_to_string(gameinfo->to_move), movenum+1);
<               if(!(line_ptr = readline(line))) {
<                       printf("\nThanks! for playing GNU go.\n\n");
<                       return;
<               }
<               add_history(line_ptr);
< #endif
---
>       line_ptr = line;
>       if (!fgets(line, 80, stdin)) {
>       printf("\nThanks! for playing GNU Go.\n\n");
>       return ;
>       }
992,995d977
< #ifdef READLINE
<       free(line_ptr);
< #endif
< 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]