OSX Xboard 4.7.2 .app

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

User avatar
hgm
Posts: 27795
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: OSX Xboard 4.7.2 .app

Post by hgm »

Ah yes, that is a good point. For XBoard I didn't think it necessary, because the user settings where in the user's home directory, and I supposed he would be able to find them easily. But the OS X setup is more WinBoard-like than XBoard-like, and there is good reason to have it there.

In menu.c you could add two lines in the engineMenu table:

Code: Select all

MenuItem engineMenu[100] = {
  {N_("Edit Engine List..."),   NULL,     "EditEngList", EditEngineProc},
  {"----",                         NULL,      NULL,              NothingProc},
  {N_("Load New 1st Engine..."),   NULL,     "LoadNew1stEngine", LoadEngine1Proc},
  {N_("Load New 2nd Engine..."),   NULL,     "LoadNew2ndEngine", LoadEngine2Proc},
  {"----",                         NULL,      NULL,              NothingProc},
Then you should make an EditEngineProc somewhere above it, e.g. just before "void CreateBookDelayed ()". This should look:

Code: Select all

void
EditEngineProc ()
{
    EditTagsPopUp(firstChessProgramNames, &firstChessProgramNames);
}
That should do it.
JoshPettus
Posts: 730
Joined: Fri Oct 19, 2012 2:23 am

Re: OSX Xboard 4.7.2 .app

Post by JoshPettus »

I gave it a try. Amazing how so few lines did the trick! Only the "Save Changes" button doesn't appear to save anything to the user .conf. There wasn't any error in the terminal or anything.
-------

Any way we could have a toggle for logo's precisely for the same reason?

It's actually slightly worse then winboard.
The ~/Library folder is actually hidden on OSX 10.7-10.9. In order to access it you have to, either A) change the hidden flag on the folder (which resets itself when you update) B) Change the Finder to see hidden folders with a terminal command and restart the finder. (Ubuntu handles this so much better!) C) Or hold "option/alt" and go to the Go Menu in the Finder, which is actually quite handy, but obscure to most people.
User avatar
hgm
Posts: 27795
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: OSX Xboard 4.7.2 .app

Post by hgm »

JoshPettus wrote:I gave it a try. Amazing how so few lines did the trick!
That is of course because the feature already existed in the back-end, for the benefit of WinBoard, so I only had to invoke it. Actually this is a relatively complicated way to invoke it. I could not put EditTagsPopUp directly in the menu table as routine to be called when the menu is clicked, because EditTagsPopUp needed arguments. So I had to create the 'wrapper' EditEngineProc to specify what had to be edited.

This again is a consequence that I was lazy when adding the feature to WinBoard: rather than programming something new, I used the existing Edit Tags dialog to edit other stuff as well. (Book, Engine List or PGN Tags.) Now that XBoard and WinBoard both do this, I guess the clean way to do it would be to move what is now EditEngineProc to backend.c, and call it EditEngineListEvent there, so that the front-ends could call it directly on a menu click.
Only the "Save Changes" button doesn't appear to save anything to the user .conf. There wasn't any error in the terminal or anything.
I admit this is a bit confusing. The 'Save Changes' button in the Edit Tags dialog only pushes the change to the string you are editing in XBoard's memory (in this case the value of -firstChessProgramNames). This string again is only written to the settings file on exit or when you press Save Settings Now. The Save Changes button was added recently, mainly for the benefit of Edit Book, where you needed a way to save changes without closing the dialog (because then you would have to re-open it again when you moved to another position, when creating a book by hand). For editing Tags or the Engine List it is not really needed. Perhaps the button should be disabled there, or not displayed at all.
Any way we could have a toggle for logo's precisely for the same reason?
You mean that it should be possible to set the -logoHeight option from a dialog? I don't know if the GTK version would be able to reformat the display for adding or deleting logos during the session.

Btw, there should already be an undocumented feature where you can change any option setting by typing the option in the move type-in box. For options that should have immediate consequences, no attempt is made to to have those take effect, however. So it is only useful for settings that XBoard consults on a later action. Not for settings that were consulted only at startup. But any changes of such settings would still find their way in the settings file. In that respect it is an alternative to ediing the settings file.
It's actually slightly worse then winboard.
On Windows the user's AppData folder is hidden too...
JoshPettus
Posts: 730
Joined: Fri Oct 19, 2012 2:23 am

Re: OSX Xboard 4.7.2 .app

Post by JoshPettus »

hgm wrote: I admit this is a bit confusing. The 'Save Changes' button in the Edit Tags dialog only pushes the change to the string you are editing in XBoard's memory (in this case the value of -firstChessProgramNames).
Unfortunately I don't think it is putting it into xboard's memory. I edit the text, hit Ok, and then Save Settings Now. When I go back to the Edit Engine List, or exit Xboard and go back, nothing has changed. Not sure what's wrong.
I don't know if the GTK version would be able to reformat the display for adding or deleting logos during the session.
ah, I see. I guess we can add (requires restart) next to the flag. What will most likely happen is you will see the last logo loaded, but it will be shrunk as the clock is fit to the original size. and then take effect fully when you restart xboard. It's what happens when you load a pgn file as I think for a split second fairymax is loaded, before the pgn file is open. If it weren't then there would be just a blank white space where the logo would be.
Btw, there should already be an undocumented feature where you can change any option setting by typing the option in the move type-in box.
Oh, wow good to know. Is there a specific syntax? I just get, "could not parse move" when I type in the command like -autoLogo 0
It's actually slightly worse then winboard.
On Windows the user's AppData folder is hidden too...
Oh yes i forgot, it's been so long since I have dug into windows. :\
User avatar
hgm
Posts: 27795
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: OSX Xboard 4.7.2 .app

Post by hgm »

JoshPettus wrote:Unfortunately I don't think it is putting it into xboard's memory. I edit the text, hit Ok, and then Save Settings Now. When I go back to the Edit Engine List, or exit Xboard and go back, nothing has changed. Not sure what's wrong.
Oh, I must check that then. Perhaps I connected a handler to the button that only writes the book back to file, forgetting that the same dialog is also used for editing other things. I think the best solution would be to disable or suppress the button completely when editing tags or engine list.
ah, I see. I guess we can add (requires restart) next to the flag.
Well adding a line

Code: Select all

{ 0, 0, 200, NULL, (void*) &appData.logoSize, "", NULL, Spin, N_("Logo Size (0=off, requires restart):") },
in the list of options for a dialog of your choice (perhaps boardOptions?) in dialogs.c should do the trick.
Oh, wow good to know. Is there a specific syntax? I just get, "could not parse move" when I type in the command like -autoLogo 0
Hmm, perhaps it only works in WinBoard then. I will have a look at it. It was supposed to work on every line that started with a hyphen, as those could never be moves, FENs or move numbers. Or perhaps it tests for a leading slash, because that is WinBoard option syntax. It is so long ago that I sort of forgot.
JoshPettus
Posts: 730
Joined: Fri Oct 19, 2012 2:23 am

Re: OSX Xboard 4.7.2 .app

Post by JoshPettus »

hgm wrote: I think the best solution would be to disable or suppress the button completely when editing tags or engine list.
The save button works when editing tags, in any case I didn't press it when trying to use the Edit Engine List.
Well adding a line

Code: Select all

{ 0, 0, 200, NULL, (void*) &appData.logoSize, "", NULL, Spin, N_("Logo Size (0=off, requires restart):") },
Great I'll give it a try! I think in winboard, Display Logo's is put in the General Options, unless we should move that too?
User avatar
hgm
Posts: 27795
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: OSX Xboard 4.7.2 .app

Post by hgm »

JoshPettus wrote:Great I'll give it a try! I think in winboard, Display Logo's is put in the General Options, unless we should move that too?
Well, in WinBoard I mainly put it there because it was just a checkbox, and the General Options dialog is comparatively easy to modify in WinBoard. As it considers the graphics of the main window, I think the Board Options dialog would be a more logical place.

I guess I was too quick with the EditTagsPopUp. I thought this was back-end, and just copied the code with which WinBoard called it. But it turns out it is front-end, and WinBoard and XBoard each have their own version of EditTagsPopUp. Both happen to take two arguments, but in the WinBoard version the second one is the place where it should store back the result, while in XBoard it is the title of the window, and the result is always assigned to tge PGN tags (unless you are editing book, when it goes to the book file). So for this to work, some changes in the XBoard EditTagsPopUp still have to be made, so that it does not automatically store the results in the PGN tags, but that a parameter will indicate where it should be stored. I will let you know when I pushed something that does this.
JoshPettus
Posts: 730
Joined: Fri Oct 19, 2012 2:23 am

Re: OSX Xboard 4.7.2 .app

Post by JoshPettus »

Just so you know, I actually may be away from all web things till next Saturday. So take your time.
JoshPettus
Posts: 730
Joined: Fri Oct 19, 2012 2:23 am

Re: OSX Xboard 4.7.2 .app

Post by JoshPettus »

Hey, I actually got a chance to take a look, at what you did. Really nice work!
I quite like the Chat/ICS window. Plus how you managed to pop up the ICS text Menu is a really neat compromise to make something that works in GTK and Xaw. Although it works pretty good, gtk does have that actual right click menu with cut/copy/paste ect. Is there a way we could relay the ICS text menu into that in the gtk version?

------------------------
I noticed a few things though in your master branch.

Don't forget to put in that last bit of code with the renaming of items in the user conf file. in args.h

Code: Select all

    case ArgFilename:
      if(*(char**)ad->argLoc == NULL) break; // just in case
      { char buf[MSG_SIZ];
        snprintf(buf, MSG_SIZ, "%s", *(char**)ad->argLoc);
#ifdef __APPLE__
        if(strstr(buf, DATADIR) == buf)
          snprintf(buf, MSG_SIZ, "~~%s", *(char**)ad->argLoc + strlen(DATADIR));
#endif
        if (strchr(buf, '\"')) {
          fprintf(f, OPTCHAR "%s" SEPCHAR "'%s'\n", ad->argName, buf);
        } else {
          fprintf(f, OPTCHAR "%s" SEPCHAR "\"%s\"\n", ad->argName, buf);
        }
      }
      break;
    case ArgBoardSize: 
---------------------------------------
Next that old issue where if you open xboard twice it opens a million times is in your master branch. I suspect a suppression line must have been lost somewhere along the way. (it's works fine in the master-20140119 branch on savannah)
----------------------------------------
Lastly, with the new integrated ics menu, I tried replacing my .command scripts with .xop files as terminal won't be needed anymore. Only when the .xop file launches the ics with just:

Code: Select all

-ics
-icshost freechess.org
I get an error
"Exiting: Got an end of file from keyboard"
If I hit OK, it closes xboard. If I close the window of the popup, xboard stays open. I suspect it happens because it's being opened without the terminal.
User avatar
hgm
Posts: 27795
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: OSX Xboard 4.7.2 .app

Post by hgm »

Currently the terminal is not abandoned yet, and the ICS Console just lives next to it as an optional feature. So it still tries to read from the terminal, and when there is none, this produces the end-of-file condition. I guess I could make it such that when such an end-of-file is detected, I should alter XBoard's reaction to it. In stead of producing a fatal error, it should simply set some flag to indicate that the terminal is closed, close the input source to prevent further reading, and refrain from writing to it when this flag is set. This could be a biit tricky, because I am not sure whether XBoard will detect this end-of-file before or after the ICS Console window is opened. If it would be before, it goes through a period where it is not able to present any ICS output to the user, so that this output (e.g. the ICS welcome message) might get lost completely if you really start without any terminal at all.

As to the context menu: indeed it replaces the usual cut/copy/paste etc. menu that would appear on right-click in a text edit. In WinBoard this is solved by putting those entries always in the ICS context menu, in addition to the user-configured entries. Now 'cut' and 'paste' really seem pointless actions in the output mmemos; the user should really not be able to alter them at all. That would leave 'copy' and perhaps 'select all'. Now these are not extremely important, as you can always use the key bindings Ctrl-C and Ctrl-A for those. But I could put them always in the menu, like WinBoard has. Or, perhaps better, I could define special commands $copy and $all, which XBoard would recognize (like it now already recognizes $chat), and would perform a specific action for them rather than sending them to the ICS. Then the user could decide if he wants those buttons in the ICS Text Menu.

I will take a look at the other issues.