Index: interface/debugboard/.cvsignore =================================================================== RCS file: interface/debugboard/.cvsignore diff -N interface/debugboard/.cvsignore --- interface/debugboard/.cvsignore 18 Dec 2001 19:23:59 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,3 +0,0 @@ -Makefile -.deps -debugboard Index: interface/debugboard/Makefile.am =================================================================== RCS file: interface/debugboard/Makefile.am diff -N interface/debugboard/Makefile.am --- interface/debugboard/Makefile.am 8 Feb 2004 00:47:23 -0000 1.5 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,30 +0,0 @@ -EXTRA_PROGRAMS = debugboard - -EXTRA_DIST = - -noinst_HEADERS = display.h gui.h - -# Remove these files here... they are created locally -DISTCLEANFILES = *~ - -INCLUDES = \ - -I$(top_srcdir)/sgf \ - -I$(top_srcdir)/engine \ - -I$(top_srcdir)/interface \ - -I$(top_srcdir)/utils - - -LDADD = \ - $(top_builddir)/engine/libengine.a \ - $(top_builddir)/patterns/libpatterns.a \ - $(top_builddir)/sgf/libsgf.a \ - $(top_builddir)/utils/libutils.a - -debugboard_SOURCES = \ - main.c \ - gui.c \ - display.c - -AIXOPTS=-O -qmaxmem=16384 -qro -qroconst -qinfo - -# OPTIONS=$(AIXOPTS) Index: interface/debugboard/Makefile.in =================================================================== RCS file: interface/debugboard/Makefile.in diff -N interface/debugboard/Makefile.in --- interface/debugboard/Makefile.in 12 Jan 2005 16:34:28 -0000 1.28 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,316 +0,0 @@ -# Makefile.in generated automatically by automake 1.5 from Makefile.am. - -# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 -# Free Software Foundation, Inc. -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ - -SHELL = @SHELL@ - -srcdir = @srcdir@ -top_srcdir = @top_srcdir@ -VPATH = @srcdir@ -prefix = @prefix@ -exec_prefix = @exec_prefix@ - -bindir = @bindir@ -sbindir = @sbindir@ -libexecdir = @libexecdir@ -datadir = @datadir@ -sysconfdir = @sysconfdir@ -sharedstatedir = @sharedstatedir@ -localstatedir = @localstatedir@ -libdir = @libdir@ -infodir = @infodir@ -mandir = @mandir@ -includedir = @includedir@ -oldincludedir = /usr/include -pkgdatadir = $(datadir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -top_builddir = ../.. - -ACLOCAL = @ACLOCAL@ -AUTOCONF = @AUTOCONF@ -AUTOMAKE = @AUTOMAKE@ -AUTOHEADER = @AUTOHEADER@ - -INSTALL = @INSTALL@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_HEADER = $(INSTALL_DATA) -transform = @program_transform_name@ -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -AMTAR = @AMTAR@ -AWK = @AWK@ -CC = @CC@ -CPP = @CPP@ -DEPDIR = @DEPDIR@ -EXEEXT = @EXEEXT@ -GCC_MAJOR_VERSION = @GCC_MAJOR_VERSION@ -GCC_MINOR_VERSION = @GCC_MINOR_VERSION@ -GNU_GO_WARNINGS = @GNU_GO_WARNINGS@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -MAINT = @MAINT@ -OBJEXT = @OBJEXT@ -PACKAGE = @PACKAGE@ -RANLIB = @RANLIB@ -VERSION = @VERSION@ -am__include = @am__include@ -am__quote = @am__quote@ -glibconfig = @glibconfig@ -install_sh = @install_sh@ - -EXTRA_PROGRAMS = debugboard - -EXTRA_DIST = - -noinst_HEADERS = display.h gui.h - -# Remove these files here... they are created locally -DISTCLEANFILES = *~ - -INCLUDES = \ - -I$(top_srcdir)/sgf \ - -I$(top_srcdir)/engine \ - -I$(top_srcdir)/interface \ - -I$(top_srcdir)/utils - - -LDADD = \ - $(top_builddir)/engine/libengine.a \ - $(top_builddir)/patterns/libpatterns.a \ - $(top_builddir)/sgf/libsgf.a \ - $(top_builddir)/utils/libutils.a - - -debugboard_SOURCES = \ - main.c \ - gui.c \ - display.c - - -AIXOPTS = -O -qmaxmem=16384 -qro -qroconst -qinfo -subdir = interface/debugboard -mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs -CONFIG_HEADER = $(top_builddir)/config.h -CONFIG_CLEAN_FILES = -EXTRA_PROGRAMS = debugboard$(EXEEXT) -am_debugboard_OBJECTS = main.$(OBJEXT) gui.$(OBJEXT) display.$(OBJEXT) -debugboard_OBJECTS = $(am_debugboard_OBJECTS) -debugboard_LDADD = $(LDADD) -debugboard_DEPENDENCIES = $(top_builddir)/engine/libengine.a \ - $(top_builddir)/patterns/libpatterns.a \ - $(top_builddir)/sgf/libsgf.a $(top_builddir)/utils/libutils.a -debugboard_LDFLAGS = - -DEFS = @DEFS@ -DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) -CPPFLAGS = @CPPFLAGS@ -LDFLAGS = @LDFLAGS@ -LIBS = @LIBS@ -depcomp = $(SHELL) $(top_srcdir)/depcomp -@AMDEP_TRUE@DEP_FILES = $(DEPDIR)/display.Po $(DEPDIR)/gui.Po \ -@AMDEP_TRUE@ $(DEPDIR)/main.Po -COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ - $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -CCLD = $(CC) -LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ -CFLAGS = @CFLAGS@ -DIST_SOURCES = $(debugboard_SOURCES) -HEADERS = $(noinst_HEADERS) - -DIST_COMMON = $(noinst_HEADERS) Makefile.am Makefile.in -SOURCES = $(debugboard_SOURCES) - -all: all-am - -.SUFFIXES: -.SUFFIXES: .c .o .obj -$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) - cd $(top_srcdir) && \ - $(AUTOMAKE) --gnu interface/debugboard/Makefile -Makefile: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.in $(top_builddir)/config.status - cd $(top_builddir) && \ - CONFIG_HEADERS= CONFIG_LINKS= \ - CONFIG_FILES=$(subdir)/$@ $(SHELL) ./config.status -debugboard$(EXEEXT): $(debugboard_OBJECTS) $(debugboard_DEPENDENCIES) - @rm -f debugboard$(EXEEXT) - $(LINK) $(debugboard_LDFLAGS) $(debugboard_OBJECTS) $(debugboard_LDADD) $(LIBS) - -mostlyclean-compile: - -rm -f *.$(OBJEXT) core *.core - -distclean-compile: - -rm -f *.tab.c - -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/display.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/gui.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/main.Po@am__quote@ - -distclean-depend: - -rm -rf $(DEPDIR) - -.c.o: -@AMDEP_TRUE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@ -@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ - $(COMPILE) -c `test -f $< || echo '$(srcdir)/'`$< - -.c.obj: -@AMDEP_TRUE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@ -@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ - $(COMPILE) -c `cygpath -w $<` -CCDEPMODE = @CCDEPMODE@ -uninstall-info-am: - -tags: TAGS - -ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) - list='$(SOURCES) $(HEADERS) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) ' { files[$$0] = 1; } \ - END { for (i in files) print i; }'`; \ - mkid -fID $$unique $(LISP) - -TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) - tags=; \ - here=`pwd`; \ - list='$(SOURCES) $(HEADERS) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) ' { files[$$0] = 1; } \ - END { for (i in files) print i; }'`; \ - test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \ - || etags $(ETAGS_ARGS) $$tags $$unique $(LISP) - -GTAGS: - here=`CDPATH=: && cd $(top_builddir) && pwd` \ - && cd $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) $$here - -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH - -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) - -top_distdir = ../.. -distdir = $(top_distdir)/$(PACKAGE)-$(VERSION) - -distdir: $(DISTFILES) - @for file in $(DISTFILES); do \ - if test -f $$file; then d=.; else d=$(srcdir); fi; \ - dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test "$$dir" != "$$file" && test "$$dir" != "."; then \ - $(mkinstalldirs) "$(distdir)/$$dir"; \ - fi; \ - if test -d $$d/$$file; then \ - cp -pR $$d/$$file $(distdir) \ - || exit 1; \ - else \ - test -f $(distdir)/$$file \ - || cp -p $$d/$$file $(distdir)/$$file \ - || exit 1; \ - fi; \ - done -check-am: all-am -check: check-am -all-am: Makefile $(HEADERS) - -installdirs: - -install: install-am -install-exec: install-exec-am -install-data: install-data-am -uninstall: uninstall-am - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-am -install-strip: - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - `test -z '$(STRIP)' || \ - echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install -mostlyclean-generic: - -clean-generic: - -distclean-generic: - -rm -f Makefile $(CONFIG_CLEAN_FILES) stamp-h stamp-h[0-9]* - -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-am - -clean-am: clean-generic mostlyclean-am - -distclean: distclean-am - -distclean-am: clean-am distclean-compile distclean-depend \ - distclean-generic distclean-tags - -dvi: dvi-am - -dvi-am: - -info: info-am - -info-am: - -install-data-am: - -install-exec-am: - -install-info: install-info-am - -install-man: - -installcheck-am: - -maintainer-clean: maintainer-clean-am - -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-am - -mostlyclean-am: mostlyclean-compile mostlyclean-generic - -uninstall-am: uninstall-info-am - -.PHONY: GTAGS all all-am check check-am clean clean-generic distclean \ - distclean-compile distclean-depend distclean-generic \ - distclean-tags distdir dvi dvi-am info info-am install \ - install-am install-data install-data-am install-exec \ - install-exec-am install-info install-info-am install-man \ - install-strip installcheck installcheck-am installdirs \ - maintainer-clean maintainer-clean-generic mostlyclean \ - mostlyclean-compile mostlyclean-generic tags uninstall \ - uninstall-am uninstall-info-am - - -# OPTIONS=$(AIXOPTS) -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: Index: interface/debugboard/display.c =================================================================== RCS file: interface/debugboard/display.c diff -N interface/debugboard/display.c --- interface/debugboard/display.c 12 Jun 2005 09:34:14 -0000 1.9 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,529 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\ - * This is GNU Go, a Go program. Contact gnugo@gnu.org, or see * - * http://www.gnu.org/software/gnugo/ for more information. * - * * - * Copyright 1999, 2000, 2001, 2002, 2003, 2004 and 2005 * - * by the Free Software Foundation. * - * * - * This program is free software; you can redistribute it and/or * - * modify it under the terms of the GNU General Public License as * - * published by the Free Software Foundation - version 2 * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License in file COPYING for more details. * - * * - * You should have received a copy of the GNU General Public * - * License along with this program; if not, write to the Free * - * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * - * Boston, MA 02111, USA. * -\* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#ifdef CURSES - -#include -#include -#include -#include - -#ifdef HAVE_UNISTD_H -#include -#endif - -#include -#include - -#include "display.h" /* includes */ -#include "gnugo.h" -#include "gg_utils.h" - - -/* Local variables for display.c */ -WINDOW *board_frame_window; -WINDOW *board_window; -WINDOW *tab_window; -WINDOW *info_window; -WINDOW *message_window; - -static Display_data displaydata; - -/* Wrapper around vwprintw. - * - * Some curses implementations (one of them is pdcurses) - * don't have vwprintw. - */ - -void -gg_vwprintw(WINDOW *w, const char *format, va_list ap) -{ -#if HAVE_VWPRINTW - vwprintw(w, format, ap); -#else - char msg[128]; - gg_vsnprintf(msg, 128, format, ap); - wprintw(w, "%s", msg); -#endif -} - -/* Wrapper around wprintw. - * - * Most curses implementations don't declare fmt as a - * const char, but as a plain char. This can lead to a - * lot of compilation warnings. - */ - -void -gg_wprintw (WINDOW *w, const char *format, ... ) -{ - va_list args; - va_start(args,format); - gg_vwprintw(w, format, args); - va_end(args); -} - -/* ================================================================ */ - - -/* - * Initialize the curses package, and draw the windows. - * - * Return 1 if ok, otherwise return 0. - */ - -int -display_init(int minwidth, int minheight, int size) -{ - - initscr(); - if ((COLS < minwidth) || (LINES < minheight)) { - endwin(); - display_cleanup(); - fprintf(stderr, "Not big enough screen to run debugboard.\n"); - fprintf(stderr, "You need at least %d rows and %d columns.\n", - minheight, minwidth); - return 0; - } - - board_frame_window = newwin(BOARD_FRAME_HEIGHT, minwidth, - BOARD_FRAME_MINROW, BOARD_FRAME_MINCOL); - - /* The board itself. */ - board_window = subwin(board_frame_window, size + 2, size * 2 + 1, - BOARD_MINROW, BOARD_MINCOL); - - /* The tab window. */ - tab_window = newwin(TAB_HEIGHT, TAB_WIDTH, TAB_MINROW, TAB_MINCOL); - leaveok(tab_window, TRUE); - - /* The info window. */ - info_window = newwin(INFO_HEIGHT, INFO_WIDTH, INFO_MINROW, INFO_MINCOL); - leaveok(info_window, TRUE); - - /* The message window. */ - message_window = newwin(MESSAGE_HEIGHT, MESSAGE_WIDTH, - MESSAGE_MINROW, MESSAGE_MINCOL); - leaveok(message_window, TRUE); - - displaydata.boardsize = size; - displaydata.cur_row = 0; - displaydata.cur_col = 0; - displaydata.cur_tab_choice = 0; - clear_all_windows(); - - /* Arrange for the input. */ - cbreak(); -#if HAVE_KEYPAD - keypad(board_window, TRUE); -#endif - noecho(); - - return 1; -} - - - -/* - * Check for input from stdin. Return character. - */ - -int -display_input() -{ - return wgetch(board_window); -} - - - -/* - * Empty the screen and cleanup the curses package. - */ - -void -display_cleanup() -{ - clear(); - refresh(); - endwin(); -} - - -/****************************************************************/ -/*************** Various printing on the screen *****************/ - - -void -clear_board_frame() -{ - static char labels[] = "ABCDEFGHJKLMNOPQRSTUV"; - int i; - - /* Draw the board frame. */ - wclear(board_frame_window); -#if 0 - box(board_frame_window, '|', '-'); - mvwaddch(board_frame_window, 0, 0, '+'); - mvwaddch(board_frame_window, 0, minwidth - 1, '+'); - mvwaddch(board_frame_window, BOARD_FRAME_HEIGHT, 0, '+'); - mvwaddch(board_frame_window, BOARD_FRAME_HEIGHT, minwidth - 1, '+'); -#endif - - for (i = 0; i < displaydata.boardsize; ++i) { - mvwaddch(board_frame_window, BOARD_MINROW-1, BOARD_MINCOL + 2*i + 1, - labels[i]); - mvwaddch(board_frame_window, - BOARD_MINROW+displaydata.boardsize + 2, - BOARD_MINCOL + 2*i + 1, labels[i]); - } - for (i = 0; i < displaydata.boardsize; ++i) { - wmove(board_frame_window, BOARD_MINROW+1+i, BOARD_MINCOL-3); - gg_wprintw(board_frame_window, "%2d", displaydata.boardsize-i); - - wmove(board_frame_window, - BOARD_MINROW + 1 + i, - BOARD_MINCOL + 2*displaydata.boardsize + 2); - gg_wprintw(board_frame_window, "%2d", displaydata.boardsize-i); - } - wrefresh(board_frame_window); - - display_board_cursor(); -} - - -void -clear_visual_board() -{ - int i; - int j; - - wclear(board_window); - box(board_window, '|', '-'); - - for (i = 0; i < displaydata.boardsize; ++i) - for (j = 0; j < displaydata.boardsize; ++j) - mvwaddch(board_window, i+1, 2*j+1, '.'); - - wrefresh(board_window); -} - - -void -clear_tab_window() -{ - wclear(tab_window); - wrefresh(tab_window); -} - - -void -clear_info_window() -{ - wclear(info_window); - /* box(info_window, '|', '-');*/ - wrefresh(info_window); -} - - -void -clear_message_window() -{ - wclear(message_window); - box(message_window, '|', '-'); - wrefresh(message_window); -} - -void -clear_all_windows() -{ - clear_board_frame(); - clear_visual_board(); - clear_tab_window(); - clear_info_window(); - clear_message_window(); - - display_board_cursor(); -} - - -/* ================================================================ */ -/* Board window */ -/* ================================================================ */ - - -int -display_cur_row() -{ - return displaydata.cur_row; -} - -int -display_cur_col() -{ - return displaydata.cur_col; -} - -int -display_cur_tabchoice() -{ - return displaydata.cur_tab_choice; -} - - -void -display_board_char(int i, int j, int ch) -{ - mvwaddch(board_window, i+1, 2*j+1, ch); -} - - -void -display_board_intersection(int i, int j, int color) -{ - int ch; - - switch (color) { - case EMPTY: ch = '.'; break; - case BLACK: ch = 'X'; break; - case WHITE: ch = 'O'; break; - default: ch = '?'; break; - } - - mvwaddch(board_window, i+1, 2*j+1, ch); - - wrefresh(board_window); -} - -void -display_board_position(display_board_function *func) -{ - int ch; - int i; - int j; - int board[MAX_BOARD][MAX_BOARD]; - int boardsize; - - gnugo_get_board(board); - boardsize = gnugo_get_boardsize(); - - for (i = 0; i < boardsize; ++i) - for (j = 0; j < boardsize; ++j) { - switch (board[i][j]) { - case EMPTY: ch = '.'; break; - case BLACK: ch = 'X'; break; - case WHITE: ch = 'O'; break; - default: ch = '?'; break; - } - mvwaddch(board_window, i+1, 2*j+1, ch); - } - - if (func) - func(display_cur_row(), display_cur_col()); - - display_board_cursor(); -} - - -void -display_board_cursor() -{ - wmove(board_window, displaydata.cur_row+1, 2*displaydata.cur_col+1); - wrefresh(board_window); -} - - -void -display_board_moveto(int i, int j) -{ - if (i < 0) i = 0; - if (i > displaydata.boardsize-1) i = displaydata.boardsize-1; - if (j < 0) j = 0; - if (j > displaydata.boardsize-1) j = displaydata.boardsize-1; - - displaydata.cur_row = i; - displaydata.cur_col = j; - - display_board_cursor(); -} - - -void -display_board_move(int di, int dj) -{ - display_board_moveto(displaydata.cur_row + di, displaydata.cur_col + dj); -} - - -/* ================================================================ */ -/* Tab window */ -/* ================================================================ */ - - -void -tab_window_draw(Tab *tabs) -{ - int len; - int i; - int j; - - wmove(tab_window, 0, 1); - for (i = 0; tabs[i].text[0]; ++i) { - len = strlen(tabs[i].text); - gg_wprintw(tab_window, " "); - for (j = 0; j < len+2; ++j) - gg_wprintw(tab_window, "_"); - gg_wprintw(tab_window, " "); - } - - wmove(tab_window, 1, 1); - for (i = 0; tabs[i].text[0]; ++i) { - gg_wprintw(tab_window, "/ "); - gg_wprintw(tab_window, tabs[i].text); - gg_wprintw(tab_window, " \\"); - } - - wrefresh(tab_window); -} - - -void -tab_window_choose(Tab *tabs, int choice) -{ - int pos; - int len; - int i; - int j; - - /* Store the choice for future reference. */ - displaydata.cur_tab_choice = choice; - - /* Find out where the open space in the box is. */ - pos = 1; - for (i = 0; i < choice; ++i) { - pos += strlen(tabs[i].text) + 4; - } - - /* Redraw the box and the open space. */ - len = strlen(tabs[i].text) + 4; - box(info_window, '|', '-'); - wmove(info_window, 0, pos); - for (j = 0; j < len; ++j) - gg_wprintw(info_window, " "); - - /* Clear everything inside the box. */ - for (i = 1; i < INFO_HEIGHT-1; ++i) - for (j = 1; j < INFO_WIDTH-1; ++j) - mvwaddch(info_window, i, j, ' '); - - wrefresh(info_window); -} - - -/* ================================================================ */ -/* Info window */ -/* ================================================================ */ - - -/* ================================================================ */ -/* Message window */ -/* ================================================================ */ - - -/* - * Display a message at the bottom of the screen. - */ - -void -display_message(const char *format, ...) -{ - va_list ap; - - va_start(ap, format); - - wmove(message_window, 1, 2); - - gg_vwprintw(message_window, format, ap); - - wclrtoeol(message_window); - wrefresh(message_window); - - display_board_cursor(); - - va_end(ap); -} - -/* - * Display a little help about possible keyboard commands. - */ - -void -display_help() -{ - display_message("?: Help, q: Quit, l: Refresh screen"); -} - - -/* ================================================================ */ - - -/* - * Redisplay everything on the screen. This can be used, for instance - * when the screen has been garbled from a system message or similar. - */ - -void -display_refresh() -{ - /* Empty the screen */ - touchwin(stdscr); - refresh(); - - /* Redraw everything. */ - touchwin(board_frame_window); - wrefresh(board_frame_window); - touchwin(board_window); - wrefresh(board_window); - - touchwin(tab_window); - wrefresh(tab_window); - - touchwin(info_window); - wrefresh(info_window); - - touchwin(message_window); - wrefresh(message_window); - - display_board_cursor(); -} - -#endif /* CURSES */ - -/* - * Local Variables: - * tab-width: 8 - * c-basic-offset: 2 - * End: - */ Index: interface/debugboard/display.h =================================================================== RCS file: interface/debugboard/display.h diff -N interface/debugboard/display.h --- interface/debugboard/display.h 12 Jun 2005 09:34:14 -0000 1.9 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,158 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\ - * This is GNU Go, a Go program. Contact gnugo@gnu.org, or see * - * http://www.gnu.org/software/gnugo/ for more information. * - * * - * Copyright 1999, 2000, 2001, 2002, 2003, 2004 and 2005 * - * by the Free Software Foundation. * - * * - * This program is free software; you can redistribute it and/or * - * modify it under the terms of the GNU General Public License as * - * published by the Free Software Foundation - version 2 * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License in file COPYING for more details. * - * * - * You should have received a copy of the GNU General Public * - * License along with this program; if not, write to the Free * - * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * - * Boston, MA 02111, USA. * -\* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -#ifndef __DISPLAY_H__ -#define __DISPLAY_H__ - -/* - * File: display.h - */ - -#include - -#if HAVE_CURSES_H -#include -#elif HAVE_NCURSES_CURSES_H -#include -#else -#endif - -#include - -#include "gnugo.h" - - -/* ================================================================ */ - - -typedef struct { - int boardsize; - int cur_row; - int cur_col; - - int cur_tab_choice; -} Display_data; - - -typedef struct { - const char *text; -} Tab; - - -/* ================================================================ */ - - -#define BOARD_FRAME_MINROW 0 -#define BOARD_FRAME_MINCOL 0 -#define BOARD_FRAME_HEIGHT (MAX_BOARD + 5) -#define BOARD_FRAME_WIDTH MINWIDTH - -#define BOARD_MINROW 1 -#define BOARD_MINCOL 7 - -#define TAB_MINROW BOARD_FRAME_HEIGHT -#define TAB_MINCOL 0 -#define TAB_HEIGHT 2 -#define TAB_WIDTH MINWIDTH - -#define INFO_MINROW (TAB_MINROW + TAB_HEIGHT) -#define INFO_MINCOL 0 -#define INFO_HEIGHT 15 -#define INFO_WIDTH MINWIDTH - -#define MESSAGE_MINROW (INFO_MINROW + INFO_HEIGHT) -#define MESSAGE_MINCOL 0 -#define MESSAGE_HEIGHT 3 -#define MESSAGE_WIDTH MINWIDTH - - -/* Minimal width & height for the display. */ -#define MINWIDTH 80 -#define MINHEIGHT (MESSAGE_MINROW + MESSAGE_HEIGHT) - - -extern WINDOW *board_frame_window; -extern WINDOW *board_window; -extern WINDOW *tab_window; -extern WINDOW *info_window; -extern WINDOW *message_window; - -void gg_vwprintw(WINDOW *w, const char *format, va_list ap); -void gg_wprintw(WINDOW *w, const char *format, ...); - -/* ================================================================ */ -/*********************** display functions ************************/ - - -/* - * Display_init() initializes the display. - * - * Display_cleanup() does any necessary cleanup, such as free()ing - * used memory and resetting the terminal to normal. - */ - -int display_init(int minwidth, int minheight, int size); -int display_input(void); -void display_cleanup(void); - -void display_refresh(void); -void display_help(void); - -void clear_all_windows(void); -void clear_board_frame(void); -void clear_visual_board(void); -void clear_tab_window(void); -void clear_info_window(void); -void clear_message_window(void); - - -int display_cur_row(void); -int display_cur_col(void); -int display_cur_tabchoice(void); - -typedef void (display_board_function)(int m, int n); -void display_board_cursor(void); -void display_board_char(int i, int j, int ch); -void display_board_intersection(int i, int j, int color); -void display_board_position(display_board_function *func); -void display_board_moveto(int i, int j); -void display_board_move(int di, int dj); - - -void tab_window_draw(Tab *tabs); -void tab_window_choose(Tab *tabs, int choice); - -void display_message(const char *format, ...); - -#define display_error display_message - - - -#endif /* __DISPLAY_H__ */ - - -/* - * Local Variables: - * tab-width: 8 - * c-basic-offset: 2 - * End: - */ Index: interface/debugboard/gui.c =================================================================== RCS file: interface/debugboard/gui.c diff -N interface/debugboard/gui.c --- interface/debugboard/gui.c 12 Jun 2005 09:34:14 -0000 1.25 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,481 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\ - * This is GNU Go, a Go program. Contact gnugo@gnu.org, or see * - * http://www.gnu.org/software/gnugo/ for more information. * - * * - * Copyright 1999, 2000, 2001, 2002, 2003, 2004 and 2005 * - * by the Free Software Foundation. * - * * - * This program is free software; you can redistribute it and/or * - * modify it under the terms of the GNU General Public License as * - * published by the Free Software Foundation - version 2 * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License in file COPYING for more details. * - * * - * You should have received a copy of the GNU General Public * - * License along with this program; if not, write to the Free * - * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * - * Boston, MA 02111, USA. * -\* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#ifdef CURSES - -#include "display.h" -#include "gui.h" -#include "liberty.h" - - -void -prepare_worms_tab() -{ - wmove(info_window, 3, 2); - gg_wprintw(info_window, "size: "); - - wmove(info_window, 5, 2); - gg_wprintw(info_window, "cutstone: "); - wmove(info_window, 6, 2); - gg_wprintw(info_window, "cutstone2: "); - wmove(info_window, 7, 2); - gg_wprintw(info_window, "genus: "); - - wmove(info_window, 3, 36); - gg_wprintw(info_window, "liberties: 1 2 3 4"); - - wmove(info_window, 6, 36); - gg_wprintw(info_window, "uncond. status: "); - wmove(info_window, 7, 36); - gg_wprintw(info_window, "flags: "); - - wmove(info_window, 9, 2); - gg_wprintw(info_window, "attack: "); - wmove(info_window, 10, 2); - gg_wprintw(info_window, "defense: "); - wmove(info_window, 11, 2); - gg_wprintw(info_window, "attack threats: "); - wmove(info_window, 12, 2); - gg_wprintw(info_window, "defense threats: "); - wmove(info_window, 13, 2); - gg_wprintw(info_window, "lunch: "); - - wrefresh(info_window); -} - - -void -display_worm(int w) -{ - int i; - - wmove(info_window, 1, 2); - gg_wprintw(info_window, "%3s: %5s worm ", - location_to_string(w), - color_to_string(worm[w].color)); - gg_wprintw(info_window, "(origin %s) ", - location_to_string(worm[w].origin)); - - wmove(info_window, 3, 16); - gg_wprintw(info_window, "%3d %5.3f ", - worm[w].size, worm[w].effective_size); - - wmove(info_window, 5, 19); - gg_wprintw(info_window, "%d", worm[w].cutstone); - wmove(info_window, 6, 19); - gg_wprintw(info_window, "%d", worm[w].cutstone2); - wmove(info_window, 7, 19); - gg_wprintw(info_window, "%d", worm[w].genus); - - wmove(info_window, 4, 50); - gg_wprintw(info_window, "%3d %3d %3d %3d ", - worm[w].liberties, worm[w].liberties2, - worm[w].liberties3, worm[w].liberties4); - - wmove(info_window, 6, 55); - gg_wprintw(info_window, "%s ", - status_to_string(worm[w].unconditional_status)); - /* FIXME: Is status_to_string() correct here? */ - - wmove(info_window, 7, 49); - gg_wprintw(info_window, " "); - wmove(info_window, 7, 49); - if (worm[w].inessential) - gg_wprintw(info_window, "inessential "); - if (worm[w].invincible) - gg_wprintw(info_window, "invincible "); - - for (i = 0; i < MAX_TACTICAL_POINTS; i++) { - wmove(info_window, 9, 19 + i * 6); - if (worm[w].attack_points[i] == 0) - gg_wprintw(info_window, "---:0 ", worm[w].attack_codes[i]); - else - gg_wprintw(info_window, "%3s:%d ", - location_to_string(worm[w].attack_points[i]), - worm[w].attack_codes[i]); - - wmove(info_window, 10, 19 + i * 6); - if (worm[w].defense_points[i] == 0) - gg_wprintw(info_window, "---:0 ", worm[w].defense_codes[i]); - else - gg_wprintw(info_window, "%3s:%d ", - location_to_string(worm[w].defense_points[i]), - worm[w].defense_codes[i]); - - wmove(info_window, 11, 19 + i * 6); - if (worm[w].attack_threat_points[i] == 0) - gg_wprintw(info_window, "---:0", worm[w].attack_threat_codes[i]); - else - gg_wprintw(info_window, "%3s:%d ", - location_to_string(worm[w].attack_threat_points[i]), - worm[w].attack_threat_codes[i]); - - wmove(info_window, 12, 19 + i * 6); - if (worm[w].defense_threat_points[i] == 0) - gg_wprintw(info_window, "---:0 ", worm[w].defense_threat_codes[i]); - else - gg_wprintw(info_window, "%3s:%d ", - location_to_string(worm[w].defense_threat_points[i]), - worm[w].defense_threat_codes[i]); - } - - wmove(info_window, 13, 19); - if (worm[w].lunch == NO_MOVE) - gg_wprintw(info_window, "---"); - else - gg_wprintw(info_window, "%3s", location_to_string(worm[w].lunch)); - - wrefresh(info_window); -} - - -void -display_worm_tactical_data(int m, int n) -{ - int i; - int ii; - - ii = POS(m, n); - for (i = 0; i < MAX_TACTICAL_POINTS; i++) { - if (worm[ii].attack_codes[i] != 0) - display_board_char(I(worm[ii].attack_points[i]), - J(worm[ii].attack_points[i]), 'A'); - if (worm[ii].defense_codes[i] != 0) - display_board_char(I(worm[ii].defense_points[i]), - J(worm[ii].defense_points[i]), 'D'); - if (worm[ii].attack_threat_codes[i] != 0) - display_board_char(I(worm[ii].attack_threat_points[i]), - J(worm[ii].attack_threat_points[i]), 'a'); - if (worm[ii].defense_threat_codes[i] != 0) - display_board_char(I(worm[ii].defense_threat_points[i]), - J(worm[ii].defense_threat_points[i]), 'd'); - } -} - - -/* ---------------------------------------------------------------- */ - -/* Missing: - * border, age, owl_time - * - * Missing in dragon_data2: - * neighbors, adjacent[], moyo - */ - -void -prepare_dragons_tab() -{ - wmove(info_window, 3, 2); - gg_wprintw(info_window, "size: "); - - wmove(info_window, 8, 2); - gg_wprintw(info_window, "half eyes: "); - wmove(info_window, 9, 2); - gg_wprintw(info_window, "genus: "); - wmove(info_window, 10, 2); - gg_wprintw(info_window, "escape_route "); - wmove(info_window, 11, 2); - gg_wprintw(info_window, "lunch: "); - - wmove(info_window, 3, 36); - gg_wprintw(info_window, "status:"); - wmove(info_window, 4, 36); - gg_wprintw(info_window, "owl_status:"); - wmove(info_window, 5, 36); - gg_wprintw(info_window, "owl_threat_status:"); - wmove(info_window, 6, 36); - gg_wprintw(info_window, "matcher_status: "); - - wmove(info_window, 8, 36); - wmove(info_window, 9, 36); - gg_wprintw(info_window, "safety: "); - wmove(info_window, 10, 36); - gg_wprintw(info_window, "semeai: "); - wmove(info_window, 11, 36); - gg_wprintw(info_window, "semeai_margin: "); - - wrefresh(info_window); -} - - -void -display_dragon(int pos) -{ - struct dragon_data *d; - struct dragon_data2 *d2; - - /* FIXME: We should clear the old entries here rather than just - * returning when called on an empty vertex. We can't continue now, - * however, since we may crash on bad field values. - */ - if (board[pos] == EMPTY) - return; - - d = &dragon[pos]; - d2 = &(dragon2[d->id]); - wmove(info_window, 1, 2); - gg_wprintw(info_window, "%3s: %5s dragon ", - location_to_string(pos), color_to_string(d->color)); - gg_wprintw(info_window, "(origin %s) id %d ", - location_to_string(d->origin), d->id); - - wmove(info_window, 3, 16); - gg_wprintw(info_window, "%3d %5.3f ", d->size, d->effective_size); - -#if 0 - wmove(info_window, 8, 18); - if (board[pos] == EMPTY) - gg_wprintw(info_window, " ", d2->heyes); - else - gg_wprintw(info_window, "%d ", d2->heyes); - wmove(info_window, 8, 21); - if (board[pos] != EMPTY && d2->heyes > 0) - gg_wprintw(info_window, "[%s] ", location_to_string(d2->heye)); - else - gg_wprintw(info_window, "[---]"); - - wmove(info_window, 9, 18); - gg_wprintw(info_window, "%d ", d2->genus); -#endif - wmove(info_window, 10, 18); - gg_wprintw(info_window, "%d ", - board[pos] == EMPTY ? 0 : d2->escape_route); - wmove(info_window, 11, 18); - if (d2->lunch == NO_MOVE) - gg_wprintw(info_window, "---"); - else - gg_wprintw(info_window, "%3s", location_to_string(d2->lunch)); - - /* status */ - wmove(info_window, 3, 55); - gg_wprintw(info_window, "%s ", status_to_string(d->crude_status)); - - /* owl status */ - wmove(info_window, 4, 55); - gg_wprintw(info_window, "%-12s", status_to_string(d2->owl_status)); - if (d2->owl_attack_point == NO_MOVE) - gg_wprintw(info_window, "[---] "); - else - gg_wprintw(info_window, "[%3s] ", - location_to_string(d2->owl_attack_point)); - if (d2->owl_defense_point == NO_MOVE) - gg_wprintw(info_window, "[---] "); - else - gg_wprintw(info_window, "[%3s] ", - location_to_string(d2->owl_defense_point)); - - wmove(info_window, 5, 55); - switch (d2->owl_threat_status) { - case DEAD: - case ALIVE: - gg_wprintw(info_window, "%-12s[---] [---]", - status_to_string(d2->owl_threat_status)); - break; - case UNCHECKED: - gg_wprintw(info_window, "unchecked [---] [---]"); - break; - case CAN_THREATEN_ATTACK: - gg_wprintw(info_window, "att. threat [%3s] [---]", - location_to_string(d2->owl_second_attack_point)); - break; - case CAN_THREATEN_DEFENSE: - gg_wprintw(info_window, "def. threat [---] [%3s]", - location_to_string(d2->owl_second_defense_point)); - break; - default: - gg_wprintw(info_window, "Error: %3d [---] [---]", d2->owl_threat_status); - break; - } - - wmove(info_window, 6, 55); - gg_wprintw(info_window, "%s ", status_to_string(d->status)); - - wmove(info_window, 8, 55); - wmove(info_window, 9, 55); - gg_wprintw(info_window, "%s ", status_to_string(d2->safety)); - wmove(info_window, 10, 55); - gg_wprintw(info_window, "%d ", d2->semeai); - - wmove(info_window, 11, 55); - gg_wprintw(info_window, "%d ", d2->semeai_margin_of_safety); - - wrefresh(info_window); -} - - -/* ---------------------------------------------------------------- */ - - -void -prepare_eyes_tab() -{ - wmove(info_window, 1, 2); - gg_wprintw(info_window, "Displaying data for:"); - wmove(info_window, 2, 2); - gg_wprintw(info_window, "Eye at origin: "); - - wmove(info_window, 4, 2); - gg_wprintw(info_window, "color: "); - wmove(info_window, 5, 2); - gg_wprintw(info_window, "total size: "); - wmove(info_window, 6, 2); - gg_wprintw(info_window, "marginals: "); - wmove(info_window, 7, 2); - gg_wprintw(info_window, "surr. dragon: "); - - wmove(info_window, 9, 2); - gg_wprintw(info_window, "----------------------------------------------------------------------------"); - - wmove(info_window, 11, 2); - gg_wprintw(info_window, "type: "); - wmove(info_window, 12, 2); - gg_wprintw(info_window, "marginal: "); - - wmove(info_window, 4, 36); - gg_wprintw(info_window, "max eyes: "); - wmove(info_window, 5, 36); - gg_wprintw(info_window, "min eyes: "); - wmove(info_window, 6, 36); - gg_wprintw(info_window, "attack point: "); - wmove(info_window, 7, 36); - gg_wprintw(info_window, "defense point: "); - - wmove(info_window, 11, 36); - gg_wprintw(info_window, "neighbors: "); - wmove(info_window, 12, 36); - gg_wprintw(info_window, "marg. neighbors: "); - wmove(info_window, 13, 36); - gg_wprintw(info_window, "cut: "); - - wrefresh(info_window); -} - - -void -display_eye(int color, struct eye_data eyedata[BOARDMAX], int pos) -{ - wmove(info_window, 1, 24); - gg_wprintw(info_window, "%s", color == WHITE ? "WHITE" : "BLACK"); - wmove(info_window, 2, 9); - gg_wprintw(info_window, "%s ", location_to_string(pos)); - - wmove(info_window, 2, 24); - if (eyedata[pos].origin == NO_MOVE) - gg_wprintw(info_window, "---"); - else - gg_wprintw(info_window, "%s ", - location_to_string(eyedata[pos].origin)); - - wmove(info_window, 4, 18); - gg_wprintw(info_window, "%-12s", color_to_string(eyedata[pos].color)); - wmove(info_window, 5, 18); - gg_wprintw(info_window, "%d ", eyedata[pos].esize); - wmove(info_window, 6, 18); - gg_wprintw(info_window, "%d ", eyedata[pos].msize); -#if 0 - wmove(info_window, 7, 18); - if (eyedata[pos].dragon == NO_MOVE) - gg_wprintw(info_window, "---"); - else - gg_wprintw(info_window, "%s ", - location_to_string(eyedata[pos].dragon)); -#endif - - wmove(info_window, 11, 18); - gg_wprintw(info_window, "%d ", eyedata[pos].type); - wmove(info_window, 12, 18); - gg_wprintw(info_window, "%d ", eyedata[pos].marginal); - - wmove(info_window, 4, 55); - gg_wprintw(info_window, "%d ", max_eyes(&eyedata[pos].value)); - wmove(info_window, 5, 55); - gg_wprintw(info_window, "%d ", min_eyes(&eyedata[pos].value)); - - wmove(info_window, 6, 55); - if (eyedata[pos].attack_point == NO_MOVE) - gg_wprintw(info_window, "--- "); - else - gg_wprintw(info_window, "%3s", - location_to_string(eyedata[pos].attack_point)); - - wmove(info_window, 7, 55); - if (eyedata[pos].defense_point == NO_MOVE) - gg_wprintw(info_window, "--- "); - else - gg_wprintw(info_window, "%3s", - location_to_string(eyedata[pos].defense_point)); - - wmove(info_window, 11, 55); - gg_wprintw(info_window, "%d ", eyedata[pos].neighbors); - wmove(info_window, 12, 55); - gg_wprintw(info_window, "%d ", eyedata[pos].marginal_neighbors); - wmove(info_window, 13, 55); - gg_wprintw(info_window, "%d ", eyedata[pos].cut); - - wrefresh(info_window); -} - - -/* ---------------------------------------------------------------- */ - - -void -prepare_help_tab() -{ - wmove(info_window, 2, 2); - gg_wprintw(info_window, "Worms screen - press 'w'."); - wmove(info_window, 3, 2); - gg_wprintw(info_window, "Dragons screen - press 'd'."); - wmove(info_window, 4, 2); - gg_wprintw(info_window, "Eyes screen - press 'e'."); - wmove(info_window, 5, 2); - gg_wprintw(info_window, "Help screen - press 'h'."); - - wmove(info_window, 7, 2); - gg_wprintw(info_window, "Show data for white - press 'W'."); - wmove(info_window, 8, 2); - gg_wprintw(info_window, "Show data for black - press 'B'."); - - wmove(info_window, 2, 36); - gg_wprintw(info_window, "Move up - press '8' or '^p'."); - wmove(info_window, 3, 36); - gg_wprintw(info_window, "Move down - press '2' or '^n'."); - wmove(info_window, 4, 36); - gg_wprintw(info_window, "Move left - press '4' or '^b'."); - wmove(info_window, 5, 36); - gg_wprintw(info_window, "Move right - press '6' or '^f'."); - - wrefresh(info_window); -} - -#endif /* CURSES */ - -/* - * Local Variables: - * tab-width: 8 - * c-basic-offset: 2 - * End: - */ Index: interface/debugboard/gui.h =================================================================== RCS file: interface/debugboard/gui.h diff -N interface/debugboard/gui.h --- interface/debugboard/gui.h 12 Jun 2005 09:34:14 -0000 1.9 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,55 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\ - * This is GNU Go, a Go program. Contact gnugo@gnu.org, or see * - * http://www.gnu.org/software/gnugo/ for more information. * - * * - * Copyright 1999, 2000, 2001, 2002, 2003, 2004 and 2005 * - * by the Free Software Foundation. * - * * - * This program is free software; you can redistribute it and/or * - * modify it under the terms of the GNU General Public License as * - * published by the Free Software Foundation - version 2 * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License in file COPYING for more details. * - * * - * You should have received a copy of the GNU General Public * - * License along with this program; if not, write to the Free * - * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * - * Boston, MA 02111, USA. * -\* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/* - * File: display.h - */ - -#include - -#include "liberty.h" -#include "display.h" - - -/* ================================================================ */ - - -void prepare_worms_tab(void); -void display_worm(int w); -void display_worm_tactical_data(int m, int n); - -void prepare_dragons_tab(void); -void display_dragon(int pos); - -void prepare_eyes_tab(void); -void display_eye(int color, struct eye_data eyedata[BOARDMAX], int pos); - -void prepare_help_tab(void); - - - -/* - * Local Variables: - * tab-width: 8 - * c-basic-offset: 2 - * End: - */ Index: interface/debugboard/main.c =================================================================== RCS file: interface/debugboard/main.c diff -N interface/debugboard/main.c --- interface/debugboard/main.c 12 Jun 2005 09:34:14 -0000 1.14 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,365 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\ - * This is GNU Go, a Go program. Contact gnugo@gnu.org, or see * - * http://www.gnu.org/software/gnugo/ for more information. * - * * - * Copyright 1999, 2000, 2001, 2002, 2003, 2004 and 2005 * - * by the Free Software Foundation. * - * * - * This program is free software; you can redistribute it and/or * - * modify it under the terms of the GNU General Public License as * - * published by the Free Software Foundation - version 2 * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License in file COPYING for more details. * - * * - * You should have received a copy of the GNU General Public * - * License along with this program; if not, write to the Free * - * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * - * Boston, MA 02111, USA. * -\* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -#include - -#ifdef HAVE_CONFIG_H -#include -#endif - -#ifdef CURSES - -#include - -#if TIME_WITH_SYS_TIME -# include -# include -#else -# if HAVE_SYS_TIME_H -# include -# else -# include -# endif -#endif - -#ifdef __MINGW32__ -#include -#include -#include -#endif - -#ifdef HAVE_VISUAL_C -#include -#include -#endif - -#include "gnugo.h" -#include "sgftree.h" -#include "interface.h" - -#include "display.h" -#include "gui.h" - - - -Tab tabs[] = { - {"Worms"}, - {"Dragons"}, - {" Eyes "}, - {" Help "}, - {""}, -}; - - -Gameinfo gameinfo; -SGFTree sgftree; - -int current_color = WHITE; - -static void main_loop(void); - -void choose_worms_tab(void); -void choose_dragons_tab(void); -void choose_eyes_tab(void); -void choose_help_tab(void); - -void show_current_info(void); - - -int -main(int argc, char *argv[]) -{ - char *until = NULL; - int next; - char *infilename; - - /* Examine options. */ - if (argc == 1 || argc > 3 ) { - fprintf(stderr, "Usage: %s infile [movenum]\n", argv[0]); - exit(1); - } - - /* Try to open the infile. */ - infilename = argv[1]; - sgftree_clear(&sgftree); - if (!sgftree_readfile(&sgftree, infilename)) { - fprintf(stderr, "Cannot open or parse '%s'\n", infilename); - exit(1); - } - - if (argc == 3) { - until = argv[2]; - } - - /* FIXME: Want to do this somewhere more structured. */ - debug = 0; - level = 10; - fusekidb = 1; - josekidb = 1; - - /* Check if there is enough screen space. */ - if (!display_init(MINWIDTH, MINHEIGHT, board_size)) - exit(1); - - /* Initialize the GNU Go engine. */ - init_gnugo(8, time(0)); - - gameinfo_clear(&gameinfo, 19, 5.5); - next = gameinfo_play_sgftree(&gameinfo, &sgftree, until); - - - reset_engine(); - - display_message("Hit 'h' for help!"); - - tab_window_draw(tabs); - - display_board_position(NULL); - gnugo_examine_position(next, EXAMINE_ALL); - - choose_worms_tab(); - main_loop(); - display_cleanup(); - - exit(0); -} - -static void -main_loop() -{ - int ch; - - while (1) { - ch = display_input(); - if (ch == -1) { -#ifdef HAVE_USLEEP - usleep(100000); -#else - struct timeval timeout; - timeout.tv_sec = 0; - timeout.tv_usec = 100000; - select(0, NULL, NULL, NULL, &timeout); -#endif - continue; - } - - if (ch == 'q' || ch == 'Q') - break; - - switch (ch) { - /* ---- Tabs ---- */ - case 'w': /* Worms */ - choose_worms_tab(); - show_current_info(); - break; - - case 'd': /* Dragons */ - case 'D': - choose_dragons_tab(); - show_current_info(); - break; - - case 'e': /* Eyes */ - case 'E': - choose_eyes_tab(); - show_current_info(); - break; - - /* ---- White or black ---- */ - case 'W': - current_color = WHITE; - show_current_info(); - break; - - case 'B': - current_color = BLACK; - show_current_info(); - break; - - /* ---- Movement ---- */ - /* LEFT */ - - case 2: /* CTRL-B */ - case '4': /* Or use numeric keypad 4. */ -#ifdef HAVE_CURSES_ARROWS - case KEY_LEFT: -#endif - display_board_move(0, -1); - - show_current_info(); - break; - - /* RIGHT */ - case 6: /* CTRL-F */ - case '6': /* Or use numeric keypad 6 */ -#ifdef HAVE_CURSES_ARROWS - case KEY_RIGHT: -#endif - display_board_move(0, 1); - show_current_info(); - break; - - /* UP */ - - case 16: /* CTRL-P */ - case '8': /* Or use numeric keypad 8 */ -#ifdef HAVE_CURSES_ARROWS - case KEY_UP: -#endif - display_board_move(-1, 0); - show_current_info(); - break; - - /* DOWN */ - - case 14: /* CTRL-N */ - case '2': /* Or use numeric keypad 2 */ -#ifdef HAVE_CURSES_ARROWS - case KEY_DOWN: -#endif - display_board_move(1, 0); - show_current_info(); - break; - - /* Beginning of line */ - case 1: /* CTRL-A */ - display_board_move(0, -100); - show_current_info(); - break; - - /* End of line */ - case 5: /* CTRL-E */ - display_board_move(0, 100); - show_current_info(); - break; - - /* ---- Miscellaneous ---- */ - case 'l': /* Refresh screen */ - case 'L': - display_refresh(); - break; - - case '?': /* Help */ - case 'h': - case 'H': - choose_help_tab(); - display_help(); - break; - - default: - display_message("Unkown character (%d) received", ch); - } - } - } - - - -/* ---------------------------------------------------------------- */ - -void -choose_worms_tab() -{ - tab_window_choose(tabs, 0); - prepare_worms_tab(); - display_worm(POS(display_cur_row(), display_cur_col())); - - display_board_cursor(); -} - - -void -choose_dragons_tab() -{ - tab_window_choose(tabs, 1); - prepare_dragons_tab(); - - display_board_cursor(); -} - - -void -choose_eyes_tab() -{ - tab_window_choose(tabs, 2); - prepare_eyes_tab(); - - display_board_cursor(); -} - - -void -choose_help_tab() -{ - tab_window_choose(tabs, 3); - prepare_help_tab(); - - display_board_cursor(); -} - - -void -show_current_info() -{ - switch (display_cur_tabchoice()) { - case 0: - display_board_position(display_worm_tactical_data); - display_worm(POS(display_cur_row(), display_cur_col())); - break; - case 1: - display_board_position(NULL); - display_dragon(POS(display_cur_row(), display_cur_col())); - break; - case 2: - display_board_position(NULL); - if (current_color == WHITE) - display_eye(WHITE, white_eye, POS(display_cur_row(), display_cur_col())); - else - display_eye(BLACK, black_eye, POS(display_cur_row(), display_cur_col())); - default: - break; - } - - display_board_cursor(); -} - -#else /* !CURSES */ - -/* Avoid compiler warnings with unused parameters */ -#define UNUSED(x) (void)x - -int -main(int argc, char *argv[]) -{ - UNUSED(argc); - UNUSED(argv); - fprintf(stderr, "This program requires curses. Rebuild with curses and/or check that\nconfigure did find curses successfully.\n"); - return 1; -} - -#endif /* CURSES */ - -/* - * Local Variables: - * tab-width: 8 - * c-basic-offset: 2 - * End: - */