diff options
Diffstat (limited to '')
-rw-r--r-- | bin/gfcocoa.m | 8 | ||||
-rw-r--r-- | bin/gfxx.c | 21 |
2 files changed, 20 insertions, 9 deletions
diff --git a/bin/gfcocoa.m b/bin/gfcocoa.m index 0e2fbe2c..13b218a7 100644 --- a/bin/gfcocoa.m +++ b/bin/gfcocoa.m @@ -23,6 +23,7 @@ #define UNUSED __attribute__((unused)) extern int init(int argc, char *argv[]); +extern const char *title(void); extern void draw(uint32_t *buf, size_t xres, size_t yres); extern void input(char in); @@ -40,6 +41,10 @@ extern void input(char in); return [super initWithFrame: frameRect]; } +- (void) setWindowTitle { + [[self window] setTitle: [NSString stringWithUTF8String: title()]]; +} + - (void) draw { draw(buf, [self frame].size.width, [self frame].size.height); [self setNeedsDisplay: YES]; @@ -90,6 +95,7 @@ extern void input(char in); ]; if (converted) { input(in); + [self setWindowTitle]; [self draw]; } } @@ -138,11 +144,11 @@ int main(int argc, char *argv[]) { backing: NSBackingStoreBuffered defer: YES ]; - [window setTitle: name]; [window center]; BufferView *view = [[BufferView alloc] initWithFrame: [window frame]]; [window setContentView: view]; + [view setWindowTitle]; [window makeKeyAndOrderFront: nil]; [NSApp activateIgnoringOtherApps: YES]; diff --git a/bin/gfxx.c b/bin/gfxx.c index d451d22c..6d187cb9 100644 --- a/bin/gfxx.c +++ b/bin/gfxx.c @@ -59,7 +59,7 @@ extern int init(int argc, char *argv[]) { const char *path = NULL; int opt; - while (0 < (opt = getopt(argc, argv, "c:b:e:E:n:w:fmz:"))) { + while (0 < (opt = getopt(argc, argv, "c:b:e:E:n:fmw:z:"))) { switch (opt) { case 'c': switch (optarg[0]) { case 'p': space = COLOR_PALETTE; break; @@ -86,9 +86,9 @@ extern int init(int argc, char *argv[]) { bits[3] = optarg[len-1] - '0'; } break; case 'n': offset = strtoul(optarg, NULL, 0); break; - case 'w': width = strtoul(optarg, NULL, 0); break; case 'f': flip ^= true; break; case 'm': mirror ^= true; break; + case 'w': width = strtoul(optarg, NULL, 0); break; case 'z': scale = strtoul(optarg, NULL, 0); break; default: return EX_USAGE; } @@ -119,19 +119,24 @@ extern int init(int argc, char *argv[]) { return EX_OK; } -static void printOpts(void) { - printf( - "gfxx -c %s -e %c -E %c -b %c%c%c%c -n %#zx -w %zu %s%s-z %zu\n", +static char options[128]; + +extern const char *title(void) { + snprintf( + options, + sizeof(options), + "gfxx -c %s -e%c -E%c -b %c%c%c%c -n %#zx %s%s-w %zu -z %zu", (const char *[COLOR__MAX]){ "palette", "grayscale", "rgb" }[space], "lb"[byteOrder], "lb"[bitOrder], bits[0] + '0', bits[1] + '0', bits[2] + '0', bits[3] + '0', offset, - width, flip ? "-f " : "", mirror ? "-m " : "", + width, scale ); + return options; } struct Iter { @@ -284,8 +289,8 @@ extern void input(char in) { size_t pixel = (BITS_TOTAL + 7) / 8; size_t row = width * pixel; switch (in) { - case 'q': printOpts(); exit(EX_OK); - break; case 'o': printOpts(); + case 'q': title(); printf("%s\n", options); exit(EX_OK); + break; case 'o': title(); printf("%s\n", options); break; case '[': if (!space--) space = COLOR__MAX - 1; break; case ']': if (++space == COLOR__MAX) space = 0; break; case '{': if (!preset--) preset = PRESETS_LEN - 1; setPreset(); |