void PastePositionProc P((Widget w, XEvent *event, String *prms,
Cardinal *nprms));
void CopyGameProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms));
+void CopyGameListProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms));
void PasteGameProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms));
void SaveGameProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms));
void SavePositionProc P((Widget w, XEvent *event,
MenuItem editMenu[] = {
{N_("Copy Game Ctrl+C"), "Copy Game", CopyGameProc},
{N_("Copy Position Ctrl+Shift+C"), "Copy Position", CopyPositionProc},
+ {N_("Copy Game List"), "Copy Game List", CopyGameListProc},
{"----", NULL, NothingProc},
{N_("Paste Game Ctrl+V"), "Paste Game", PasteGameProc},
{N_("Paste Position Ctrl+Shift+V"), "Paste Position", PastePositionProc},
{ "CopyPositionProc", CopyPositionProc },
{ "PastePositionProc", PastePositionProc },
{ "CopyGameProc", CopyGameProc },
+ { "CopyGameListProc", CopyGameListProc },
{ "PasteGameProc", PasteGameProc },
{ "SaveGameProc", SaveGameProc },
{ "SavePositionProc", SavePositionProc },
}
}
-/* note: when called from menu all parameters are NULL, so no clue what the
- * Widget which was clicked on was, or what the click event was
- */
-void CopyGameProc(w, event, prms, nprms)
- Widget w;
- XEvent *event;
- String *prms;
- Cardinal *nprms;
+void CopySomething()
{
int ret;
- ret = SaveGameToFile(gameCopyFilename, FALSE);
- if (!ret) return;
-
/*
* Set both PRIMARY (the selection) and CLIPBOARD, since we don't
* have a notion of a game that is selected but not copied.
NULL/* transfer_done_proc */);
}
+/* note: when called from menu all parameters are NULL, so no clue what the
+ * Widget which was clicked on was, or what the click event was
+ */
+void CopyGameProc(w, event, prms, nprms)
+ Widget w;
+ XEvent *event;
+ String *prms;
+ Cardinal *nprms;
+{
+ int ret;
+
+ ret = SaveGameToFile(gameCopyFilename, FALSE);
+ if (!ret) return;
+
+ CopySomething();
+}
+
+void CopyGameListProc(w, event, prms, nprms)
+ Widget w;
+ XEvent *event;
+ String *prms;
+ Cardinal *nprms;
+{
+ if(!SaveGameListAsText(fopen(gameCopyFilename, "w"))) return;
+ CopySomething();
+}
+
/* function called when the data to Paste is ready */
static void
PasteGameCB(Widget w, XtPointer client_data, Atom *selection,
return glc && glc->up;
}
+int SaveGameListAsText(FILE *f)\r
+{\r
+ ListGame * lg = (ListGame *) gameList.head;\r
+ int nItem;\r
+\r
+ if( ((ListGame *) gameList.tailPred)->number <= 0 ) {\r
+ DisplayError("Game list not loaded or empty", 0);\r
+ return False;\r
+ }\r
+\r
+ /* Copy the list into the global memory block */\r
+ if( f != NULL ) {\r
+
+ lg = (ListGame *) gameList.head;\r
+\r
+ for (nItem = 0; nItem < ((ListGame *) gameList.tailPred)->number; nItem++){\r
+ char * st = GameListLineFull(lg->number, &lg->gameInfo);\r
+ char *line = GameListLine(lg->number, &lg->gameInfo);
+ if(filterString[0] == NULLCHAR || SearchPattern( line, filterString ) )
+ fprintf( f, "%s\n", st );
+ free(st); free(line);\r
+ lg = (ListGame *) lg->node.succ;\r
+ }\r
+\r
+ fclose(f);
+ return True;\r
+ }
+ return False;\r
+}\r
//--------------------------------- Game-List options dialog ------------------------------------------
Widget gameListOptShell, listwidg;