X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=xoptions.c;h=cb0be5885d86051063dbc0ce38fdbfe9aee41eb4;hb=d374c33760f3faec1c674c74a2712d1d018153a0;hp=8dbf32a608d17609610cfc2e9084fb180b284848;hpb=715e33a60133ac9ac76b3aa0a5cf6f14f0f3930f;p=xboard.git diff --git a/xoptions.c b/xoptions.c index 8dbf32a..cb0be58 100644 --- a/xoptions.c +++ b/xoptions.c @@ -50,6 +50,7 @@ extern char *getenv(); #include #include #include +#include #include #include #include @@ -1101,7 +1102,8 @@ void AdjustColor(int i) void BoardOptionsOK(int n) { - if(appData.overrideLineGap >= 0) lineGap = appData.overrideLineGap; + extern int defaultLineGap; + if(appData.overrideLineGap >= 0) lineGap = appData.overrideLineGap; else lineGap = defaultLineGap; MakeColors(); CreateGCs(True); CreateXPMPieces(); CreateXPMBoard(appData.liteBackTextureFile, 1); @@ -1665,6 +1667,87 @@ void MatchOptionsProc(w, event, prms, nprms) GenericPopUp(matchOptions, _("Match Options"), 0); } +Option textOptions[100]; +extern char *icsTextMenuString; +void PutText P((char *text, int pos)); + +SendString(char *p) +{ + char buf[MSG_SIZ], *q; + if(q = strstr(p, "$input")) { + if(!shellUp[4]) return; + strncpy(buf, p, MSG_SIZ); + strncpy(buf + (q-p), q+6, MSG_SIZ-(q-p)); + PutText(buf, q-p); + return; + } + snprintf(buf, MSG_SIZ, "%s\n", p); + SendToICS(buf); +} + +/* function called when the data to Paste is ready */ +static void +SendTextCB(Widget w, XtPointer client_data, Atom *selection, + Atom *type, XtPointer value, unsigned long *len, int *format) +{ + char buf[MSG_SIZ], *p = (char*) textOptions[(int) client_data].choice, *name = (char*) value, *q; + if (value==NULL || *len==0) return; /* nothing selected, abort */ + name[*len]='\0'; + strncpy(buf, p, MSG_SIZ); + q = strstr(p, "$name"); + snprintf(buf + (q-p), MSG_SIZ -(q-p), "%s%s", name, q+5); + SendString(buf); + XtFree(value); +} + +void SendText(int n) +{ + char *p = (char*) textOptions[n].choice; + if(strstr(p, "$name")) { + XtGetSelectionValue(menuBarWidget, + XA_PRIMARY, XA_STRING, + /* (XtSelectionCallbackProc) */ SendTextCB, + (XtPointer) n, /* client_data passed to PastePositionCB */ + CurrentTime + ); + } else SendString(p); +} + +void IcsTextProc(w, event, prms, nprms) + Widget w; + XEvent *event; + String *prms; + Cardinal *nprms; +{ + int i=0, j; + char *p, *q, *r; + if((p = icsTextMenuString) == NULL) return; + do { + q = r = p; while(*p && *p != ';') p++; + for(j=0; j