#include <sys/types.h>
#include <sys/file.h>
-#include <curses.h>
#include "gnushogi.h"
char mvstr[4][6];
have_shown_prompt = false;
#endif /* QUIETBACKGROUND */
- if (command == NULL)
- {
+ if (command == NULL) {
if (NOT_CURSES)
- {
- s[0] = sx[0] = '\0';
+ s[0] = '\0';
- while(!eof && !sx[0])
- eof = (fgets(sx, 80, stdin) == NULL);
- }
- else
- {
- fflush(stdout);
- eof = (getstr(sx) == ERR);
- }
- }
- else
- {
+ eof = GetString(sx);
+ } else {
strcpy(sx, command);
done = true;
}
}
+int
+Curses_GetString(char* sx)
+{
+ fflush(stdout);
+ return (getstr(sx) == ERR);
+}
+
+
void
Curses_ShowNodeCnt(long NodeCnt)
{
void Curses_AlwaysShowMessage(const char *format, ...);
void Curses_Printf(const char *format, ...);
void Curses_doRequestInputString(const char* fmt, char* buffer);
+int Curses_GetString(char* sx);
void Curses_ShowPatternCount(short side, short n);
void Curses_ShowPostnValue(short sq);
void Curses_ShowPostnValues(void);
}
doRequestInputString(fmt, buffer);
}
+
+/*********/
+
+#define CASE_DSPFUNC_RAW(func,args) \
+ case DISPLAY_RAW: \
+ case DISPLAY_X: \
+ return (func args); \
+ break
+
+#ifdef HAVE_LIBCURSES
+#define CASE_DSPFUNC_CURSES(func,args) \
+ case DISPLAY_CURSES: \
+ return (func args); \
+ break;
+#else
+#define CASE_DSPFUNC_CURSES(func,args)
+#endif
+
+#define DISPLAY_INTFUNC(func,argsdecl,args) \
+ int func argsdecl \
+ { \
+ switch (display_type) { \
+ CASE_DSPFUNC_RAW(Raw_ ## func, args); \
+ CASE_DSPFUNC_CURSES(Curses_ ## func, args); \
+ } \
+ assert(0); \
+ }
+
+DISPLAY_INTFUNC(GetString, (char* sx), (sx))
extern void AlwaysShowMessage(const char *format, ...);
extern void Printf(const char *format, ...);
extern void RequestInputString(char* buffer, unsigned bufsize);
+extern int GetString(char* sx);
extern void ShowPatternCount(short side, short n);
extern void ShowPostnValue(short sq);
extern void ShowPostnValues(void);
}
+int
+Raw_GetString(char* sx)
+{
+ int eof = 0;
+ sx[0] = '\0';
+
+ while(!eof && !sx[0])
+ eof = (fgets(sx, 80, stdin) == NULL);
+ return eof;
+}
+
+
void
Raw_ShowNodeCnt(long NodeCnt)
{
void Raw_AlwaysShowMessage(const char *format, ...);
void Raw_Printf(const char *format, ...);
void Raw_doRequestInputString(const char* fmt, char* buffer);
+int Raw_GetString(char* sx);
void Raw_ShowPatternCount(short side, short n);
void Raw_ShowPostnValue(short sq);
void Raw_ShowPostnValues(void);