Skip to content

Commit 4ad14fa

Browse files
authored
Allow choice of foreground and background colors for Medley X11/SDL display (#511)
* Allow choice of foreground and background colors for Medley X11 display lde/ldex Accepts -fg/-foreground <color> and -bg/-background <color>, or the corresponding X resources ldex*foreground and ldex*background to specify the colors that will represent the monochrome Medley display pixels. * Extend screen foreground/background color selection to SDL display subsystem (ldesdl)
1 parent aa4df51 commit 4ad14fa

File tree

4 files changed

+894
-43
lines changed

4 files changed

+894
-43
lines changed

src/main.c

+22-1
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,8 @@ const char *helpstring =
288288
-info Print general info about the system\n\
289289
-help Print this message\n\
290290
-pixelscale <n> The amount of pixels to show for one Medley screen pixel.\n\
291+
-fg/-foreground <color> Screen foreground color, default Black. X color name or #RRBBGG hex\n\
292+
-bg/-background <color> Screen background color, default White. X color name or #RRBBGG hex\n\
291293
-sc[reen] <w>x<h>] The Medley screen geometry\n\
292294
-t <title> The window title\n\
293295
-title <title> The window title\n";
@@ -316,6 +318,12 @@ const char *nethubHelpstring = "";
316318
extern int insnsCountdownForTimerAsyncEmulation;
317319
#endif
318320

321+
#if defined(XWINDOW) || defined(SDL)
322+
char foregroundColorName[64] = {0};
323+
extern char foregroundColorName[64];
324+
char backgroundColorName[64] = {0};
325+
extern char backgroundColorName[64];
326+
#endif
319327
/************************************************************************/
320328
/* */
321329
/* M A I N E N T R Y P O I N T */
@@ -488,8 +496,21 @@ int main(int argc, char *argv[])
488496
(void)fprintf(stderr, "Missing argument after -title\n");
489497
exit(1);
490498
}
499+
} else if (strcmp(argv[i], "-fg") == 0 || strcmp(argv[i], "-foreground") == 0) {
500+
if (argc > ++i) {
501+
strncpy(foregroundColorName, argv[i], sizeof(foregroundColorName) - 1);
502+
} else {
503+
(void)fprintf(stderr, "Missing argument after -fg/-foreground\n");
504+
exit(1);
505+
}
506+
} else if (strcmp(argv[i], "-bg") == 0 || strcmp(argv[i], "-background") == 0) {
507+
if (argc > ++i) {
508+
strncpy(backgroundColorName, argv[i], sizeof(backgroundColorName) - 1);
509+
} else {
510+
(void)fprintf(stderr, "Missing argument after -bg/-background\n");
511+
exit(1);
512+
}
491513
}
492-
493514
#endif /* SDL */
494515
/* Can only do this under SUNOs, for now */
495516
else if (!strcmp(argv[i], "-E")) { /**** ethernet info ****/

0 commit comments

Comments
 (0)