[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master a6a4f1d6d1: Improve font dialog on macOS
From: |
Po Lu |
Subject: |
master a6a4f1d6d1: Improve font dialog on macOS |
Date: |
Mon, 2 May 2022 03:07:10 -0400 (EDT) |
branch: master
commit a6a4f1d6d16bfc4d33c09d6d5a8038786d8e1325
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>
Improve font dialog on macOS
* src/nsterm.m ([EmacsView changeFont:]): Don't exit loop here
on macOS.
([EmacsView noteUserSelectedFont]): New function.
([EmacsView showFontPanel]): Add explicit "OK" button on macOS.
---
src/nsterm.m | 41 ++++++++++++++++++++++++++++++++++++++++-
1 file changed, 40 insertions(+), 1 deletion(-)
diff --git a/src/nsterm.m b/src/nsterm.m
index f9d46c73d7..f2bf1c1c4a 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -6170,9 +6170,19 @@ ns_font_desc_to_font_spec (NSFontDescriptor *desc,
NSFont *font)
if (font_panel_result)
[font_panel_result retain];
+#ifndef NS_IMPL_COCOA
+ font_panel_active = NO;
+ [NSApp stop: self];
+#endif
+}
+
+#ifdef NS_IMPL_COCOA
+- (void) noteUserSelectedFont
+{
font_panel_active = NO;
[NSApp stop: self];
}
+#endif
- (Lisp_Object) showFontPanel
{
@@ -6180,6 +6190,10 @@ ns_font_desc_to_font_spec (NSFontDescriptor *desc,
NSFont *font)
struct font *font = FRAME_OUTPUT_DATA (emacsframe)->font;
NSFont *nsfont, *result;
struct timespec timeout;
+#ifdef NS_IMPL_COCOA
+ NSButton *button;
+ BOOL canceled;
+#endif
#ifdef NS_IMPL_GNUSTEP
nsfont = ((struct nsfont_info *) font)->nsfont;
@@ -6187,6 +6201,21 @@ ns_font_desc_to_font_spec (NSFontDescriptor *desc,
NSFont *font)
nsfont = (NSFont *) macfont_get_nsctfont (font);
#endif
+#ifdef NS_IMPL_COCOA
+ /* FIXME: this button could be made a lot prettier, but I don't know
+ how. */
+ button = [[NSButton alloc] initWithFrame: NSMakeRect (0, 0, 192, 40)];
+ [button setTitle: @"OK"];
+ [button setTarget: self];
+ [button setAction: @selector (noteUserSelectedFont)];
+ [button setButtonType: NSButtonTypeMomentaryPushIn];
+ [button setHidden: NO];
+
+ [[fm fontPanel: YES] setAccessoryView: button];
+ [button release];
+ [[fm fontPanel: YES] setDefaultButtonCell: [button cell]];
+#endif
+
[fm setSelectedFont: nsfont isMultiple: NO];
[fm orderFrontFontPanel: NSApp];
@@ -6195,13 +6224,23 @@ ns_font_desc_to_font_spec (NSFontDescriptor *desc,
NSFont *font)
block_input ();
while (font_panel_active
- && [[fm fontPanel: YES] isVisible])
+#ifdef NS_IMPL_COCOA
+ && (canceled = [[fm fontPanel: YES] isVisible])
+#else
+ && [[fm fontPanel: YES] isVisible]
+#endif
+ )
ns_select_1 (0, NULL, NULL, NULL, &timeout, NULL, YES);
unblock_input ();
if (font_panel_result)
[font_panel_result autorelease];
+#ifdef NS_IMPL_COCOA
+ if (!canceled)
+ font_panel_result = nil;
+#endif
+
result = font_panel_result;
font_panel_result = nil;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master a6a4f1d6d1: Improve font dialog on macOS,
Po Lu <=