X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=xboard.c;h=dfe70cdba42834cce337e84735d153108675689b;hb=7fb56edee87ea24c7b2b6b0065e73e5053650383;hp=8031466ad0d0af4393e804da4e7a589e3b800d74;hpb=bdd61153a00af769f75d1f20d7938642592cbce9;p=xboard.git diff --git a/xboard.c b/xboard.c index 8031466..dfe70cd 100644 --- a/xboard.c +++ b/xboard.c @@ -232,6 +232,7 @@ typedef struct { int main P((int argc, char **argv)); RETSIGTYPE CmailSigHandler P((int sig)); RETSIGTYPE IntSigHandler P((int sig)); +RETSIGTYPE TermSizeSigHandler P((int sig)); void CreateGCs P((void)); void CreateXIMPieces P((void)); void CreateXPMPieces P((void)); @@ -446,6 +447,8 @@ void UciPopDown P(()); void TimeControlPopDown P(()); void NewVariantPopDown P(()); void SettingsPopDown P(()); +void update_ics_width P(()); +int get_term_width P(()); /* * XBoard depends on Xt R4 or higher */ @@ -1894,7 +1897,6 @@ XtActionsRec boardActions[] = { { "TagsPopDown", (XtActionProc) TagsPopDown }, { "ErrorPopDown", (XtActionProc) ErrorPopDown }, { "ICSInputBoxPopDown", (XtActionProc) ICSInputBoxPopDown }, - { "AnalysisPopDown", (XtActionProc) AnalysisPopDown }, { "FileNamePopDown", (XtActionProc) FileNamePopDown }, { "AskQuestionPopDown", (XtActionProc) AskQuestionPopDown }, { "GameListPopDown", (XtActionProc) GameListPopDown }, @@ -3211,6 +3213,11 @@ ShutDownFrontEnd() unlink(gamePasteFilename); } +RETSIGTYPE TermSizeSigHandler(int sig) +{ + update_ics_width(); +} + RETSIGTYPE IntSigHandler(sig) int sig; @@ -3277,11 +3284,6 @@ ResetFrontEnd() return; } -void NotifyFrontendLogin() -{ - // placeholder -} - typedef struct { char *name; Boolean value; @@ -5741,37 +5743,6 @@ void CommentPopUp(title, text) commentUp = True; } -void AnalysisPopUp(title, text) - char *title, *text; -{ - Arg args[16]; - int j; - Widget edit; - - if (analysisShell == NULL) { - analysisShell = MiscCreate(title, text, False, NULL, 4); - XtRealizeWidget(analysisShell); - CatchDeleteWindow(analysisShell, "AnalysisPopDown"); - - } else { - edit = XtNameToWidget(analysisShell, "*form.text"); - j = 0; - XtSetArg(args[j], XtNstring, text); j++; - XtSetValues(edit, args, j); - j = 0; - XtSetArg(args[j], XtNiconName, (XtArgVal) title); j++; - XtSetArg(args[j], XtNtitle, (XtArgVal) title); j++; - XtSetValues(analysisShell, args, j); - } - - if (!analysisUp) { - XtPopup(analysisShell, XtGrabNone); - } - XSync(xDisplay, False); - - analysisUp = True; -} - void CommentCallback(w, client_data, call_data) Widget w; XtPointer client_data, call_data; @@ -5810,16 +5781,6 @@ void CommentPopDown() commentUp = False; } -void AnalysisPopDown() -{ - if (!analysisUp) return; - XtPopdown(analysisShell); - XSync(xDisplay, False); - analysisUp = False; - if (appData.icsEngineAnalyze) ExitAnalyzeMode(); /* [DM] icsEngineAnalyze */ -} - - void FileNamePopUp(label, def, proc, openMode) char *label; char *def; @@ -6291,7 +6252,6 @@ void ResetProc(w, event, prms, nprms) Cardinal *nprms; { ResetGameEvent(); - AnalysisPopDown(); } int LoadGamePopUp(f, gameNumber, title) @@ -8395,6 +8355,10 @@ int StartChildProcess(cmdLine, dir, pr) SetUpChildIO(to_prog, from_prog); + #ifdef SIGWINCH + signal(SIGWINCH, TermSizeSigHandler); + #endif + if ((pid = fork()) == 0) { /* Child process */ // [HGM] PSWBTM: made order resistant against case where fd of created pipe was 0 or 1 @@ -9487,3 +9451,38 @@ SetProgramStats( FrontEndProgramStats * stats ) // [HGM] done, but perhaps backend should call this directly? EngineOutputUpdate( stats ); } + +#include +int get_term_width() +{ + int fd, default_width; + + fd = STDIN_FILENO; + default_width = 79; // this is FICS default anyway... + +#if !defined(TIOCGWINSZ) && defined(TIOCGSIZE) + struct ttysize win; + if (!ioctl(fd, TIOCGSIZE, &win)) + default_width = win.ts_cols; +#elif defined(TIOCGWINSZ) + struct winsize win; + if (!ioctl(fd, TIOCGWINSZ, &win)) + default_width = win.ws_col; +#endif + return default_width; +} + +void update_ics_width() +{ + static int old_width = 0; + int new_width = get_term_width(); + + if (old_width != new_width) + ics_printf("set width %d\n", new_width); + old_width = new_width; +} + +void NotifyFrontendLogin() +{ + update_ics_width(); +}