code cleanup: make function definition confirm to GNU coding style
[xboard.git] / xengineoutput.c
index 980b639..6bb2917 100644 (file)
@@ -5,7 +5,7 @@
  *
  * Copyright 2005 Alessandro Scotti
  *
- * Enhancements Copyright 2009, 2010, 2011 Free Software Foundation, Inc.
+ * Enhancements Copyright 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
  *
  * ------------------------------------------------------------------------
  *
@@ -100,14 +100,6 @@ extern char *getenv();
 
 #define _LL_ 100
 
-// imports from xboard.c
-extern Widget formWidget, shellWidget, boardWidget, menuBarWidget;
-extern Display *xDisplay;
-extern Window xBoardWindow;
-extern int squareSize;
-extern Pixmap xMarkPixmap, wIconPixmap, bIconPixmap;
-extern char *layoutName;
-
 Pixmap icons[8]; // [HGM] this front-end array translates back-end icon indicator to handle
 Widget outputField[2][7]; // [HGM] front-end array to translate output field to window handle
 
@@ -116,12 +108,6 @@ void engineOutputPopUp();
 int  EngineOutputIsUp();
 void SetEngineColorIcon( int which );
 
-/* Imports from backend.c */
-extern int opponentKibitzes;
-
-/* Imports from xboard.c */
-extern Arg layoutArgs[2], formArgs[2], messageArgs[4];
-
 //extern WindowPlacement wpEngineOutput;
 
 Position engineOutputX = -1, engineOutputY = -1;
@@ -148,7 +134,8 @@ typedef struct {
 
 //static void UpdateControls( EngineOutputData * ed );
 
-void ReadIcon(char *pixData[], int iconNr)
+void
+ReadIcon (char *pixData[], int iconNr)
 {
     int r;
 
@@ -161,7 +148,8 @@ void ReadIcon(char *pixData[], int iconNr)
        }
 }
 
-static void InitializeEngineOutput()
+static void
+InitializeEngineOutput ()
 {
         ReadIcon(WHITE_14,   nColorWhite);
         ReadIcon(BLACK_14,   nColorBlack);
@@ -173,7 +161,8 @@ static void InitializeEngineOutput()
         ReadIcon(ANALYZE_14, nAnalyzing);
 }
 
-void DoSetWindowText(int which, int field, char *s_label)
+void
+DoSetWindowText (int which, int field, char *s_label)
 {
        Arg arg;
 
@@ -181,7 +170,16 @@ void DoSetWindowText(int which, int field, char *s_label)
        XtSetValues(outputField[which][field], &arg, 1);
 }
 
-void InsertIntoMemo( int which, char * text, int where )
+void
+SetEngineOutputTitle (char *title)
+{
+       Arg arg;
+       XtSetArg(arg, XtNtitle, (XtArgVal) title);
+       XtSetValues(engineOutputShell, &arg, 1);
+}
+
+void
+InsertIntoMemo (int which, char * text, int where)
 {
        XawTextBlock t;
        Widget edit;
@@ -200,7 +198,8 @@ void InsertIntoMemo( int which, char * text, int where )
        }
 }
 
-void SetIcon( int which, int field, int nIcon )
+void
+SetIcon (int which, int field, int nIcon)
 {
     Arg arg;
 
@@ -210,19 +209,19 @@ void SetIcon( int which, int field, int nIcon )
     }
 }
 
-void DoClearMemo(int which)
+void
+DoClearMemo (int which)
 {
-    Widget edit;
-
-    edit = XtNameToWidget(engineOutputShell, which ? "*form2.text" : "*form.text");
-    XtCallActionProc(edit, "select-all", NULL, NULL, 0);
-    XtCallActionProc(edit, "kill-selection", NULL, NULL, 0);
+    Widget edit = XtNameToWidget(engineOutputShell, which ? "*form2.text" : "*form.text");
+    Arg arg;
+//    XtCallActionProc(edit, "select-all", NULL, NULL, 0);
+//    XtCallActionProc(edit, "kill-selection", NULL, NULL, 0);
+    XtSetArg(arg, XtNstring, ""); // clear without disturbing selection!
+    XtSetValues(edit, &arg, 1);
 }
 
 // cloned from CopyPositionProc. Abuse selected_fen_position to hold selection
 
-extern char *selected_fen_position;
-
 Boolean SendPositionSelection(Widget w, Atom *selection, Atom *target,
                 Atom *type_return, XtPointer *value_return,
                 unsigned long *length_return, int *format_return); // from xboard.c
@@ -231,7 +230,8 @@ void SetFocus(Widget w, XtPointer data, XEvent *event, Boolean *b); // from xopt
 char memoTranslations[] =
 ":Ctrl<Key>c: CopyMemoProc() \n \
 <Btn3Motion>: HandlePV() \n \
-<Btn3Down>: select-start() SelectPV() \n \
+Shift<Btn3Down>: select-start() SelectPV(1) \n \
+Any<Btn3Down>: select-start() SelectPV(0) \n \
 <Btn3Up>: extend-end() StopPV() \n";
 
 void
@@ -248,6 +248,7 @@ SelectPV (Widget w, XEvent * event, String * params, Cardinal * nParams)
        XawTextGetSelectionPos(w, &index, &dummy);
        XtSetArg(arg, XtNstring, &val);
        XtGetValues(w, &arg, 1);
+       shiftKey = strcmp(params[0], "0");
        if(LoadMultiPV(x, y, val, index, &start, &end)) {
            XawTextSetSelection( outputField[currentPV][nMemo], start, end );
            highTextStart[currentPV] = start; highTextEnd[currentPV] = end;
@@ -263,8 +264,8 @@ StopPV (Widget w, XEvent * event, String * params, Cardinal * nParams)
 }
 
 static void
-MemoCB(Widget w, XtPointer client_data, Atom *selection,
-          Atom *type, XtPointer value, unsigned long *len, int *format)
+MemoCB (Widget w, XtPointer client_data, Atom *selection,
+       Atom *type, XtPointer value, unsigned long *len, int *format)
 {
   if (value==NULL || *len==0) return; /* nothing had been selected to copy */
   selected_fen_position = value;
@@ -276,11 +277,8 @@ MemoCB(Widget w, XtPointer client_data, Atom *selection,
                   NULL/* transfer_done_proc */);
 }
 
-void CopyMemoProc(w, event, prms, nprms)
-  Widget w;
-  XEvent *event;
-  String *prms;
-  Cardinal *nprms;
+void
+CopyMemoProc (Widget w, XEvent *event, String *prms, Cardinal *nprms)
 {
     if(appData.pasteSelection) return;
     if (selected_fen_position) free(selected_fen_position);
@@ -298,10 +296,8 @@ void CopyMemoProc(w, event, prms, nprms)
 
 // The following routines are mutated clones of the commentPopUp routines
 
-void PositionControlSet(which, shell, form, bw_width)
-     int which;
-     Widget shell, form;
-     Dimension bw_width;
+void
+PositionControlSet (int which, Widget shell, Widget form, Dimension bw_width)
 {
     Arg args[16];
     Widget edit, NameWidget, ColorWidget, ModeWidget, MoveWidget, NodesWidget;
@@ -404,8 +400,8 @@ void PositionControlSet(which, shell, form, bw_width)
     XtSetValues(edit, args, j);
 }
 
-Widget EngineOutputCreate(name, text)
-     char *name, *text;
+Widget
+EngineOutputCreate (char *name, char *text)
 {
     Arg args[16];
     Widget shell, layout, form, form2;
@@ -496,8 +492,8 @@ Widget EngineOutputCreate(name, text)
     return shell;
 }
 
-void ResizeWindowControls(mode)
-       int mode;
+void
+ResizeWindowControls (int mode)
 {
     Widget form1, form2;
     Arg args[16];
@@ -534,7 +530,7 @@ void ResizeWindowControls(mode)
 }
 
 void
-EngineOutputPopUp()
+EngineOutputPopUp ()
 {
     Arg args[16];
     int j;
@@ -578,7 +574,8 @@ EngineOutputPopUp()
     ShowThinkingEvent(); // [HGM] thinking: might need to prompt engine for thinking output
 }
 
-void EngineOutputPopDown()
+void
+EngineOutputPopDown ()
 {
     Arg args[16];
     int j;
@@ -606,22 +603,20 @@ void EngineOutputPopDown()
     ShowThinkingEvent(); // [HGM] thinking: might need to shut off thinking output
 }
 
-int EngineOutputIsUp()
+int
+EngineOutputIsUp ()
 {
     return engineOutputDialogUp;
 }
 
-int EngineOutputDialogExists()
+int
+EngineOutputDialogExists ()
 {
     return engineOutputShell != NULL;
 }
 
 void
-EngineOutputProc(w, event, prms, nprms)
-     Widget w;
-     XEvent *event;
-     String *prms;
-     Cardinal *nprms;
+EngineOutputProc (Widget w, XEvent *event, String *prms, Cardinal *nprms)
 {
   if (engineOutputDialogUp) {
     EngineOutputPopDown();