"Insert contents of `ns-working-text' as UTF-8 string and mark with
`ns-working-overlay'. Any previously existing working text is cleared first.
The overlay is assigned the face `ns-working-text-face'."
- ;; FIXME: if buffer is read-only, don't try to insert anything
- ;; and if text is bound to a command, execute that instead (Bug#1453)
+ ;; FIXME: if buffer is read-only, don't try to insert anything, and
+ ;; if text is bound to a command, execute that instead (Bug#1453).
(interactive)
(ns-delete-working-text)
(let ((start (point)))
;;;; File handling.
(defun x-file-dialog (prompt dir default_filename mustmatch only_dir_p)
-"SKIP: real doc in xfns.c."
+ "SKIP: real doc in xfns.c."
(ns-read-file-name prompt dir mustmatch default_filename only_dir_p))
(defun ns-open-file-using-panel ()
*/
/* This should be the first include, as it may set up #defines affecting
- interpretation of even the system includes. */
+ interpretation of even the system includes. */
#include <config.h>
#include <math.h>
static EmacsTooltip *ns_tooltip = nil;
-/* Static variables to handle applescript execution. */
+/* Static variables to handle AppleScript execution. */
static Lisp_Object as_script, *as_result;
static int as_status;
id view =nil, window =nil;
if (!FRAMEP (maybeFrame) || !FRAME_NS_P (XFRAME (maybeFrame)))
- maybeFrame = selected_frame;/*wrong_type_argument (Qframep, maybeFrame); */
+ maybeFrame = selected_frame; /* wrong_type_argument (Qframep, maybeFrame); */
if (!NILP (maybeFrame))
view = FRAME_NS_VIEW (XFRAME (maybeFrame));
static Lisp_Object
interpret_services_menu (NSMenu *menu, Lisp_Object prefix, Lisp_Object old)
/* --------------------------------------------------------------------------
- Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side
+ Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side.
-------------------------------------------------------------------------- */
{
int i, count;
if (FRAME_NS_VIEW (f))
{
update_face_from_frame_parameter (f, Qforeground_color, arg);
- /*recompute_basic_faces (f); */
+ /* recompute_basic_faces (f); */
if (FRAME_VISIBLE_P (f))
SET_FRAME_GARBAGED (f);
}
error ("Unknown color");
}
- /* clear the frame; in some instances the NS-internal GC appears not to
- update, or it does update and cannot clear old text properly */
+ /* Clear the frame; in some instances the NS-internal GC appears not
+ to update, or it does update and cannot clear old text
+ properly. */
if (FRAME_VISIBLE_P (f))
ns_clear_frame (f);
NSView *view = FRAME_NS_VIEW (f);
NSTRACE ("x_set_icon_name");
- /* see if it's changed */
+ /* See if it's changed. */
if (STRINGP (arg))
{
if (STRINGP (oldval) && EQ (Fstring_equal (oldval, arg), Qt))
if (nlines)
{
FRAME_EXTERNAL_MENU_BAR (f) = 1;
- /* does for all frames, whereas we just want for one frame
+ /* Does for all frames, whereas we just want for one frame
[NSMenu setMenuBarVisible: YES]; */
}
else
{
if (FRAME_EXTERNAL_MENU_BAR (f) == 1)
free_frame_menubar (f);
- /* [NSMenu setMenuBarVisible: NO]; */
+ /* [NSMenu setMenuBarVisible: NO]; */
FRAME_EXTERNAL_MENU_BAR (f) = 0;
}
}
static void
x_set_tool_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval)
{
- /* Currently, when the tool bar change state, the frame is resized.
+ /* Currently, when the tool bar changes state, the frame is resized.
TODO: It would be better if this didn't occur when 1) the frame
is full height or maximized or 2) when specified by
- `frame-inhibit-implied-resize'. */
+ `frame-inhibit-implied-resize'. */
int nlines;
NSTRACE ("x_set_tool_bar_lines");
chain = XCDR (chain))
{
elt = XCAR (chain);
- /* special case: t means go by file type */
+ /* Special case: t means go by file type. */
if (SYMBOLP (elt) && EQ (elt, Qt) && SSDATA (f->name)[0] == '/')
{
NSString *str
store_frame_param (f, Qicon_type, arg);
}
- /* do it the implicit way */
+ /* Do it the implicit way. */
if (NILP (arg))
{
ns_implicitly_set_icon_type (f);
static void
x_set_mouse_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
{
- /* don't think we can do this on Nextstep */
+ /* Don't think we can do this on Nextstep. */
}
/* This is for use by x-server-version and collapses all version info we
have into a single int. For a better picture of the implementation
- running, use ns_appkit_version_str.*/
+ running, use ns_appkit_version_str. */
static int
ns_appkit_version_int (void)
{
}
-/* Note: see frame.c for template, also where generic functions are impl */
+/* Note: see frame.c for template, also where generic functions are
+ implemented. */
frame_parm_handler ns_frame_parm_handlers[] =
{
x_set_autoraise, /* generic OK */
#ifdef NS_IMPL_COCOA
x_set_undecorated,
#else
- 0, /*x_set_undecorated */
+ 0, /* x_set_undecorated */
#endif
x_set_parent_frame,
0, /* x_set_skip_taskbar */
/* use for default font name */
id font = [NSFont userFixedPitchFontOfSize: -1.0]; /* default */
x_default_parameter (f, parms, Qfontsize,
- make_number (0 /*(int)[font pointSize]*/),
+ make_number (0 /* (int)[font pointSize] */),
"fontSize", "FontSize", RES_TYPE_NUMBER);
// Remove ' Regular', not handled by backends.
char *fontname = xstrdup ([[font displayName] UTF8String]);
"foreground", "Foreground", RES_TYPE_STRING);
x_default_parameter (f, parms, Qbackground_color, build_string ("White"),
"background", "Background", RES_TYPE_STRING);
- /* FIXME: not supported yet in Nextstep */
x_default_parameter (f, parms, Qline_spacing, Qnil,
"lineSpacing", "LineSpacing", RES_TYPE_NUMBER);
x_default_parameter (f, parms, Qleft_fringe, Qnil,
f->no_split = minibuffer_only || (!EQ (tem, Qunbound) && !EQ (tem, Qnil));
/* NOTE: on other terms, this is done in set_mouse_color, however this
- was not getting called under Nextstep */
+ was not getting called under Nextstep. */
f->output_data.ns->text_cursor = [NSCursor IBeamCursor];
f->output_data.ns->nontext_cursor = [NSCursor arrowCursor];
f->output_data.ns->modeline_cursor = [NSCursor pointingHandCursor];
/* ns_display_info does not have a reference_count. */
f->terminal->reference_count++;
- /* It is now ok to make the frame official even if we get an error below.
- The frame needs to be on Vframe_list or making it visible won't work. */
+ /* It is now ok to make the frame official even if we get an error
+ below. The frame needs to be on Vframe_list or making it visible
+ won't work. */
Vframe_list = Fcons (frame, Vframe_list);
x_default_parameter (f, parms, Qicon_type, Qnil,
static BOOL
ns_window_is_ancestor (NSWindow *win, NSWindow *candidate)
-/* Test whether CANDIDATE is an ancestor window of WIN. */
+/* Test whether CANDIDATE is an ancestor window of WIN. */
{
if (candidate == NULL)
return NO;
{
Lisp_Object frame;
- /* Check against [win parentWindow] so that it doesn't match itself. */
+ /* Check against [win parentWindow] so that it doesn't match
+ itself. */
if (parent == nil || ns_window_is_ancestor (parent, [win parentWindow]))
{
XSETFRAME (frame, ((EmacsView *)[win delegate])->emacsframe);
DEFUN ("ns-popup-font-panel", Fns_popup_font_panel, Sns_popup_font_panel,
0, 1, "",
- doc: /* Pop up the font panel. */)
+ doc: /* Pop up the font panel. */)
(Lisp_Object frame)
{
struct frame *f = decode_window_system_frame (frame);
(Lisp_Object terminal)
{
check_ns_display_info (terminal);
- /* This function has no real equivalent under NeXTstep. Return nil to
- indicate this. */
+ /* This function has no real equivalent under Nextstep. Return nil to
+ indicate this. */
return Qnil;
}
(Lisp_Object terminal)
{
check_ns_display_info (terminal);
- /*NOTE: it is unclear what would best correspond with "protocol";
- we return 10.3, meaning Panther, since this is roughly the
- level that GNUstep's APIs correspond to.
- The last number is where we distinguish between the Apple
- and GNUstep implementations ("distributor-specific release
- number") and give int'ized versions of major.minor. */
+ /* NOTE: it is unclear what would best correspond with "protocol";
+ we return 10.3, meaning Panther, since this is roughly the
+ level that GNUstep's APIs correspond to. The last number
+ is where we distinguish between the Apple and GNUstep
+ implementations ("distributor-specific release number") and
+ give int'ized versions of major.minor. */
return list3i (10, 3, ns_appkit_version_int ());
}
else if ( depth == NSBestDepth (NSCalibratedRGBColorSpace, 8, 24, NO, NULL))
return intern ("direct-color");
else
- /* color mgmt as far as we do it is really handled by Nextstep itself anyway */
+ /* Color management as far as we do it is really handled by
+ Nextstep itself anyway. */
return intern ("direct-color");
}
doc: /* Determine font PostScript or family name for font NAME.
NAME should be a string containing either the font name or an XLFD
font descriptor. If string contains `fontset' and not
-`fontset-startup', it is left alone. */)
+`fontset-startup', it is left alone. */)
(Lisp_Object name)
{
char *nm;
status as function value. A zero is returned if compilation and
execution is successful, in which case *RESULT is set to a Lisp
string or a number containing the resulting script value. Otherwise,
- 1 is returned. */
+ 1 is returned. */
static int
ns_do_applescript (Lisp_Object script, Lisp_Object *result)
{
return 0;
}
-/* Helper function called from sendEvent to run applescript
+/* Helper function called from sendEvent to run AppleScript
from within the main event loop. */
void
doc: /* Execute AppleScript SCRIPT and return the result.
If compilation and execution are successful, the resulting script value
is returned as a string, a number or, in the case of other constructs, t.
-In case the execution fails, an error is signaled. */)
+In case the execution fails, an error is signaled. */)
(Lisp_Object script)
{
Lisp_Object result;
as_script = script;
as_result = &result;
- /* executing apple script requires the event loop to run, otherwise
+ /* Executing AppleScript requires the event loop to run, otherwise
errors aren't returned and executeAndReturnError hangs forever.
- Post an event that runs applescript and then start the event loop.
- The event loop is exited when the script is done. */
+ Post an event that runs AppleScript and then start the event
+ loop. The event loop is exited when the script is done. */
nxev = [NSEvent otherEventWithType: NSEventTypeApplicationDefined
location: NSMakePoint (0, 0)
modifierFlags: 0
[NSApp postEvent: nxev atStart: NO];
- // If there are other events, the event loop may exit. Keep running
- // until the script has been handled. */
+ /* If there are other events, the event loop may exit. Keep running
+ until the script has been handled. */
ns_init_events (&ev);
while (! NILP (as_script))
[NSApp run];
height - 1) / height;
}
-/* terms impl this instead of x-get-resource directly */
+/* Terms implement this instead of x-get-resource directly. */
char *
x_get_string_resource (XrmDatabase rdb, const char *name, const char *class)
{
/* CGDisplayIOServicePort is deprecated. Do it another (harder) way.
Is this code OK for macOS < 10.9, and GNUstep? I suspect it is,
- in which case is it worth keeping the other method in here? */
+ in which case is it worth keeping the other method in here? */
if (IOMasterPort (MACH_PORT_NULL, &masterPort) != kIOReturnSuccess
|| IOServiceGetMatchingServices (masterPort,
- height);
}
- /* Find the screen that pt is on. */
+ /* Find the screen that pt is on. */
for (screen in [NSScreen screens])
if (pt.x >= screen.frame.origin.x
&& pt.x < screen.frame.origin.x + screen.frame.size.width
if (CGRectContainsPoint ([screen frame], pt))
which would be neater, but it causes problems building on old
- versions of macOS and in GNUstep. */
+ versions of macOS and in GNUstep. */
/* Ensure in bounds. (Note, screen origin = lower left.) */
if (INTEGERP (left) || INTEGERP (right))
*root_x = pt.x;
else if (pt.x + XINT (dx) <= screen.frame.origin.x)
- *root_x = screen.frame.origin.x; /* Can happen for negative dx */
+ *root_x = screen.frame.origin.x;
else if (pt.x + XINT (dx) + width
<= screen.frame.origin.x + screen.frame.size.width)
/* It fits to the right of the pointer. */
*root_y = pt.y - height - XINT (dy);
else if (pt.y + XINT (dy) + height
<= screen.frame.origin.y + screen.frame.size.height)
- /* It fits above the pointer */
+ /* It fits above the pointer. */
*root_y = pt.y + XINT (dy);
else
/* Put it on the top. */
{
#ifdef NS_IMPL_COCOA
/* GNUstep doesn't support CGWarpMouseCursorPosition, so none of
- this will work. */
+ this will work. */
struct frame *f = SELECTED_FRAME ();
EmacsView *view = FRAME_NS_VIEW (f);
NSScreen *screen = [[view window] screen];
doc: /* Return absolute position of mouse cursor in pixels.
The position is returned as a cons cell (X . Y) of the
coordinates of the mouse cursor position in pixels relative to a
-position (0, 0) of the selected frame's terminal. */)
+position (0, 0) of the selected frame's terminal. */)
(void)
{
struct frame *f = SELECTED_FRAME ();
case NSPageDownFunctionKey:
case NSEndFunctionKey:
/* Don't send command modified keys, as those are handled in the
- performKeyEquivalent method of the super class.
- */
+ performKeyEquivalent method of the super class. */
if (! ([theEvent modifierFlags] & NSEventModifierFlagCommand))
{
[panel sendEvent: theEvent];
them here. TODO: handle Emacs key bindings for copy/cut/select-all
here, paste works, because we have that in our Edit menu.
I.e. refactor out code in nsterm.m, keyDown: to figure out the
- correct modifier.
- */
+ correct modifier. */
case 'x': // Cut
case 'c': // Copy
case 'v': // Paste
*/
/* This should be the first include, as it may set up #defines affecting
- interpretation of even the system includes. */
+ interpretation of even the system includes. */
#include <config.h>
#include "lisp.h"
#include "font.h"
#include "termchar.h"
-/* TODO: Drop once we can assume gnustep-gui 0.17.1. */
+/* TODO: Drop once we can assume gnustep-gui 0.17.1. */
#ifdef NS_IMPL_GNUSTEP
#import <AppKit/NSFontDescriptor.h>
#endif
#define NSFONT_TRACE 0
#define LCD_SMOOTHING_MARGIN 2
-/* font glyph and metrics caching functions, implemented at end */
+/* Font glyph and metrics caching functions, implemented at end. */
static void ns_uni_to_glyphs (struct nsfont_info *font_info,
unsigned char block);
static void ns_glyph_metrics (struct nsfont_info *font_info,
/* Replace spaces w/another character so emacs core font parsing routines
- aren't thrown off. */
+ aren't thrown off. */
static void
ns_escape_name (char *name)
{
}
-/* Reconstruct spaces in a font family name passed through emacs. */
+/* Reconstruct spaces in a font family name passed through emacs. */
static void
ns_unescape_name (char *name)
{
}
-/* Extract family name from a font spec. */
+/* Extract family name from a font spec. */
static NSString *
ns_get_family (Lisp_Object font_spec)
{
/* Return 0 if attr not set, else value (which might also be 0).
On Leopard 0 gets returned even on descriptors where the attribute
was never set, so there's no way to distinguish between unspecified
- and set to not have. Callers should assume 0 means unspecified. */
+ and set to not have. Callers should assume 0 means unspecified. */
static float
ns_attribute_fvalue (NSFontDescriptor *fdesc, NSString *trait)
{
/* Converts FONT_WEIGHT, FONT_SLANT, FONT_WIDTH, plus family and script/lang
- to NSFont descriptor. Information under extra only needed for matching. */
+ to NSFont descriptor. Information under extra only needed for matching. */
#define STYLE_REF 100
static NSFontDescriptor *
ns_spec_to_descriptor (Lisp_Object font_spec)
NSString *family = ns_get_family (font_spec);
float n;
- /* add each attr in font_spec to fdAttrs.. */
+ /* Add each attr in font_spec to fdAttrs. */
n = min (FONT_WEIGHT_NUMERIC (font_spec), 200);
if (n != -1 && n != STYLE_REF)
[tdict setObject: [NSNumber numberWithFloat: (n - 100.0F) / 100.0F]
}
-/* Converts NSFont descriptor to FONT_WEIGHT, FONT_SLANT, FONT_WIDTH, etc.. */
+/* Converts NSFont descriptor to FONT_WEIGHT, FONT_SLANT, FONT_WIDTH, etc. */
static Lisp_Object
ns_descriptor_to_entity (NSFontDescriptor *desc,
Lisp_Object extra,
unsigned int traits = [desc symbolicTraits];
char *escapedFamily;
- /* Shouldn't happen, but on Tiger fallback desc gets name but no family. */
+ /* Shouldn't happen, but on Tiger fallback desc gets name but no family. */
if (family == nil)
family = [desc objectForKey: NSFontNameAttribute];
if (family == nil)
}
-/* Default font entity. */
+/* Default font entity. */
static Lisp_Object
ns_fallback_entity (void)
{
}
-/* Utility: get width of a char c in screen font SFONT */
+/* Utility: get width of a char c in screen font SFONT. */
static CGFloat
ns_char_width (NSFont *sfont, int c)
{
/* Return whether set1 covers set2 to a reasonable extent given by pct.
We check, out of each 16 Unicode char range containing chars in set2,
whether at least one character is present in set1.
- This must be true for pct of the pairs to consider it covering. */
+ This must be true for pct of the pairs to consider it covering. */
static BOOL
ns_charset_covers(NSCharacterSet *set1, NSCharacterSet *set2, float pct)
{
if (*bytes1 == 0) // *bytes1 & *bytes2 != *bytes2
off++;
}
-//fprintf(stderr, "off = %d\ttot = %d\n", off,tot);
+ // fprintf(stderr, "off = %d\ttot = %d\n", off,tot);
return (float)off / tot < 1.0F - pct;
}
/* Convert :lang property to a script. Use of :lang property by font backend
- seems to be limited for now (2009/05) to ja, zh, and ko. */
+ seems to be limited for now (2009/05) to ja, zh, and ko. */
static NSString
*ns_lang_to_script (Lisp_Object lang)
{
if (!strcmp (SSDATA (SYMBOL_NAME (lang)), "ja"))
return @"han";
/* NOTE: ja given for any hanzi that's also a kanji, but Chinese fonts
- have more characters. */
+ have more characters. */
else if (!strcmp (SSDATA (SYMBOL_NAME (lang)), "zh"))
return @"han";
else if (!strcmp (SSDATA (SYMBOL_NAME (lang)), "ko"))
/* Convert OTF 4-letter script code to emacs script name. (Why can't
- everyone just use some standard Unicode names for these?) */
+ everyone just use some standard Unicode names for these?) */
static NSString
*ns_otf_to_script (Lisp_Object otf)
{
}
-/* Convert a font registry, such as */
+/* Convert a font registry. */
static NSString
*ns_registry_to_script (char *reg)
{
/* Searches the :script, :lang, and :otf extra-bundle properties of the spec,
plus registry regular property, for something that can be mapped to a
- Unicode script. Empty string returned if no script spec found. */
+ Unicode script. Empty string returned if no script spec found. */
static NSString
*ns_get_req_script (Lisp_Object font_spec)
{
Lisp_Object reg = AREF (font_spec, FONT_REGISTRY_INDEX);
Lisp_Object extra = AREF (font_spec, FONT_EXTRA_INDEX);
- /* The extra-bundle properties have priority. */
+ /* The extra-bundle properties have priority. */
for ( ; CONSP (extra); extra = XCDR (extra))
{
Lisp_Object tmp = XCAR (extra);
}
}
- /* If we get here, check the charset portion of the registry. */
+ /* If we get here, check the charset portion of the registry. */
if (! NILP (reg))
{
/* XXX: iso10646 is passed in for non-ascii latin-1 characters
(which causes box rendering if we don't treat it like iso8858-1)
- but also for ascii (which causes unnecessary font substitution). */
+ but also for ascii (which causes unnecessary font substitution). */
#if 0
if (EQ (reg, Qiso10646_1))
reg = Qiso8859_1;
/* This small function is static in fontset.c. If it can be made public for
- all ports, remove this, but otherwise it doesn't seem worth the ifdefs. */
+ all ports, remove this, but otherwise it doesn't seem worth the ifdefs. */
static void
accumulate_script_ranges (Lisp_Object arg, Lisp_Object range, Lisp_Object val)
{
/* Use the Unicode range information in Vchar_script_table to convert a script
- name into an NSCharacterSet. */
+ name into an NSCharacterSet. */
static NSCharacterSet
*ns_script_to_charset (NSString *scriptName)
{
If none are found, we reduce the percentage and try again, until 5%.
This provides a font with at least some characters if such can be found.
We don't use isSupersetOfSet: because (a) it doesn't work on Tiger, and
- (b) need approximate match as fonts covering full Unicode ranges are rare. */
+ (b) need approximate match as fonts covering full Unicode ranges are rare. */
static NSSet
*ns_get_covering_families (NSString *script, float pct)
{
{
NSCharacterSet *fset = [[fontMgr fontWithFamily: family
traits: 0 weight: 5 size: 12.0] coveredCharacterSet];
- /* Some fonts on macOS, maybe many on GNUstep, return nil. */
+ /* Some fonts on macOS, maybe many on GNUstep, return nil. */
if (fset == nil)
fset = [NSCharacterSet characterSetWithRange:
NSMakeRange (0, 127)];
/* Implementation for list() and match(). List() can return nil, match()
must return something. Strategy is to drop family name from attribute
-matching set for match. */
+matching set for match. */
static Lisp_Object
ns_findfonts (Lisp_Object font_spec, BOOL isMatch)
{
foundItal = YES;
}
- /* Add synthItal member if needed. */
+ /* Add synthItal member if needed. */
family = [fdesc objectForKey: NSFontFamilyAttribute];
if (family != nil && !foundItal && XINT (Flength (list)) > 0)
{
unblock_input ();
- /* Return something if was a match and nothing found. */
+ /* Return something if was a match and nothing found. */
if (isMatch)
return ns_fallback_entity ();
/* Return a font entity most closely matching with FONT_SPEC on
FRAME. The closeness is determined by the font backend, thus
`face-font-selection-order' is ignored here.
- Properties to be considered are same as for list(). */
+ Properties to be considered are same as for list(). */
static Lisp_Object
nsfont_match (struct frame *f, Lisp_Object font_spec)
{
/* List available families. The value is a list of family names
- (symbols). */
+ (symbols). */
static Lisp_Object
nsfont_list_family (struct frame *f)
{
objectEnumerator];
while ((family = [families nextObject]))
list = Fcons (intern ([family UTF8String]), list);
- /* FIXME: escape the name? */
+ /* FIXME: escape the name? */
if (NSFONT_TRACE)
fprintf (stderr, "nsfont: list families returning %"pI"d entries\n",
if (family == nil)
family = [[NSFont userFixedPitchFontOfSize: 0] familyName];
/* Should be > 0.23 as some font descriptors (e.g. Terminus) set to that
- when setting family in ns_spec_to_descriptor(). */
+ when setting family in ns_spec_to_descriptor(). */
if (ns_attribute_fvalue (fontDesc, NSFontWeightTrait) > 0.50F)
traits |= NSBoldFontMask;
if (fabs (ns_attribute_fvalue (fontDesc, NSFontSlantTrait) > 0.05F))
if (!font)
{
unblock_input ();
- return Qnil; /* FIXME: other terms do, but return Qnil causes segfault */
+ return Qnil; /* FIXME: other terms do, but returning Qnil causes segfault. */
}
font_info->glyphs = xzalloc (0x100 * sizeof *font_info->glyphs);
* -2.00000405... (represented by 0xc000000220000000). Without
* adjustment, the code below would round the descender to -3,
* resulting in a font that would be one pixel higher than
- * intended. */
+ * intended. */
CGFloat adjusted_descender = [sfont descender] + 0.0001;
#ifdef NS_IMPL_GNUSTEP
synthItal || ([fontMgr traitsOfFont: nsfont] & NSItalicFontMask);
/* Metrics etc.; some fonts return an unusually large max advance, so we
- only use it for fonts that have wide characters. */
+ only use it for fonts that have wide characters. */
font_info->width = ([sfont numberOfGlyphs] > 2000) ?
[sfont maximumAdvancement].width : ns_char_width (sfont, '0');
/* max bounds */
font->ascent = font_info->max_bounds.ascent = lrint ([sfont ascender]);
/* Descender is usually negative. Use floor to avoid
- clipping descenders. */
+ clipping descenders. */
font->descent =
font_info->max_bounds.descent = -lrint (floor(adjusted_descender));
font_info->height =
}
-/* Close FONT. */
+/* Close FONT. */
static void
nsfont_close (struct font *font)
{
/* If FONT_ENTITY has a glyph for character C (Unicode code point),
return 1. If not, return 0. If a font must be opened to check
- it, return -1. */
+ it, return -1. */
static int
nsfont_has_char (Lisp_Object entity, int c)
{
/* Return a glyph code of FONT for character C (Unicode code point).
- If FONT doesn't have such a glyph, return FONT_INVALID_CODE. */
+ If FONT doesn't have such a glyph, return FONT_INVALID_CODE. */
static unsigned int
nsfont_encode_char (struct font *font, int c)
{
if (c > 0xFFFF)
return FONT_INVALID_CODE;
- /* did we already cache this block? */
+ /* Did we already cache this block? */
if (!font_info->glyphs[high])
ns_uni_to_glyphs (font_info, high);
/* Perform the size computation of glyphs of FONT and fill in members
of METRICS. The glyphs are specified by their glyph codes in
- CODE (length NGLYPHS). */
+ CODE (length NGLYPHS). */
static void
nsfont_text_extents (struct font *font, unsigned int *code,
int nglyphs, struct font_metrics *metrics)
/* Draw glyphs between FROM and TO of S->char2b at (X Y) pixel
position of frame F with S->FACE and S->GC. If WITH_BACKGROUND,
fill the background in advance. It is assured that WITH_BACKGROUND
- is false when (FROM > 0 || TO < S->nchars). */
+ is false when (FROM > 0 || TO < S->nchars). */
static int
nsfont_draw (struct glyph_string *s, int from, int to, int x, int y,
bool with_background)
-/* NOTE: focus and clip must be set */
+/* NOTE: focus and clip must be set. */
{
static unsigned char cbuf[1024];
unsigned char *c = cbuf;
if (font == NULL)
font = (struct nsfont_info *)FRAME_FONT (s->f);
- /* Select face based on input flags */
+ /* Select face based on input flags. */
flags = s->hl == DRAW_CURSOR ? NS_DUMPGLYPH_CURSOR :
(s->hl == DRAW_MOUSE_FACE ? NS_DUMPGLYPH_MOUSEFACE :
(s->for_overlaps ? NS_DUMPGLYPH_FOREGROUND :
/* Convert UTF-16 (?) to UTF-8 and determine advances. Note if we just ask
NS to render the string, it will come out differently from the individual
- character widths added up because of layout processing. */
+ character widths added up because of layout processing. */
{
int cwidth, twidth = 0;
int hi, lo;
- /* FIXME: composition: no vertical displacement is considered. */
+ /* FIXME: composition: no vertical displacement is considered. */
t += from; /* advance into composition */
for (i = from; i < to; i++, t++)
{
}
else
{
- if (!font->metrics[hi]) /* FIXME: why/how can we need this now? */
+ if (!font->metrics[hi]) /* FIXME: why/how can we need this now? */
ns_glyph_metrics (font, hi);
cwidth = font->metrics[hi][lo].width;
}
twidth += cwidth;
#ifdef NS_IMPL_GNUSTEP
*adv++ = cwidth;
- CHAR_STRING_ADVANCE (*t, c); /* this converts the char to UTF-8 */
+ CHAR_STRING_ADVANCE (*t, c); /* This converts the char to UTF-8. */
#else
(*adv++).width = cwidth;
#endif
*c = 0;
}
- /* fill background if requested */
+ /* Fill background if requested. */
if (with_background && !isComposite)
{
NSRect br = r;
}
if (s->face->box == FACE_NO_BOX)
{
- /* expand unboxed top row over internal border */
+ /* Expand unboxed top row over internal border. */
if (br.origin.y <= fibw + 1 + mbox_line_width)
{
br.size.height += br.origin.y;
========================================================================== */
/* Find and cache corresponding glyph codes for unicode values in given
- hi-byte block of 256. */
+ hi-byte block of 256. */
static void
ns_uni_to_glyphs (struct nsfont_info *font_info, unsigned char block)
{
if (!unichars || !(font_info->glyphs[block]))
emacs_abort ();
- /* create a string containing all Unicode characters in this block */
+ /* Create a string containing all Unicode characters in this block. */
for (idx = block<<8, i = 0; i < 0x100; idx++, i++)
if (idx < 0xD800 || idx > 0xDFFF)
unichars[i] = idx;
length: 0x100
freeWhenDone: NO];
NSGlyphGenerator *glyphGenerator = [NSGlyphGenerator sharedGlyphGenerator];
- /*NSCharacterSet *coveredChars = [nsfont coveredCharacterSet]; */
+ /* NSCharacterSet *coveredChars = [nsfont coveredCharacterSet]; */
unsigned int numGlyphs = [font_info->nsfont numberOfGlyphs];
NSUInteger gInd = 0, cInd = 0;
g = unichars[i];
#else
g = glyphStorage->cglyphs[i];
- /* TODO: is this a good check? maybe need to use coveredChars.. */
+ /* TODO: is this a good check? Maybe need to use coveredChars. */
if (g > numGlyphs || g == NSNullGlyph)
- g = INVALID_GLYPH; /* hopefully unused... */
+ g = INVALID_GLYPH; /* Hopefully unused... */
#endif
*glyphs = g;
}
/* Determine and cache metrics for corresponding glyph codes in given
- hi-byte block of 256. */
+ hi-byte block of 256. */
static void
ns_glyph_metrics (struct nsfont_info *font_info, unsigned char block)
{
metrics->rbearing = lrint (w + rb + LCD_SMOOTHING_MARGIN);
metrics->descent = r.origin.y < 0 ? -r.origin.y : 0;
- /*lrint (hshrink * [sfont ascender] + expand * hd/2); */
+ /* lrint (hshrink * [sfont ascender] + expand * hd/2); */
metrics->ascent = r.size.height - metrics->descent;
-/*-lrint (hshrink* [sfont descender] - expand * hd/2); */
+ /* -lrint (hshrink* [sfont descender] - expand * hd/2); */
}
unblock_input ();
}
#ifdef NS_IMPL_COCOA
-/* helper for font glyph setup */
+/* Helper for font glyph setup. */
@implementation EmacsGlyphStorage
- init
DEFSYM (Qapple, "apple");
DEFSYM (Qmedium, "medium");
DEFVAR_LISP ("ns-reg-to-script", Vns_reg_to_script,
- doc: /* Internal use: maps font registry to Unicode script. */);
+ doc: /* Internal use: maps font registry to Unicode script. */);
ascii_printable = NULL;
}
#ifndef __NSGUI_H__
#define __NSGUI_H__
-/* this gets included from a couple of the plain (non-NS) .c files */
+/* This gets included from a couple of the plain (non-NS) .c files. */
#ifdef __OBJC__
#ifdef NS_IMPL_COCOA
/* XXX: xfaces requires these structures, but the question is are we
- forced to use them? */
+ forced to use them? */
typedef struct _XGCValues
{
unsigned long foreground;
typedef Lisp_Object XrmDatabase;
-/* some sort of attempt to normalize rectangle handling.. seems a bit much
- for what is accomplished */
+/* Some sort of attempt to normalize rectangle handling. Seems a bit
+ much for what is accomplished. */
typedef struct {
int x, y;
unsigned width, height;
-/* This stuff needed by frame.c. */
+/* This stuff needed by frame.c. */
#define ForgetGravity 0
#define NorthWestGravity 1
#define NorthGravity 2
*/
/* This should be the first include, as it may set up #defines affecting
- interpretation of even the system includes. */
+ interpretation of even the system includes. */
#include <config.h>
#include "lisp.h"
C interface. This allows easy calling from C files. We could just
compile everything as Objective-C, but that might mean slower
- compilation and possible difficulties on some platforms..
+ compilation and possible difficulties on some platforms.
========================================================================== */
/* Create image from monochrome bitmap. If both FG and BG are 0
- (black), set the background to white and make it transparent. */
+ (black), set the background to white and make it transparent. */
- (instancetype)initFromXBM: (unsigned char *)bits width: (int)w height: (int)h
fg: (unsigned long)fg bg: (unsigned long)bg
{
}
{
- /* pull bits out to set the (bytewise) alpha mask */
+ /* Pull bits out to set the (bytewise) alpha mask. */
int i, j, k;
unsigned char *s = bits;
unsigned char *rr = planes[0];
}
-/* attempt to pull out pixmap data from a BitmapImageRep; returns NO if fails */
+/* Attempt to pull out pixmap data from a BitmapImageRep; returns NO if fails. */
- (void) setPixmapData
{
NSEnumerator *reps;
}
-/* note; this and next work only for image created with initForXPMWithDepth,
- initFromSkipXBM, or where setPixmapData was called successfully */
+/* Note: this and next work only for image created with initForXPMWithDepth,
+ initFromSkipXBM, or where setPixmapData was called successfully. */
/* return ARGB */
- (unsigned long) getPixelAtX: (int)x Y: (int)y
{
if (bmRep == nil)
return 0;
- /* this method is faster but won't work for bitmaps */
+ /* This method is faster but won't work for bitmaps. */
if (pixmapData[0] != NULL)
{
int loc = x + y * [self size].width;
}
}
-/* returns a pattern color, which is cached here */
+/* Returns a pattern color, which is cached here. */
- (NSColor *)stippleMask
{
if (stippleMask == nil)
return stippleMask;
}
-/* Find the first NSBitmapImageRep which has multiple frames. */
+/* Find the first NSBitmapImageRep which has multiple frames. */
- (NSBitmapImageRep *)getAnimatedBitmapImageRep
{
for (NSImageRep * r in [self representations])
}
/* If the image has multiple frames, get a count of them and the
- animation delay, if available. */
+ animation delay, if available. */
- (Lisp_Object)getMetadata
{
Lisp_Object metadata = Qnil;
return metadata;
}
-/* Attempt to set the animation frame to be displayed. */
+/* Attempt to set the animation frame to be displayed. */
- (BOOL)setFrame: (unsigned int) index
{
NSBitmapImageRep * bm = [self getAnimatedBitmapImageRep];
{
int frames = [[bm valueForProperty:NSImageFrameCount] intValue];
- /* If index is invalid, give up. */
+ /* If index is invalid, give up. */
if (index < 0 || index > frames)
return NO;
}
/* Setting the frame has succeeded, or the image doesn't have
- multiple frames. */
+ multiple frames. */
return YES;
}
Carbon version by Yamamoto Mitsuharu. */
/* This should be the first include, as it may set up #defines affecting
- interpretation of even the system includes. */
+ interpretation of even the system includes. */
#include <config.h>
#include "lisp.h"
#if 0
-/* Include lisp -> C common menu parsing code */
+/* Include lisp -> C common menu parsing code. */
#define ENCODE_MENU_STRING(str) ENCODE_UTF_8 (str)
#include "nsmenu_common.c"
#endif
/* NOTE: toolbar implementation is at end,
- following complete menu implementation. */
+ following complete menu implementation. */
/* ==========================================================================
/* Supposed to discard menubar and free storage. Since we share the
menubar among frames and update its context for the focused window,
- there is nothing to do here. */
+ there is nothing to do here. */
void
free_frame_menubar (struct frame *f)
{
block_input ();
pool = [[NSAutoreleasePool alloc] init];
- /* Menu may have been created automatically; if so, discard it. */
+ /* Menu may have been created automatically; if so, discard it. */
if ([menu isKindOfClass: [EmacsMenu class]] == NO)
{
[menu release];
if (deep_p)
{
- /* Fully parse one or more of the submenus. */
+ /* Fully parse one or more of the submenus. */
int n = 0;
int *submenu_start, *submenu_end;
bool *submenu_top_level_items;
set_buffer_internal_1 (XBUFFER (buffer));
/* TODO: for some reason this is not needed in other terms,
- but some menu updates call Info-extract-pointer which causes
- abort-on-error if waiting-for-input. Needs further investigation. */
+ but some menu updates call Info-extract-pointer which causes
+ abort-on-error if waiting-for-input. Needs further investigation. */
owfi = waiting_for_input;
waiting_for_input = 0;
break;
/* FIXME: we'd like to only parse the needed submenu, but this
- was causing crashes in the _common parsing code.. need to make
- sure proper initialization done.. */
-/* if (submenu && strcmp ([[submenu title] UTF8String], SSDATA (string)))
- continue; */
+ was causing crashes in the _common parsing code: need to make
+ sure proper initialization done. */
+ /* if (submenu && strcmp ([[submenu title] UTF8String], SSDATA (string)))
+ continue; */
submenu_start[i] = menu_items_used;
set_buffer_internal_1 (prev);
- /* Compare the new menu items with previous, and leave off if no change */
+ /* Compare the new menu items with previous, and leave off if no change. */
/* FIXME: following other terms here, but seems like this should be
- done before parse stage 2 above, since its results aren't used */
+ done before parse stage 2 above, since its results aren't used. */
if (previous_menu_items_used
&& (!submenu || (submenu && submenu == last_submenu))
&& menu_items_used == previous_menu_items_used)
{
for (i = 0; i < previous_menu_items_used; i++)
/* FIXME: this ALWAYS fails on Buffers menu items.. something
- about their strings causes them to change every time, so we
- double-check failures */
+ about their strings causes them to change every time, so we
+ double-check failures. */
if (!EQ (previous_items[i], AREF (menu_items, i)))
if (!(STRINGP (previous_items[i])
&& STRINGP (AREF (menu_items, i))
break;
if (i == previous_menu_items_used)
{
- /* No change.. */
+ /* No change. */
#if NSMENUPROFILE
ftime (&tb);
return;
}
}
- /* The menu items are different, so store them in the frame */
- /* FIXME: this is not correct for single-submenu case */
+ /* The menu items are different, so store them in the frame. */
+ /* FIXME: this is not correct for single-submenu case. */
fset_menu_bar_vector (f, menu_items);
f->menu_bar_items_used = menu_items_used;
- /* Calls restore_menu_items, etc., as they were outside */
+ /* Calls restore_menu_items, etc., as they were outside. */
unbind_to (specpdl_count, Qnil);
/* Parse stage 2a: now GC cannot happen during the lifetime of the
- widget_value, so it's safe to store data from a Lisp_String */
+ widget_value, so it's safe to store data from a Lisp_String. */
wv = first_wv->contents;
for (i = 0; i < ASIZE (items); i += 4)
{
}
/* Now, update the NS menu; if we have a submenu, use that, otherwise
- create a new menu for each sub and fill it. */
+ create a new menu for each sub and fill it. */
if (submenu)
{
const char *submenuTitle = [[submenu title] UTF8String];
wv->button_type = BUTTON_TYPE_NONE;
first_wv = wv;
- /* Make widget-value tree w/ just the top level menu bar strings */
+ /* Make widget-value tree with just the top level menu bar strings. */
items = FRAME_MENU_BAR_ITEMS (f);
if (NILP (items))
{
}
- /* check if no change.. this mechanism is a bit rough, but ready */
+ /* Check if no change: this mechanism is a bit rough, but ready. */
n = ASIZE (items) / 4;
if (f == last_f && n_previous_strings == n)
{
wv->call_data = (void *) (intptr_t) (-1);
#ifdef NS_IMPL_COCOA
- /* we'll update the real copy under app menu when time comes */
+ /* We'll update the real copy under app menu when time comes. */
if (!strcmp ("Services", wv->name))
{
- /* but we need to make sure it will update on demand */
+ /* But we need to make sure it will update on demand. */
[svcsMenu setFrame: f];
}
else
/* Main emacs core entry point for menubar menus: called to indicate that the
frame's menus have changed, and the *step representation should be updated
- from Lisp. */
+ from Lisp. */
void
set_frame_menubar (struct frame *f, bool first_time, bool deep_p)
{
/* Menu that can define itself from Emacs "widget_value"s and will lazily
update itself when user clicked. Based on Carbon/AppKit implementation
- by Yamamoto Mitsuharu. */
+ by Yamamoto Mitsuharu. */
@implementation EmacsMenu
/* override designated initializer */
#endif /* NS_IMPL_COCOA */
-/* delegate method called when a submenu is being opened: run a 'deep' call
- to set_frame_menubar */
+/* Delegate method called when a submenu is being opened: run a 'deep' call
+ to set_frame_menubar. */
- (void)menuNeedsUpdate: (NSMenu *)menu
{
if (!FRAME_LIVE_P (frame))
[item setEnabled: wv->enabled];
- /* Draw radio buttons and tickboxes */
+ /* Draw radio buttons and tickboxes. */
if (wv->selected && (wv->button_type == BUTTON_TYPE_TOGGLE ||
wv->button_type == BUTTON_TYPE_RADIO))
[item setState: NSOnState];
}
-/* adds an empty submenu and returns it */
+/* Adds an empty submenu and returns it. */
- (EmacsMenu *)addSubmenuWithTitle: (const char *)title forFrame: (struct frame *)f
{
NSString *titleStr = [NSString stringWithUTF8String: title];
return submenu;
}
-/* run a menu in popup mode */
+/* Run a menu in popup mode. */
- (Lisp_Object)runMenuAt: (NSPoint)p forFrame: (struct frame *)f
keymaps: (bool)keymaps
{
NSEvent *e, *event;
long retVal;
-/* p = [view convertPoint:p fromView: nil]; */
+ /* p = [view convertPoint:p fromView: nil]; */
p.y = NSHeight ([view frame]) - p.y;
e = [[view window] currentEvent];
event = [NSEvent mouseEventWithType: NSEventTypeRightMouseDown
timestamp: [e timestamp]
windowNumber: [[view window] windowNumber]
context: nil
- eventNumber: 0/*[e eventNumber] */
+ eventNumber: 0 /* [e eventNumber] */
clickCount: 1
pressure: 0];
first_wv = wv;
#if 0
- /* FIXME: a couple of one-line differences prevent reuse */
+ /* FIXME: a couple of one-line differences prevent reuse. */
wv = digest_single_submenu (0, menu_items_used, 0);
#else
{
widget_value *save_wv = 0, *prev_wv = 0;
widget_value **submenu_stack
= alloca (menu_items_used * sizeof *submenu_stack);
-/* Lisp_Object *subprefix_stack
+ /* Lisp_Object *subprefix_stack
= alloca (menu_items_used * sizeof *subprefix_stack); */
int submenu_depth = 0;
int first_pane = 1;
block_input ();
view->wait_for_tool_bar = NO;
- /* Note: This trigger an animation, which calls windowDidResize
- repeatedly. */
+ /* Note: This triggers an animation, which calls windowDidResize
+ repeatedly. */
f->output_data.ns->in_animation = 1;
[[view toolbar] setVisible: NO];
f->output_data.ns->in_animation = 0;
void
update_frame_tool_bar (struct frame *f)
/* --------------------------------------------------------------------------
- Update toolbar contents
+ Update toolbar contents.
-------------------------------------------------------------------------- */
{
int i, k = 0;
[toolbar clearAll];
#endif
- /* update EmacsToolbar as in GtkUtils, build items list */
+ /* Update EmacsToolbar as in GtkUtils, build items list. */
for (i = 0; i < f->n_tool_bar_items; ++i)
{
#define TOOLPROP(IDX) AREF (f->tool_bar_items, \
image = TOOLPROP (TOOL_BAR_ITEM_IMAGES);
if (VECTORP (image))
{
- /* NS toolbar auto-computes disabled and selected images */
+ /* NS toolbar auto-computes disabled and selected images. */
idx = TOOL_BAR_IMAGE_ENABLED_SELECTED;
eassert (ASIZE (image) >= idx);
image = AREF (image, idx);
#ifdef NS_IMPL_COCOA
if ([toolbar changed])
{
- /* inform app that toolbar has changed */
+ /* Inform app that toolbar has changed. */
NSDictionary *dict = [toolbar configurationDictionary];
NSMutableDictionary *newDict = [dict mutableCopy];
NSEnumerator *keys = [[dict allKeys] objectEnumerator];
}
/* This overrides super's implementation, which automatically sets
- all items to enabled state (for some reason). */
+ all items to enabled state (for some reason). */
- (void)validateVisibleItems
{
NSTRACE ("[EmacsToolbar validateVisibleItems]");
{
NSTRACE ("[EmacsToolbar toolbar: ...]");
- /* look up NSToolbarItem by identifier and return... */
+ /* Look up NSToolbarItem by identifier and return... */
return [identifierToItem objectForKey: itemIdentifier];
}
{
NSTRACE ("[EmacsToolbar toolbarDefaultItemIdentifiers:]");
- /* return entire set.. */
+ /* Return entire set. */
return activeIdentifiers;
}
{
NSTRACE ("[EmacsToolbar toolbarAllowedItemIdentifiers:]");
- /* return entire set... */
+ /* return entire set... */
return activeIdentifiers;
//return [identifierToItem allKeys];
}
========================================================================== */
/* Needed because NeXTstep does not provide enough control over tooltip
- display. */
+ display. */
@implementation EmacsTooltip
- (instancetype)init
NSFont *font = [NSFont toolTipsFontOfSize: 0];
NSFont *sfont = [font screenFont];
int height = [sfont ascender] - [sfont descender];
-/*[font boundingRectForFont].size.height; */
+ /* [font boundingRectForFont].size.height; */
NSRect r = NSMakeRect (0, 0, 100, height+6);
textField = [[NSTextField alloc] initWithFrame: r];
[win setReleasedWhenClosed: NO];
[win setDelegate: self];
[[win contentView] addSubview: textField];
-/* [win setBackgroundColor: col]; */
+ /* [win setBackgroundColor: col]; */
[win setOpaque: NO];
return self;
[self setTitle: @""];
area.origin.x += ICONSIZE+2*SPACER;
-/* area.origin.y = TEXTHEIGHT; ICONSIZE/2-10+SPACER; */
+ /* area.origin.y = TEXTHEIGHT; ICONSIZE/2-10+SPACER; */
area.size.width = 400;
area.size.height= TEXTHEIGHT;
command = [[[NSTextField alloc] initWithFrame: area] autorelease];
[command setSelectable: NO];
[command setFont: [NSFont boldSystemFontOfSize: 13.0]];
-/* area.origin.x = ICONSIZE+2*SPACER;
+ /* area.origin.x = ICONSIZE+2*SPACER;
area.origin.y = TEXTHEIGHT + 2*SPACER;
area.size.width = 400;
area.size.height= 2;
tem = [[[NSBox alloc] initWithFrame: area] autorelease];
[[self contentView] addSubview: tem];
[tem setTitlePosition: NSNoTitle];
- [tem setAutoresizingMask: NSViewWidthSizable];*/
+ [tem setAutoresizingMask: NSViewWidthSizable]; */
-/* area.origin.x = ICONSIZE+2*SPACER; */
+ /* area.origin.x = ICONSIZE+2*SPACER; */
area.origin.y += TEXTHEIGHT+SPACER;
area.size.width = 400;
area.size.height= TEXTHEIGHT;
int i;
NSRect r, s, t;
- if (cols == 1 && rows > 1) /* Never told where to split */
+ if (cols == 1 && rows > 1) /* Never told where to split. */
{
[matrix addColumn];
for (i = 0; i < rows/2; i++)
data2: 0];
timer_fired = YES;
- /* We use sto because stopModal/abortModal out of the main loop does not
- seem to work in 10.6. But as we use stop we must send a real event so
- the stop is seen and acted upon. */
+ /* We use stop because stopModal/abortModal out of the main loop
+ does not seem to work in 10.6. But as we use stop we must send a
+ real event so the stop is seen and acted upon. */
[NSApp stop:self];
[NSApp postEvent: nxev atStart: NO];
}
ret = dialog_return;
if (! timer_fired)
{
- if (tmo != nil) [tmo invalidate]; /* Cancels timer */
+ if (tmo != nil) [tmo invalidate]; /* Cancels timer. */
break;
}
}
DEFUN ("menu-or-popup-active-p", Fmenu_or_popup_active_p, Smenu_or_popup_active_p, 0, 0, 0,
- doc: /* SKIP: real doc in xmenu.c. */)
+ doc: /* SKIP: real doc in xmenu.c. */)
(void)
{
return popup_activated () ? Qt : Qnil;
static Lisp_Object Vselection_alist;
-/* NSPasteboardNameGeneral is pretty much analogous to X11 CLIPBOARD */
+/* NSPasteboardNameGeneral is pretty much analogous to X11 CLIPBOARD. */
static NSString *NXPrimaryPboard;
static NSString *NXSecondaryPboard;
/* CGFloat on GNUstep may be 4 or 8 byte, but functions expect float* for some
versions.
- On Cocoa >= 10.5, functions expect CGFloat *. Make compatible type. */
+ On Cocoa >= 10.5, functions expect CGFloat *. Make compatible type. */
#ifdef NS_IMPL_COCOA
typedef CGFloat EmacsCGFloat;
#elif GNUSTEP_GUI_MAJOR_VERSION > 0 || GNUSTEP_GUI_MINOR_VERSION >= 22
can become misaligned, as all threads (currently) share one state.
This is post prominent when the EVENTS part is enabled.
- Note that the trace system, when enabled, use the GCC/Clang
+ Note that the trace system, when enabled, uses the GCC/Clang
"cleanup" extension. */
/* For example, the following is the output of `M-x
void nstrace_restore_global_trace_state(int *);
char const * nstrace_fullscreen_type_name (int);
-/* printf-style trace output. Output is aligned with contained heading. */
+/* printf-style trace output. Output is aligned with contained heading. */
#define NSTRACE_MSG_NO_DASHES(...) \
do \
{ \
/* Macros for printing complex types.
NSTRACE_FMT_what -- Printf format string for "what".
- NSTRACE_ARG_what(x) -- Printf argument for "what". */
+ NSTRACE_ARG_what(x) -- Printf argument for "what". */
#define NSTRACE_FMT_SIZE "(W:%.0f H:%.0f)"
#define NSTRACE_ARG_SIZE(elt) (elt).width, (elt).height
#define NSTRACE_ARG_FSTYPE(elt) nstrace_fullscreen_type_name(elt)
-/* Macros for printing complex types as extra information. */
+/* Macros for printing complex types as extra information. */
#define NSTRACE_SIZE(str,size) \
NSTRACE_MSG (str ": " NSTRACE_FMT_SIZE, \
NSTRACE_FMT_RETURN - A string literal representing a returned
value. Useful when creating a format string
- to printf-like constructs like NSTRACE(). */
+ to printf-like constructs like NSTRACE(). */
#define NSTRACE_FMT_RETURN "->>"
NSTRACE_WHEN (cond, fmt, ...) -- Enable trace output when COND is true.
NSTRACE_UNLESS (cond, fmt, ...) -- Enable trace output unless COND is
- true. */
+ true. */
/* Unsilence called functions.
Concretely, this us used to allow "event" functions to be silenced
- while trace output can be printed for functions they call. */
+ while trace output can be printed for functions they call. */
#define NSTRACE_UNSILENCE() do { nstrace_enabled_global = 1; } while(0)
#endif /* NSTRACE_ENABLED */
#define NSTRACE(...) NSTRACE_WHEN(1, __VA_ARGS__)
#define NSTRACE_UNLESS(cond, ...) NSTRACE_WHEN(!(cond), __VA_ARGS__)
-/* Non-trace replacement versions. */
+/* Non-trace replacement versions. */
#ifndef NSTRACE_WHEN
#define NSTRACE_WHEN(...)
#endif
#endif
-/* If the compiler doesn't support instancetype, map it to id. */
+/* If the compiler doesn't support instancetype, map it to id. */
#ifndef NATIVE_OBJC_INSTANCETYPE
typedef id instancetype;
#endif
========================================================================== */
-/* We override sendEvent: as a means to stop/start the event loop */
+/* We override sendEvent: as a means to stop/start the event loop. */
@interface EmacsApp : NSApplication
{
#ifdef NS_IMPL_COCOA
#endif
- (int)fullscreenState;
-/* Non-notification versions of NSView methods. Used for direct calls. */
+/* Non-notification versions of NSView methods. Used for direct calls. */
- (void)windowWillEnterFullScreen;
- (void)windowDidEnterFullScreen;
- (void)windowWillExitFullScreen;
@end
-/* Small utility used for processing resize events under Cocoa. */
+/* Small utility used for processing resize events under Cocoa. */
@interface EmacsWindow : NSWindow
{
NSPoint grabOffset;
extern NSString *ns_app_name;
extern EmacsMenu *svcsMenu;
-/* Apple removed the declaration, but kept the implementation */
+/* Apple removed the declaration, but kept the implementation. */
#if defined (NS_IMPL_COCOA)
@interface NSApplication (EmacsApp)
- (void)setAppleMenu: (NSMenu *)menu;
#define KEY_NS_TOGGLE_TOOLBAR ((1<<28)|(0<<16)|13)
#define KEY_NS_SHOW_PREFS ((1<<28)|(0<<16)|14)
-/* could use list to store these, but rest of emacs has a big infrastructure
- for managing a table of bitmap "records" */
+/* Could use list to store these, but rest of emacs has a big infrastructure
+ for managing a table of bitmap "records". */
struct ns_bitmap_record
{
#ifdef __OBJC__
int height, width, depth;
};
-/* this to map between emacs color indices and NSColor objects */
+/* This maps between emacs color indices and NSColor objects. */
struct ns_color_table
{
ptrdiff_t size;
#define BLUE_FROM_ULONG(color) ((color) & 0xff)
/* Do not change `* 0x101' in the following lines to `<< 8'. If
- changed, image masks in 1-bit depth will not work. */
+ changed, image masks in 1-bit depth will not work. */
#define RED16_FROM_ULONG(color) (RED_FROM_ULONG(color) * 0x101)
#define GREEN16_FROM_ULONG(color) (GREEN_FROM_ULONG(color) * 0x101)
#define BLUE16_FROM_ULONG(color) (BLUE_FROM_ULONG(color) * 0x101)
char *name; /* PostScript name, uniquely identifies on NS systems */
- /* The following metrics are stored as float rather than int. */
+ /* The following metrics are stored as float rather than int. */
float width; /* Maximum advance for the font. */
float height;
char bold, ital; /* convenience flags */
char synthItal;
XCharStruct max_bounds;
- /* we compute glyph codes and metrics on-demand in blocks of 256 indexed
- by hibyte, lobyte */
+ /* We compute glyph codes and metrics on-demand in blocks of 256 indexed
+ by hibyte, lobyte. */
unsigned short **glyphs; /* map Unicode index to glyph */
struct font_metrics **metrics;
};
-/* init'd in ns_initialize_display_info () */
+/* Initialized in ns_initialize_display_info (). */
struct ns_display_info
{
/* Chain of all ns_display_info structures. */
struct ns_display_info *next;
- /* The generic display parameters corresponding to this NS display. */
+ /* The generic display parameters corresponding to this NS display. */
struct terminal *terminal;
/* This is a cons cell of the form (NAME . FONT-LIST-CACHE). */
Lisp_Object name_list_element;
- /* The number of fonts loaded. */
+ /* The number of fonts loaded. */
int n_fonts;
/* Minimum width over all characters in all fonts in font_table. */
/* Xism */
XrmDatabase xrdb;
- /* The cursor to use for vertical scroll bars. */
+ /* The cursor to use for vertical scroll bars. */
Cursor vertical_scroll_bar_cursor;
- /* The cursor to use for horizontal scroll bars. */
+ /* The cursor to use for horizontal scroll bars. */
Cursor horizontal_scroll_bar_cursor;
/* Information about the range of text currently shown in
void *toolbar;
#endif
- /* NSCursors init'ed in initFrameFromEmacs */
+ /* NSCursors are initialized in initFrameFromEmacs. */
Cursor text_cursor;
Cursor nontext_cursor;
Cursor modeline_cursor;
scroll bars, in pixels. */
int vertical_scroll_bar_extra;
- /* The height of the titlebar decoration (included in NSWindow's frame). */
+ /* The height of the titlebar decoration (included in NSWindow's frame). */
int titlebar_height;
- /* The height of the toolbar if displayed, else 0. */
+ /* The height of the toolbar if displayed, else 0. */
int toolbar_height;
/* This is the Emacs structure for the NS display this frame is on. */
/* Non-zero if we are zooming (maximizing) the frame. */
int zooming;
- /* Non-zero if we are doing an animation, e.g. toggling the tool bar. */
+ /* Non-zero if we are doing an animation, e.g. toggling the tool bar. */
int in_animation;
};
-/* this dummy decl needed to support TTYs */
+/* This dummy declaration needed to support TTYs. */
struct x_output
{
int unused;
#define XNS_SCROLL_BAR(vec) XSAVE_POINTER (vec, 0)
#endif
-/* Compute pixel height of the frame's titlebar. */
+/* Compute pixel height of the frame's titlebar. */
#define FRAME_NS_TITLEBAR_HEIGHT(f) \
(NSHeight([FRAME_NS_VIEW (f) frame]) == 0 ? \
0 \
[[FRAME_NS_VIEW (f) window] frame] \
styleMask:[[FRAME_NS_VIEW (f) window] styleMask]])))
-/* Compute pixel height of the toolbar. */
+/* Compute pixel height of the toolbar. */
#define FRAME_TOOLBAR_HEIGHT(f) \
(([[FRAME_NS_VIEW (f) window] toolbar] == nil \
|| ! [[FRAME_NS_VIEW (f) window] toolbar].isVisible) ? \
styleMask:[[FRAME_NS_VIEW (f) window] styleMask]]) \
- NSHeight([[[FRAME_NS_VIEW (f) window] contentView] frame])))
-/* Compute pixel size for vertical scroll bars */
+/* Compute pixel size for vertical scroll bars. */
#define NS_SCROLL_BAR_WIDTH(f) \
(FRAME_HAS_VERTICAL_SCROLL_BARS (f) \
? rint (FRAME_CONFIG_SCROLL_BAR_WIDTH (f) > 0 \
: (FRAME_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f))) \
: 0)
-/* Compute pixel size for horizontal scroll bars */
+/* Compute pixel size for horizontal scroll bars. */
#define NS_SCROLL_BAR_HEIGHT(f) \
(FRAME_HAS_HORIZONTAL_SCROLL_BARS (f) \
? rint (FRAME_CONFIG_SCROLL_BAR_HEIGHT (f) > 0 \
: (FRAME_SCROLL_BAR_LINES (f) * FRAME_LINE_HEIGHT (f))) \
: 0)
-/* Difference btwn char-column-calculated and actual SB widths.
- This is only a concern for rendering when SB on left. */
+/* Difference between char-column-calculated and actual SB widths.
+ This is only a concern for rendering when SB on left. */
#define NS_SCROLL_BAR_ADJUST(w, f) \
(WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_LEFT (w) ? \
(FRAME_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f) \
- NS_SCROLL_BAR_WIDTH (f)) : 0)
-/* Difference btwn char-line-calculated and actual SB heights.
- This is only a concern for rendering when SB on top. */
+/* Difference between char-line-calculated and actual SB heights.
+ This is only a concern for rendering when SB on top. */
#define NS_SCROLL_BAR_ADJUST_HORIZONTALLY(w, f) \
(WINDOW_HAS_HORIZONTAL_SCROLL_BARS (w) ? \
(FRAME_SCROLL_BAR_LINES (f) * FRAME_LINE_HEIGHT (f) \
- NS_SCROLL_BAR_HEIGHT (f)) : 0)
/* Calculate system coordinates of the left and top of the parent
- window or, if there is no parent window, the screen. */
+ window or, if there is no parent window, the screen. */
#define NS_PARENT_WINDOW_LEFT_POS(f) \
(FRAME_PARENT_FRAME (f) != NULL \
? [FRAME_NS_VIEW (FRAME_PARENT_FRAME (f)) window].frame.origin.x : 0)
#define WHITE_PIX_DEFAULT(f) 0xFFFFFF
/* First position where characters can be shown (instead of scrollbar, if
- it is on left. */
+ it is on left. */
#define FIRST_CHAR_POSITION(f) \
(! (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f)) ? 0 \
: FRAME_SCROLL_BAR_COLS (f))
struct glyph_string;
void ns_dump_glyphstring (struct glyph_string *s) EXTERNALLY_VISIBLE;
-/* Implemented in nsterm, published in or needed from nsfns. */
+/* Implemented in nsterm, published in or needed from nsfns. */
extern Lisp_Object ns_list_fonts (struct frame *f, Lisp_Object pattern,
int size, int maxnames);
extern void ns_clear_frame (struct frame *f);
#define MINWIDTH 10
#define MINHEIGHT 10
-/* Screen max coordinate
- Using larger coordinates causes movewindow/placewindow to abort */
+/* Screen max coordinate -- using larger coordinates causes
+ movewindow/placewindow to abort. */
#define SCREENMAX 16000
#define NS_SCROLL_BAR_WIDTH_DEFAULT [EmacsScroller scrollerWidth]
#define NS_SCROLL_BAR_HEIGHT_DEFAULT [EmacsScroller scrollerHeight]
-/* This is to match emacs on other platforms, ugly though it is. */
+/* This is to match emacs on other platforms, ugly though it is. */
#define NS_SELECTION_BG_COLOR_DEFAULT @"LightGoldenrod2";
#define NS_SELECTION_FG_COLOR_DEFAULT @"Black";
#define RESIZE_HANDLE_SIZE 12
? (min) : (((x)>(max)) ? (max) : (x)))
#define SCREENMAXBOUND(x) (IN_BOUND (-SCREENMAX, x, SCREENMAX))
-/* macOS 10.7 introduces some new constants. */
+/* macOS 10.7 introduces some new constants. */
#if !defined (NS_IMPL_COCOA) || !defined (MAC_OS_X_VERSION_10_7)
#define NSFullScreenWindowMask (1 << 14)
#define NSWindowCollectionBehaviorFullScreenPrimary (1 << 7)
#define NSAppKitVersionNumber10_7 1138
#endif /* !defined (MAC_OS_X_VERSION_10_7) */
-/* macOS 10.12 deprecates a bunch of constants. */
+/* macOS 10.12 deprecates a bunch of constants. */
#if !defined (NS_IMPL_COCOA) || !defined (MAC_OS_X_VERSION_10_12)
#define NSEventModifierFlagCommand NSCommandKeyMask
#define NSEventModifierFlagControl NSControlKeyMask
#define NSControlSizeRegular NSRegularControlSize
#define NSCompositingOperationCopy NSCompositeCopy
-/* And adds NSWindowStyleMask. */
+/* And adds NSWindowStyleMask. */
#ifdef __OBJC__
typedef NSUInteger NSWindowStyleMask;
#endif
-/* Window tabbing mode enums are new too. */
+/* Window tabbing mode enums are new too. */
enum NSWindowTabbingMode
{
NSWindowTabbingModeAutomatic,
*/
/* This should be the first include, as it may set up #defines affecting
- interpretation of even the system includes. */
+ interpretation of even the system includes. */
#include <config.h>
#include <fcntl.h>
#if NSTRACE_ENABLED
/* The following use "volatile" since they can be accessed from
- parallel threads. */
+ parallel threads. */
volatile int nstrace_num = 0;
volatile int nstrace_depth = 0;
TODO: This should really be a thread-local variable, to avoid that
a function with disabled trace thread silence trace output in
- another. However, in practice this seldom is a problem. */
+ another. However, in practice this seldom is a problem. */
volatile int nstrace_enabled_global = 1;
-/* Called when nstrace_enabled goes out of scope. */
+/* Called when nstrace_enabled goes out of scope. */
void nstrace_leave(int * pointer_to_nstrace_enabled)
{
if (*pointer_to_nstrace_enabled)
}
-/* Called when nstrace_saved_enabled_global goes out of scope. */
+/* Called when nstrace_saved_enabled_global goes out of scope. */
void nstrace_restore_global_trace_state(int * pointer_to_saved_enabled_global)
{
nstrace_enabled_global = *pointer_to_saved_enabled_global;
{
/* FIXMES: We're checking for colorWithSRGBRed here so this will
only work in the same place as in the method above. It should
- really be a check whether we're on macOS 10.7 or above. */
+ really be a check whether we're on macOS 10.7 or above. */
#if defined (NS_IMPL_COCOA) \
&& MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
if (ns_use_srgb_colorspace
/* Convert a symbol indexed with an NSxxx value to a value as defined
in keyboard.c (lispy_function_key). I hope this is a correct way
- of doing things... */
+ of doing things... */
static unsigned convert_ns_to_X_keysym[] =
{
NSHomeFunctionKey, 0x50,
NSF23FunctionKey, 0xD4,
NSF24FunctionKey, 0xD5,
- NSBackspaceCharacter, 0x08, /* 8: Not on some KBs. */
- NSDeleteCharacter, 0xFF, /* 127: Big 'delete' key upper right. */
- NSDeleteFunctionKey, 0x9F, /* 63272: Del forw key off main array. */
+ NSBackspaceCharacter, 0x08, /* 8: Not on some KBs. */
+ NSDeleteCharacter, 0xFF, /* 127: Big 'delete' key upper right. */
+ NSDeleteFunctionKey, 0x9F, /* 63272: Del forw key off main array. */
NSTabCharacter, 0x09,
0x19, 0x09, /* left tab->regular since pass shift */
/* On macOS picks up the default NSGlobalDomain AppleAntiAliasingThreshold,
the maximum font size to NOT antialias. On GNUstep there is currently
- no way to control this behavior. */
+ no way to control this behavior. */
float ns_antialias_threshold;
NSArray *ns_send_types = 0, *ns_return_types = 0;
/* The number of times NSDisableScreenUpdates has been called. */
static int disable_screen_updates_count = 0;
#endif
-/*static int debug_lock = 0; */
+/* static int debug_lock = 0; */
/* event loop */
static BOOL send_appdefined = YES;
(([e type] == NSEventTypeRightMouseDown) || ([e type] == NSEventTypeRightMouseUp)) ? 2 : \
[e buttonNumber] - 1)
-/* Convert the time field to a timestamp in milliseconds. */
+/* Convert the time field to a timestamp in milliseconds. */
#define EV_TIMESTAMP(e) ([e timestamp] * 1000)
/* This is a piece of code which is common to all the event handling
/* These flags will be OR'd or XOR'd with the NSWindow's styleMask
- property depending on what we're doing. */
+ property depending on what we're doing. */
#define FRAME_DECORATED_FLAGS (NSWindowStyleMaskTitled \
| NSWindowStyleMaskResizable \
| NSWindowStyleMaskMiniaturizable \
| NSWindowStyleMaskClosable)
#define FRAME_UNDECORATED_FLAGS NSWindowStyleMaskBorderless
-/* TODO: get rid of need for these forward declarations */
+/* TODO: Get rid of need for these forward declarations. */
static void ns_condemn_scroll_bars (struct frame *f);
static void ns_judge_scroll_bars (struct frame *f);
void
ns_init_locale (void)
/* macOS doesn't set any environment variables for the locale when run
- from the GUI. Get the locale from the OS and set LANG. */
+ from the GUI. Get the locale from the OS and set LANG. */
{
NSLocale *locale = [NSLocale currentLocale];
/* It seems macOS should probably use UTF-8 everywhere.
'localeIdentifier' does not specify the encoding, and I can't
find any way to get the OS to tell us which encoding to use,
- so hard-code '.UTF-8'. */
+ so hard-code '.UTF-8'. */
NSString *localeID = [NSString stringWithFormat:@"%@.UTF-8",
[locale localeIdentifier]];
- /* Set LANG to locale, but not if LANG is already set. */
+ /* Set LANG to locale, but not if LANG is already set. */
setenv("LANG", [localeID UTF8String], 0);
}
@catch (NSException *e)
void
ns_retain_object (void *obj)
/* --------------------------------------------------------------------------
- Retain an object (callable from C)
+ Retain an object (callable from C)
-------------------------------------------------------------------------- */
{
[(id)obj retain];
static struct EmacsMargins
ns_screen_margins_ignoring_hidden_dock (NSScreen *screen)
/* The parts of SCREEN used by the operating system, excluding the parts
-reserved for an hidden dock. */
+ reserved for a hidden dock. */
{
NSTRACE ("ns_screen_margins_ignoring_hidden_dock");
{
[focus_view unlockFocus];
[[focus_view window] flushWindow];
-/*debug_lock--; */
+/* debug_lock--; */
}
if (view)
[view lockFocus];
focus_view = view;
-/*if (view) debug_lock++; */
+/* if (view) debug_lock++; */
}
}
[focus_view unlockFocus];
[[focus_view window] flushWindow];
focus_view = NULL;
-/*debug_lock--; */
+/* debug_lock--; */
}
}
}
@interface EmacsBell : NSImageView
{
- // Number of currently active bell:s.
+ // Number of currently active bells.
unsigned int nestCount;
NSView * mView;
bool isAttached;
NSTRACE ("x_make_frame_visible");
/* XXX: at some points in past this was not needed, as the only place that
called this (frame.c:Fraise_frame ()) also called raise_lower;
- if this ends up the case again, comment this out again. */
+ if this ends up the case again, comment this out again. */
if (!FRAME_VISIBLE_P (f))
{
EmacsView *view = (EmacsView *)FRAME_NS_VIEW (f);
}
/* Making a frame invisible seems to break the parent->child
- relationship, so reinstate it. */
+ relationship, so reinstate it. */
if ([window parentWindow] == nil && FRAME_PARENT_FRAME (f) != NULL)
{
NSWindow *parent = [FRAME_NS_VIEW (FRAME_PARENT_FRAME (f)) window];
/* If the parent frame moved while the child frame was
invisible, the child frame's position won't have been
- updated. Make sure it's in the right place now. */
+ updated. Make sure it's in the right place now. */
x_set_offset(f, f->left_pos, f->top_pos, 0);
}
}
if ([[view window] windowNumber] <= 0)
{
- /* the window is still deferred. Make it very small, bring it
- on screen and order it out. */
+ /* The window is still deferred. Make it very small, bring it
+ on screen and order it out. */
NSRect s = { { 100, 100}, {0, 0} };
NSRect t;
t = [[view window] frame];
}
/* Processing input while Emacs is being minimized can cause a
- crash, so block it for the duration. */
+ crash, so block it for the duration. */
block_input();
[[view window] miniaturize: NSApp];
unblock_input();
NSTRACE ("x_destroy_window");
/* If this frame has a parent window, detach it as not doing so can
- cause a crash in GNUStep. */
+ cause a crash in GNUStep. */
if (FRAME_PARENT_FRAME (f) != NULL)
{
NSWindow *child = [FRAME_NS_VIEW (f) window];
else
{
[window setToolbar: nil];
- /* Do I need to release the toolbar here? */
+ /* Do I need to release the toolbar here? */
FRAME_UNDECORATED (f) = true;
[window setStyleMask: ((window.styleMask | FRAME_UNDECORATED_FLAGS)
}
/* At this point it seems we don't have an active NSResponder,
- so some key presses (TAB) are swallowed by the system. */
+ so some key presses (TAB) are swallowed by the system. */
[window makeFirstResponder: view];
[view updateFrameSize: NO];
* displayed for the first time and when the frame changes its state
* from `iconified' or `invisible' to `visible'.)
*
- * Some window managers may not honor this parameter. */
+ * Some window managers may not honor this parameter. */
{
NSTRACE ("x_set_no_focus_on_map");
* If non-nil, this may have the unwanted side-effect that a user cannot
* scroll a non-selected frame with the mouse.
*
- * Some window managers may not honor this parameter. */
+ * Some window managers may not honor this parameter. */
{
NSTRACE ("x_set_no_accept_focus");
`below' property set. If `below', F's window is displayed below
all windows that do.
- Some window managers may not honor this parameter. */
+ Some window managers may not honor this parameter. */
{
EmacsView *view = (EmacsView *)FRAME_NS_VIEW (f);
NSWindow *window = [view window];
}
else if (EQ (new_value, Qabove_suspended))
{
- /* Not sure what level this should be. */
+ /* Not sure what level this should be. */
window.level = NSNormalWindowLevel + 1;
FRAME_Z_GROUP (f) = z_group_above_suspended;
}
if (! [view fsIsNative] && f->want_fullscreen == FULLSCREEN_BOTH)
{
/* Old style fs don't initiate correctly if created from
- init/default-frame alist, so use a timer (not nice...).
- */
+ init/default-frame alist, so use a timer (not nice...). */
[NSTimer scheduledTimerWithTimeInterval: 0.5 target: view
selector: @selector (handleFS)
userInfo: nil repeats: NO];
color_table->colors[idx] = color;
[color retain];
-/*fprintf(stderr, "color_table: allocated %d\n",idx);*/
+ /* fprintf(stderr, "color_table: allocated %d\n",idx); */
return idx;
}
-------------------------------------------------------------------------- */
/* On *Step, we attempt to mimic the X11 platform here, down to installing an
X11 rgb.txt-compatible color list in Emacs.clr (see ns_term_init()).
- See: http://thread.gmane.org/gmane.emacs.devel/113050/focus=113272). */
+ See https://lists.gnu.org/r/emacs-devel/2009-07/msg01203.html. */
{
NSColor *new = nil;
static char hex[20];
else if ([nsname isEqualToString: @"ns_selection_fg_color"])
{
/* NOTE: macOS applications normally don't set foreground
- selection, but text may be unreadable if we don't.
- */
+ selection, but text may be unreadable if we don't. */
if ((new = [NSColor selectedTextColor]) != nil)
{
*col = [new colorUsingDefaultColorSpace];
name = [nsname UTF8String];
}
- /* First, check for some sort of numeric specification. */
+ /* First, check for some sort of numeric specification. */
hex[0] = '\0';
if (name[0] == '0' || name[0] == '1' || name[0] == '.') /* RGB decimal */
NSColorList *clist;
#ifdef NS_IMPL_GNUSTEP
- /* XXX: who is wrong, the requestor or the implementation? */
+ /* XXX: who is wrong, the requestor or the implementation? */
if ([nsname compare: @"Highlight" options: NSCaseInsensitiveSearch]
== NSOrderedSame)
nsname = @"highlightColor";
int
ns_lisp_to_color (Lisp_Object color, NSColor **col)
/* --------------------------------------------------------------------------
- Convert a Lisp string object to a NS color
+ Convert a Lisp string object to a NS color.
-------------------------------------------------------------------------- */
{
NSTRACE ("ns_lisp_to_color");
If makeIndex and alloc are nonzero put the color in the color_table,
and set color_def pixel to the resulting index.
If makeIndex is zero, set color_def pixel to ARGB.
- Return false if not found
+ Return false if not found.
-------------------------------------------------------------------------- */
{
NSColor *col;
{
NSTRACE ("frame_set_mouse_pixel_position");
- /* FIXME: what about GNUstep? */
+ /* FIXME: what about GNUstep? */
#ifdef NS_IMPL_COCOA
CGPoint mouse_pos =
CGPointMake(f->left_pos + pix_x,
struct ns_display_info *dpyinfo = FRAME_DISPLAY_INFO (frame);
NSRect *r;
-// NSTRACE ("note_mouse_movement");
+ // NSTRACE ("note_mouse_movement");
dpyinfo->last_mouse_motion_frame = frame;
r = &dpyinfo->last_mouse_glyph;
/* Note, this doesn't get called for enter/leave, since we don't have a
- position. Those are taken care of in the corresponding NSView methods. */
+ position. Those are taken care of in the corresponding NSView methods. */
- /* has movement gone beyond last rect we were tracking? */
+ /* Has movement gone beyond last rect we were tracking? */
if (x < r->origin.x || x >= r->origin.x + r->size.width
|| y < r->origin.y || y >= r->origin.y + r->size.height)
{
External (hook): inform emacs about mouse position and hit parts.
If a scrollbar is being dragged, set bar_window, part, x, y, time.
x & y should be position in the scrollbar (the whole bar, not the handle)
- and length of scrollbar respectively
+ and length of scrollbar respectively.
-------------------------------------------------------------------------- */
{
id view;
{
const unsigned last_keysym = ARRAYELTS (convert_ns_to_X_keysym);
unsigned keysym;
- /* An array would be faster, but less easy to read. */
+ /* An array would be faster, but less easy to read. */
for (keysym = 0; keysym < last_keysym; keysym += 2)
if (code == convert_ns_to_X_keysym[keysym])
return 0xFF00 | convert_ns_to_X_keysym[keysym+1];
static void
ns_scroll_run (struct window *w, struct run *run)
/* --------------------------------------------------------------------------
- External (RIF): Insert or delete n lines at line vpos
+ External (RIF): Insert or delete n lines at line vpos.
-------------------------------------------------------------------------- */
{
struct frame *f = XFRAME (w->frame);
NSRectClip (r);
/* Since we composite the bitmap instead of just blitting it, we need
- to erase the whole background. */
+ to erase the whole background. */
[ns_lookup_indexed_color(face->background, f) set];
NSRectFill (r);
get_phys_cursor_geometry (w, glyph_row, phys_cursor_glyph, &fx, &fy, &h);
/* The above get_phys_cursor_geometry call set w->phys_cursor_width
- to the glyph width; replace with CURSOR_WIDTH for (V)BAR cursors. */
+ to the glyph width; replace with CURSOR_WIDTH for (V)BAR cursors. */
if (cursor_type == BAR_CURSOR)
{
if (cursor_width < 1)
cursor_width = max (FRAME_CURSOR_WIDTH (f), 1);
- /* The bar cursor should never be wider than the glyph. */
+ /* The bar cursor should never be wider than the glyph. */
if (cursor_width < w->phys_cursor_width)
w->phys_cursor_width = cursor_width;
}
- /* If we have an HBAR, "cursor_width" MAY specify height. */
+ /* If we have an HBAR, "cursor_width" MAY specify height. */
else if (cursor_type == HBAR_CURSOR)
{
cursor_height = (cursor_width < 1) ? lrint (0.25 * h) : cursor_width;
r.size.height = h;
r.size.width = w->phys_cursor_width;
- /* Prevent the cursor from being drawn outside the text area. */
+ /* Prevent the cursor from being drawn outside the text area. */
ns_clip_to_row (w, glyph_row, TEXT_AREA, NO); /* do ns_focus(f, &r, 1); if remove */
/* TODO: This makes drawing of cursor plus that of phys_cursor_glyph
atomic. Cleaner ways of doing this should be investigated.
One way would be to set a global variable DRAWING_CURSOR
- when making the call to draw_phys..(), don't focus in that
- case, then move the ns_unfocus() here after that call. */
+ when making the call to draw_phys..(), don't focus in that
+ case, then move the ns_unfocus() here after that call. */
NSDisableScreenUpdates ();
#endif
if (s->for_overlaps)
return;
- /* Do underline. */
+ /* Do underline. */
if (face->underline_p)
{
if (s->face->underline_type == FACE_UNDER_WAVE)
NSRect r;
unsigned long thickness, position;
- /* If the prev was underlined, match its appearance. */
+ /* If the prev was underlined, match its appearance. */
if (s->prev && s->prev->face->underline_p
&& s->prev->face->underline_type == FACE_UNDER_LINE
&& s->prev->underline_thickness > 0)
use_underline_position_properties =
!(NILP (val) || EQ (val, Qunbound));
- /* Use underline thickness of font, defaulting to 1. */
+ /* Use underline thickness of font, defaulting to 1. */
thickness = (font && font->underline_thickness > 0)
? font->underline_thickness : 1;
- /* Determine the offset of underlining from the baseline. */
+ /* Determine the offset of underlining from the baseline. */
if (underline_at_descent_line)
position = descent - thickness;
else if (use_underline_position_properties
position = max (position, minimum_offset);
- /* Ensure underlining is not cropped. */
+ /* Ensure underlining is not cropped. */
if (descent <= position)
{
position = descent - 1;
}
}
/* Do overline. We follow other terms in using a thickness of 1
- and ignoring overline_margin. */
+ and ignoring overline_margin. */
if (face->overline_p)
{
NSRect r;
}
/* Do strike-through. We follow other terms for thickness and
- vertical position.*/
+ vertical position. */
if (face->strike_through_p)
{
NSRect r;
[(raised_p ? lightCol : darkCol) set];
- /* TODO: mitering. Using NSBezierPath doesn't work because of color switch. */
+ /* TODO: mitering. Using NSBezierPath doesn't work because of color switch. */
/* top */
sr.size.height = thickness;
r = NSMakeRect (s->x, s->y, right_x - s->x + 1, s->height);
- /* TODO: Sometimes box_color is 0 and this seems wrong; should investigate. */
+ /* TODO: Sometimes box_color is 0 and this seems wrong; should investigate. */
if (s->face->box == FACE_SIMPLE_BOX && s->face->box_color)
{
ns_draw_box (r, abs (thickness),
/* Draw BG: if we need larger area than image itself cleared, do that,
otherwise, since we composite the image under NS (instead of mucking
- with its background color), we must clear just the image area. */
+ with its background color), we must clear just the image area. */
if (s->hl == DRAW_MOUSE_FACE)
{
face = FACE_FROM_ID_OR_NULL (s->f,
NSRectFill (br);
- /* Draw the image.. do we need to draw placeholder if img ==nil? */
+ /* Draw the image... do we need to draw placeholder if img == nil? */
if (img != nil)
{
#ifdef NS_IMPL_COCOA
if (s->w->phys_cursor_type == FILLED_BOX_CURSOR)
tdCol = ns_lookup_indexed_color (NS_FACE_BACKGROUND (face), s->f);
else
- /* Currently on NS img->mask is always 0. Since
+ /* Currently on NS img->mask is always 0. Since
get_window_cursor_type specifies a hollow box cursor when on
- a non-masked image we never reach this clause. But we put it
+ a non-masked image we never reach this clause. But we put it
in, in anticipation of better support for image masks on
- NS. */
+ NS. */
tdCol = ns_lookup_indexed_color (NS_FACE_FOREGROUND (face), s->f);
}
else
tdCol = ns_lookup_indexed_color (NS_FACE_FOREGROUND (face), s->f);
}
- /* Draw underline, overline, strike-through. */
+ /* Draw underline, overline, strike-through. */
ns_draw_text_decoration (s, face, tdCol, br.size.width, br.origin.x);
/* Draw relief, if requested */
a partially-visible bottom row will clear part of the
modeline, and another where list-buffers headers and similar
rows erroneously have visible_height set to 0. Not sure
- where this is coming from as other terms seem not to show. */
+ where this is coming from as other terms seem not to show. */
r[i].size.height = min (s->height, s->row->visible_height);
}
[bgCol set];
/* NOTE: under NS this is NOT used to draw cursors, but we must avoid
- overwriting cursor (usually when cursor on a tab) */
+ overwriting cursor (usually when cursor on a tab). */
if (s->hl == DRAW_CURSOR)
{
CGFloat x, width;
NSRectFill (r[i]);
- /* Draw overlining, etc. on the cursor. */
+ /* Draw overlining, etc. on the cursor. */
if (s->w->phys_cursor_type == FILLED_BOX_CURSOR)
ns_draw_text_decoration (s, face, bgCol, width, x);
else
}
/* Draw overlining, etc. on the stretch glyph (or the part
- of the stretch glyph after the cursor). */
+ of the stretch glyph after the cursor). */
ns_draw_text_decoration (s, face, fgCol, r[i].size.width,
r[i].origin.x);
}
: FRAME_FOREGROUND_COLOR (s->f));
[col set];
- /* Draw underline, overline, strike-through. */
+ /* Draw underline, overline, strike-through. */
ns_draw_text_decoration (s, s->face, col, s->width, s->x);
}
emacs_abort ();
}
- /* Draw box if not done already. */
+ /* Draw box if not done already. */
if (!s->for_overlaps && !box_drawn_p && s->face->box != FACE_NO_BOX)
{
n = ns_get_glyph_string_clip_rect (s, r);
}
/* Only post this event if we haven't already posted one. This will end
- the [NXApp run] main loop after having processed all events queued at
- this moment. */
+ the [NXApp run] main loop after having processed all events queued at
+ this moment. */
#ifdef NS_IMPL_COCOA
if (! send_appdefined)
/* We only need one NX_APPDEFINED event to stop NXApp from running. */
send_appdefined = NO;
- /* Don't need wakeup timer any more */
+ /* Don't need wakeup timer any more. */
if (timed_entry)
{
[timed_entry invalidate];
void
ns_check_menu_open (NSMenu *menu)
{
- /* Click in menu bar? */
+ /* Click in menu bar? */
NSArray *a = [[NSApp mainMenu] itemArray];
int i;
BOOL found = NO;
ns_init_events (&ev);
q_event_ptr = hold_quit;
- /* we manage autorelease pools by allocate/reallocate each time around
+ /* We manage autorelease pools by allocate/reallocate each time around
the loop; strict nesting is occasionally violated but seems not to
- matter.. earlier methods using full nesting caused major memory leaks */
+ matter... earlier methods using full nesting caused major memory leaks. */
[outerpool release];
outerpool = [[NSAutoreleasePool alloc] init];
- /* If have pending open-file requests, attend to the next one of those. */
+ /* If have pending open-file requests, attend to the next one of those. */
if (ns_pending_files && [ns_pending_files count] != 0
&& [(EmacsApp *)NSApp openFile: [ns_pending_files objectAtIndex: 0]])
{
[ns_pending_files removeObjectAtIndex: 0];
}
- /* Deal with pending service requests. */
+ /* Deal with pending service requests. */
else if (ns_pending_service_names && [ns_pending_service_names count] != 0
&& [(EmacsApp *)
NSApp fulfillService: [ns_pending_service_names objectAtIndex: 0]
if (hold_event_q.nr > 0)
{
- /* We already have events pending. */
+ /* We already have events pending. */
raise (SIGIO);
errno = EINTR;
return -1;
pthread_mutex_unlock (&select_mutex);
- /* Inform fd_handler that select should be called */
+ /* Inform fd_handler that select should be called. */
c = 'g';
emacs_write_sig (selfds[1], &c, 1);
}
else if (nr == 0 && timeout)
{
- /* No file descriptor, just a timeout, no need to wake fd_handler */
+ /* No file descriptor, just a timeout, no need to wake fd_handler. */
double time = timespectod (*timeout);
timed_entry = [[NSTimer scheduledTimerWithTimeInterval: time
target: NSApp
}
else /* No timeout and no file descriptors, can this happen? */
{
- /* Send appdefined so we exit from the loop */
+ /* Send appdefined so we exit from the loop. */
ns_send_appdefined (-1);
}
if (t == -2)
{
- /* The NX_APPDEFINED event we received was a timeout. */
+ /* The NX_APPDEFINED event we received was a timeout. */
result = 0;
}
else if (t == -1)
}
else
{
- /* Received back from select () in fd_handler; copy the results */
+ /* Received back from select () in fd_handler; copy the results. */
pthread_mutex_lock (&select_mutex);
if (readfds) *readfds = select_readfds;
if (writefds) *writefds = select_writefds;
#ifdef HAVE_PTHREAD
void
ns_run_loop_break ()
-/* Break out of the NS run loop in ns_select or ns_read_socket. */
+/* Break out of the NS run loop in ns_select or ns_read_socket. */
{
NSTRACE_WHEN (NSTRACE_GROUP_EVENTS, "ns_run_loop_break");
- /* If we don't have a GUI, don't send the event. */
+ /* If we don't have a GUI, don't send the event. */
if (NSApp != NULL)
ns_send_appdefined(-1);
}
int top, left, height, width;
BOOL update_p = YES;
- /* optimization; display engine sends WAY too many of these.. */
+ /* Optimization; display engine sends WAY too many of these. */
if (!NILP (window->vertical_scroll_bar))
{
bar = XNS_SCROLL_BAR (window->vertical_scroll_bar);
left = WINDOW_SCROLL_BAR_AREA_X (window);
r = NSMakeRect (left, top, width, height);
- /* the parent view is flipped, so we need to flip y value */
+ /* The parent view is flipped, so we need to flip y value. */
v = [view frame];
r.origin.y = (v.size.height - r.size.height - r.origin.y);
XSETWINDOW (win, window);
block_input ();
- /* we want at least 5 lines to display a scrollbar */
+ /* We want at least 5 lines to display a scrollbar. */
if (WINDOW_TOTAL_LINES (window) < 5)
{
if (!NILP (window->vertical_scroll_bar))
ns_set_horizontal_scroll_bar (struct window *window,
int portion, int whole, int position)
/* --------------------------------------------------------------------------
- External (hook): Update or add scrollbar
+ External (hook): Update or add scrollbar.
-------------------------------------------------------------------------- */
{
Lisp_Object win;
int window_x, window_width;
BOOL update_p = YES;
- /* optimization; display engine sends WAY too many of these.. */
+ /* Optimization; display engine sends WAY too many of these. */
if (!NILP (window->horizontal_scroll_bar))
{
bar = XNS_SCROLL_BAR (window->horizontal_scroll_bar);
top = WINDOW_SCROLL_BAR_AREA_Y (window);
r = NSMakeRect (left, top, width, height);
- /* the parent view is flipped, so we need to flip y value */
+ /* The parent view is flipped, so we need to flip y value. */
v = [view frame];
r.origin.y = (v.size.height - r.size.height - r.origin.y);
/* If there are both horizontal and vertical scroll-bars they leave
a square that belongs to neither. We need to clear it otherwise
- it fills with junk. */
+ it fills with junk. */
if (!NILP (window->vertical_scroll_bar))
ns_clear_frame_area (f, WINDOW_SCROLL_BAR_AREA_X (window), top,
NS_SCROLL_BAR_HEIGHT (f), height);
static Lisp_Object ns_string_to_lispmod (const char *s)
/* --------------------------------------------------------------------------
- Convert modifier name to lisp symbol
+ Convert modifier name to lisp symbol.
-------------------------------------------------------------------------- */
{
if (!strncmp (SSDATA (SYMBOL_NAME (Qmeta)), s, 10))
Lisp_Object yesval, Lisp_Object noval,
BOOL is_float, BOOL is_modstring)
/* --------------------------------------------------------------------------
- Check a parameter value in user's preferences
+ Check a parameter value in user's preferences.
-------------------------------------------------------------------------- */
{
const char *value = ns_get_defaults_value (parameter);
dpyinfo->n_planes = NSBitsPerPixelFromDepth (depth);
dpyinfo->color_table = xmalloc (sizeof *dpyinfo->color_table);
dpyinfo->color_table->colors = NULL;
- dpyinfo->root_window = 42; /* a placeholder.. */
+ dpyinfo->root_window = 42; /* A placeholder. */
dpyinfo->x_highlight_frame = dpyinfo->x_focus_frame = NULL;
dpyinfo->n_fonts = 0;
dpyinfo->smallest_font_height = 1;
}
-/* This and next define (many of the) public functions in this file. */
+/* This and next define (many of the) public functions in this file. */
/* x_... are generic versions in xdisp.c that we, and other terms, get away
with using despite presence in the "system dependent" redisplay
interface. In addition, many of the ns_ methods have code that is
- shared with all terms, indicating need for further refactoring. */
+ shared with all terms, indicating need for further refactoring. */
extern frame_parm_handler ns_frame_parm_handlers[];
static struct redisplay_interface ns_redisplay_interface =
{
static void
ns_delete_display (struct ns_display_info *dpyinfo)
{
- /* TODO... */
+ /* TODO... */
}
-/* This function is called when the last frame on a display is deleted. */
+/* This function is called when the last frame on a display is deleted. */
static void
ns_delete_terminal (struct terminal *terminal)
{
ns_pending_service_names = [[NSMutableArray alloc] init];
ns_pending_service_args = [[NSMutableArray alloc] init];
-/* Start app and create the main menu, window, view.
+ /* Start app and create the main menu, window, view.
Needs to be here because ns_initialize_display_info () uses AppKit classes.
- The view will then ask the NSApp to stop and return to Emacs. */
+ The view will then ask the NSApp to stop and return to Emacs. */
[EmacsApp sharedApplication];
if (NSApp == nil)
return NULL;
#ifdef NS_IMPL_GNUSTEP
Vwindow_system_version = build_string (gnustep_base_version);
#else
- /*PSnextrelease (128, c); */
+ /* PSnextrelease (128, c); */
char c[DBL_BUFSIZE_BOUND];
int len = dtoastr (c, sizeof c, 0, 0, NSAppKitVersionNumber);
Vwindow_system_version = make_unibyte_string (c, len);
#endif /* macOS menu setup */
/* Register our external input/output types, used for determining
- applicable services and also drag/drop eligibility. */
+ applicable services and also drag/drop eligibility. */
NSTRACE_MSG ("Input/output types");
NSString *fstr = represented_filename;
NSView *view = FRAME_NS_VIEW (represented_frame);
#ifdef NS_IMPL_COCOA
- /* work around a bug observed on 10.3 and later where
+ /* Work around a bug observed on 10.3 and later where
setTitleWithRepresentedFilename does not clear out previous state
- if given filename does not exist */
+ if given filename does not exist. */
if (! [[NSFileManager defaultManager] fileExistsAtPath: fstr])
[[view window] setRepresentedFilename: @""];
#endif
/* Events posted by ns_send_appdefined interrupt the run loop here.
But, if a modal window is up, an appdefined can still come through,
(e.g., from a makeKeyWindow event) but stopping self also stops the
- modal loop. Just defer it until later. */
+ modal loop. Just defer it until later. */
if ([NSApp modalWindow] == nil)
{
last_appdefined_event_data = [theEvent data1];
}
-/* Open a file (used by below, after going into queue read by ns_read_socket) */
+/* Open a file (used by below, after going into queue read by ns_read_socket). */
- (BOOL) openFile: (NSString *)fileName
{
NSTRACE ("[EmacsApp openFile:]");
- (void)applicationDidFinishLaunching: (NSNotification *)notification
/* --------------------------------------------------------------------------
- When application is loaded, terminate event loop in ns_term_init
+ When application is loaded, terminate event loop in ns_term_init.
-------------------------------------------------------------------------- */
{
NSTRACE ("[EmacsApp applicationDidFinishLaunching:]");
if ([NSApp activationPolicy] == NSApplicationActivationPolicyProhibited) {
/* Set the app's activation policy to regular when we run outside
of a bundle. This is already done for us by Info.plist when we
- run inside a bundle. */
+ run inside a bundle. */
[NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
[NSApp setApplicationIconImage:
[EmacsImage
return 1;
}
-/* Notification from the Workspace to open a file */
+/* Notification from the Workspace to open a file. */
- (BOOL)application: sender openFile: (NSString *)file
{
if (ns_do_open_file || not_in_argv (file))
}
-/* Open a file as a temporary file */
+/* Open a file as a temporary file. */
- (BOOL)application: sender openTempFile: (NSString *)file
{
if (ns_do_open_file || not_in_argv (file))
}
-/* Notification from the Workspace to open a file noninteractively (?) */
+/* Notification from the Workspace to open a file noninteractively (?). */
- (BOOL)application: sender openFileWithoutUI: (NSString *)file
{
if (ns_do_open_file || not_in_argv (file))
return YES;
}
-/* Notification from the Workspace to open multiple files */
+/* Notification from the Workspace to open multiple files. */
- (void)application: sender openFiles: (NSArray *)fileList
{
NSEnumerator *files = [fileList objectEnumerator];
}
-/* TODO: these may help w/IO switching btwn terminal and NSApp */
+/* TODO: these may help w/IO switching between terminal and NSApp. */
- (void)applicationWillBecomeActive: (NSNotification *)notification
{
NSTRACE ("[EmacsApp applicationWillBecomeActive:]");
- //ns_app_active=YES;
+ // ns_app_active=YES;
}
- (void)applicationDidBecomeActive: (NSNotification *)notification
if (! applicationDidFinishLaunchingCalled)
[self applicationDidFinishLaunching:notification];
#endif
- //ns_app_active=YES;
+ // ns_app_active=YES;
ns_update_auto_hide_menu_bar ();
// No constraining takes place when the application is not active.
{
NSTRACE ("[EmacsApp applicationDidResignActive:]");
- //ns_app_active=NO;
+ // ns_app_active=NO;
ns_send_appdefined (-1);
}
The timeout specified to ns_select has passed.
-------------------------------------------------------------------------- */
{
- /*NSTRACE ("timeout_handler"); */
+ /* NSTRACE ("timeout_handler"); */
ns_send_appdefined (-2);
}
- (void)fd_handler:(id)unused
/* --------------------------------------------------------------------------
- Check data waiting on file descriptors and terminate if so
+ Check data waiting on file descriptors and terminate if so.
-------------------------------------------------------------------------- */
{
int result;
========================================================================== */
-/* called from system: queue for next pass through event loop */
+/* Called from system: queue for next pass through event loop. */
- (void)requestService: (NSPasteboard *)pboard
userData: (NSString *)userData
error: (NSString **)error
}
-/* called from ns_read_socket to clear queue */
+/* Called from ns_read_socket to clear queue. */
- (BOOL)fulfillService: (NSString *)name withArg: (NSString *)arg
{
struct frame *emacsframe = SELECTED_FRAME ();
@implementation EmacsView
-/* needed to inform when window closed from LISP */
+/* Needed to inform when window closed from lisp. */
- (void) setWindowClosing: (BOOL)closing
{
NSTRACE ("[EmacsView setWindowClosing:%d]", closing);
}
-/* called on font panel selection */
+/* Called on font panel selection. */
- (void)changeFont: (id)sender
{
NSEvent *e = [[self window] currentEvent];
/*****************************************************************************/
-/* Keyboard handling. */
+/* Keyboard handling. */
#define NS_KEYLOG 0
- (void)keyDown: (NSEvent *)theEvent
NSTRACE ("[EmacsView keyDown:]");
- /* Rhapsody and macOS give up and down events for the arrow keys */
+ /* Rhapsody and macOS give up and down events for the arrow keys. */
if (ns_fake_keydown == YES)
ns_fake_keydown = NO;
else if ([theEvent type] != NSEventTypeKeyDown)
if (![[self window] isKeyWindow]
&& [[theEvent window] isKindOfClass: [EmacsWindow class]]
- /* we must avoid an infinite loop here. */
+ /* We must avoid an infinite loop here. */
&& (EmacsView *)[[theEvent window] delegate] != self)
{
/* XXX: There is an occasional condition in which, when Emacs display
selects it, then processes some interrupt-driven input
(dispnew.c:3878), OS will send the event to the correct NSWindow, but
for some reason that window has its first responder set to the NSView
- most recently updated (I guess), which is not the correct one. */
+ most recently updated (I guess), which is not the correct one. */
[(EmacsView *)[[theEvent window] delegate] keyDown: theEvent];
return;
}
code = ([[theEvent charactersIgnoringModifiers] length] == 0) ?
0 : [[theEvent charactersIgnoringModifiers] characterAtIndex: 0];
- /* is it a "function key"? */
+ /* Is it a "function key"? */
/* Note: Sometimes a plain key will have the NSEventModifierFlagNumericPad
- flag set (this is probably a bug in the OS).
- */
+ flag set (this is probably a bug in the OS). */
if (code < 0x00ff && (flags&NSEventModifierFlagNumericPad))
{
fnKeysym = ns_convert_key ([theEvent keyCode] | NSEventModifierFlagNumericPad);
if (fnKeysym)
{
/* COUNTERHACK: map 'Delete' on upper-right main KB to 'Backspace',
- because Emacs treats Delete and KP-Delete same (in simple.el). */
+ because Emacs treats Delete and KP-Delete same (in simple.el). */
if ((fnKeysym == 0xFFFF && [theEvent keyCode] == 0x33)
#ifdef NS_IMPL_GNUSTEP
/* GNUstep uses incompatible keycodes, even for those that are
supposed to be hardware independent. Just check for delete.
Keypad delete does not have keysym 0xFFFF.
- See https://savannah.gnu.org/bugs/?25395
- */
+ See https://savannah.gnu.org/bugs/?25395 */
|| (fnKeysym == 0xFFFF && code == 127)
#endif
)
hasn't. Also some combinations of fn and a function key
return a different key than was pressed (e.g. fn-<left> gives
<home>). We need to unset the fn modifier in these cases.
- FIXME: Can we avoid setting it in the first place. */
+ FIXME: Can we avoid setting it in the first place? */
if (fnKeysym && (flags & NS_FUNCTION_KEY_MASK))
emacs_event->modifiers ^= parse_solitary_modifier (ns_function_modifier);
}
-/* <NSTextInput> implementation (called through super interpretKeyEvents:]). */
+/* <NSTextInput> implementation (called through [super interpretKeyEvents:]). */
/* <NSTextInput>: called when done composing;
- NOTE: also called when we delete over working text, followed immed.
- by doCommandBySelector: deleteBackward: */
+ NOTE: also called when we delete over working text, followed
+ immediately by doCommandBySelector: deleteBackward: */
- (void)insertText: (id)aString
{
NSString *s;
if (!emacs_event)
return;
- /* first, clear any working text */
+ /* First, clear any working text. */
if (workingText != nil)
[self deleteWorkingText];
However, we probably can't use SAFE_NALLOCA here because it might
exit nonlocally. */
- /* now insert the string as keystrokes */
+ /* Now insert the string as keystrokes. */
for (NSUInteger i = 0; i < len; i++)
{
NSUInteger code = [s characterAtIndex:i];
++i;
}
}
- /* TODO: still need this? */
+ /* TODO: still need this? */
if (code == 0x2DC)
code = '~'; /* 0x7E */
if (code != 32) /* Space */
}
-/* <NSTextInput>: inserts display of composing characters */
+/* <NSTextInput>: inserts display of composing characters. */
- (void)setMarkedText: (id)aString selectedRange: (NSRange)selRange
{
NSString *str = [aString respondsToSelector: @selector (string)] ?
}
-/* delete display of composing characters [not in <NSTextInput>] */
+/* Delete display of composing characters [not in <NSTextInput>]. */
- (void)deleteWorkingText
{
NSTRACE ("[EmacsView deleteWorkingText]");
}
-/* used to position char selection windows, etc. */
+/* Used to position char selection windows, etc. */
- (NSRect)firstRectForCharacterRange: (NSRange)theRange
{
NSRect rect;
processingCompose = NO;
if (aSelector == @selector (deleteBackward:))
{
- /* happens when user backspaces over an ongoing composition:
- throw a 'delete' into the event queue */
+ /* Happens when user backspaces over an ongoing composition:
+ throw a 'delete' into the event queue. */
if (!emacs_event)
return;
emacs_event->kind = NON_ASCII_KEYSTROKE_EVENT;
return str;
}
-/* End <NSTextInput> impl. */
+/* End <NSTextInput> implementation. */
/*****************************************************************************/
return;
dpyinfo->last_mouse_frame = emacsframe;
- /* appears to be needed to prevent spurious movement events generated on
- button clicks */
+ /* Appears to be needed to prevent spurious movement events generated on
+ button clicks. */
emacsframe->mouse_moved = 0;
if ([theEvent type] == NSEventTypeScrollWheel)
#if defined (NS_IMPL_GNUSTEP) || MAC_OS_X_VERSION_MIN_REQUIRED < 1070
{
CGFloat delta = [theEvent deltaY];
- /* Mac notebooks send wheel events w/delta =0 when trackpad scrolling */
+ /* Mac notebooks send wheel events with delta equal to 0
+ when trackpad scrolling. */
if (delta == 0)
{
delta = [theEvent deltaX];
}
-/* Tell emacs the mouse has moved. */
+/* Tell emacs the mouse has moved. */
- (void)mouseMoved: (NSEvent *)e
{
Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (emacsframe);
dpyinfo->last_mouse_motion_x = pt.x;
dpyinfo->last_mouse_motion_y = pt.y;
- /* update any mouse face */
+ /* Update any mouse face. */
if (hlinfo->mouse_face_hidden)
{
hlinfo->mouse_face_hidden = 0;
clear_mouse_face (hlinfo);
}
- /* tooltip handling */
+ /* Tooltip handling. */
previous_help_echo_string = help_echo_string;
help_echo_string = Qnil;
{
/* NOTE: help_echo_{window,pos,object} are set in xdisp.c
(note_mouse_highlight), which is called through the
- note_mouse_movement () call above */
+ note_mouse_movement () call above. */
any_help_event_p = YES;
gen_help_event (help_echo_string, frame, help_echo_window,
help_echo_object, help_echo_pos);
if (wait_for_tool_bar)
{
/* The toolbar height is always 0 in fullscreen and undecorated
- frames, so don't wait for it to become available. */
+ frames, so don't wait for it to become available. */
if (FRAME_TOOLBAR_HEIGHT (emacsframe) == 0
&& FRAME_UNDECORATED (emacsframe) == false
&& ! [self isFullscreen])
wr = NSMakeRect (0, 0, neww, newh);
[view setFrame: wr];
- // to do: consider using [NSNotificationCenter postNotificationName:].
+ // To do: consider using [NSNotificationCenter postNotificationName:].
[self windowDidMove: // Update top/left.
[NSNotification notificationWithName:NSWindowDidMoveNotification
object:[view window]]];
}
- (NSSize)windowWillResize: (NSWindow *)sender toSize: (NSSize)frameSize
-/* normalize frame to gridded text size */
+/* Normalize frame to gridded text size. */
{
int extra = 0;
rows = MINHEIGHT;
#ifdef NS_IMPL_COCOA
{
- /* this sets window title to have size in it; the wm does this under GS */
+ /* This sets window title to have size in it; the wm does this under GS. */
NSRect r = [[self window] frame];
if (r.size.height == frameSize.height && r.size.width == frameSize.width)
{
NSTRACE_MSG ("cols: %d rows: %d", cols, rows);
- /* Restrict the new size to the text gird.
+ /* Restrict the new size to the text grid.
Don't restrict the width if the user only adjusted the height, and
vice versa. (Without this, the frame would shrink, and move
slightly, if the window was resized by dragging one of its
- borders.) */
+ borders.) */
if (!frame_resize_pixelwise)
{
NSRect r = [[self window] frame];
NSWindow *theWindow = [notification object];
/* In GNUstep, at least currently, it's possible to get a didResize
- without getting a willResize.. therefore we need to act as if we got
- the willResize now */
+ without getting a willResize, therefore we need to act as if we got
+ the willResize now. */
NSSize sz = [theWindow frame].size;
sz = [self windowWillResize: theWindow toSize: sz];
#endif /* NS_IMPL_GNUSTEP */
ns_frame_rehighlight (emacsframe);
/* FIXME: for some reason needed on second and subsequent clicks away
- from sole-frame Emacs to get hollow box to show */
+ from sole-frame Emacs to get hollow box to show. */
if (!windowClosing && [[self window] isVisible] == YES)
{
x_update_cursor (emacsframe, 1);
/* macOS Sierra automatically enables tabbed windows. We can't
allow this to be enabled until it's available on a Free system.
- Currently it only happens by accident and is buggy anyway. */
+ Currently it only happens by accident and is buggy anyway. */
#if defined (NS_IMPL_COCOA) \
&& MAC_OS_X_VERSION_MAX_ALLOWED >= 101200
#if MAC_OS_X_VERSION_MIN_REQUIRED < 101200
/* Called AFTER method below, but before our windowWillResize call there leads
to windowDidResize -> x_set_window_size. Update emacs' notion of frame
- location so set_window_size moves the frame. */
+ location so set_window_size moves the frame. */
- (BOOL)windowShouldZoom: (NSWindow *)sender toFrame: (NSRect)newFrame
{
NSTRACE (("[EmacsView windowShouldZoom:toFrame:" NSTRACE_FMT_RECT "]"
/* Override to do something slightly nonstandard, but nice. First click on
zoom button will zoom vertically. Second will zoom completely. Third
- returns to original. */
+ returns to original. */
- (NSRect)windowWillUseStandardFrame:(NSWindow *)sender
defaultFrame:(NSRect)defaultFrame
{
{
NSTRACE_MSG ("FULLSCREEN_MAXIMIZED");
- result = defaultFrame; /* second click */
+ result = defaultFrame; /* second click */
maximized_width = result.size.width;
maximized_height = result.size.height;
[self setFSValue: FULLSCREEN_MAXIMIZED];
NSScreen *screen = [w screen];
#if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= 1090
- /* Hide ghost menu bar on secondary monitor? */
+ /* Hide ghost menu bar on secondary monitor? */
if (! onFirstScreen
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1090
&& [NSScreen respondsToSelector: @selector(screensHaveSeparateSpaces)]
f->border_width = bwidth;
- // to do: consider using [NSNotificationCenter postNotificationName:] to send notifications.
+ // To do: consider using [NSNotificationCenter postNotificationName:] to
+ // send notifications.
[self windowWillExitFullScreen];
[fw setFrame: [w frame] display:YES animate:ns_use_fullscreen_animation];
}
-/* this gets called on toolbar button click */
+/* This gets called on toolbar button click. */
- (instancetype)toolbarClicked: (id)item
{
NSEvent *theEvent;
if (!emacs_event)
return self;
- /* send first event (for some reason two needed) */
+ /* Send first event (for some reason two needed). */
theEvent = [[self window] currentEvent];
emacs_event->kind = TOOL_BAR_EVENT;
XSETFRAME (emacs_event->arg, emacsframe);
EV_TRAILER (theEvent);
emacs_event->kind = TOOL_BAR_EVENT;
-/* XSETINT (emacs_event->code, 0); */
+ /* XSETINT (emacs_event->code, 0); */
emacs_event->arg = AREF (emacsframe->tool_bar_items,
idx + TOOL_BAR_ITEM_KEY);
emacs_event->modifiers = EV_MODIFIERS (theEvent);
But this should not happen because we override the services menu with our
own entries which call ns-perform-service.
Nonetheless, it appeared to happen (under strange circumstances): bug#1435.
- So let's at least stub them out until further investigation can be done. */
+ So let's at least stub them out until further investigation can be done. */
- (BOOL) readSelectionFromPasteboard: (NSPasteboard *)pb
{
- /* we could call ns_string_from_pasteboard(pboard) here but then it should
- be written into the buffer in place of the existing selection..
- ordinary service calls go through functions defined in ns-win.el */
+ /* We could call ns_string_from_pasteboard(pboard) here but then it should
+ be written into the buffer in place of the existing selection.
+ Ordinary service calls go through functions defined in ns-win.el. */
return NO;
}
NSTRACE ("[EmacsView writeSelectionToPasteboard:types:]");
- /* We only support NSStringPboardType */
+ /* We only support NSStringPboardType. */
if ([types containsObject:NSStringPboardType] == NO) {
return NO;
}
}
-/* setMini =YES means set from internal (gives a finder icon), NO means set nil
+/* setMini = YES means set from internal (gives a finder icon), NO means set nil
(gives a miniaturized version of the window); currently we use the latter for
frames whose active buffer doesn't correspond to any file
- (e.g., '*scratch*') */
+ (e.g., '*scratch*'). */
- (instancetype)setMiniwindowImage: (BOOL) setMini
{
id image = [[self window] miniwindowImage];
/* NOTE: under Cocoa miniwindowImage always returns nil, documentation
about "AppleDockIconEnabled" notwithstanding, however the set message
- below has its effect nonetheless. */
+ below has its effect nonetheless. */
if (image != emacsframe->output_data.ns->miniimage)
{
if (image && [image isKindOfClass: [EmacsImage class]])
Note that this should work in situations where multiple monitors
are present. Common configurations are side-by-side monitors and a
monitor on top of another (e.g. when a laptop is placed under a
- large screen). */
+ large screen). */
- (NSRect)constrainFrameRect:(NSRect)frameRect toScreen:(NSScreen *)screen
{
NSTRACE ("[EmacsWindow constrainFrameRect:" NSTRACE_FMT_RECT " toScreen:]",
+ (CGFloat) scrollerWidth
{
/* TODO: if we want to allow variable widths, this is the place to do it,
- however neither GNUstep nor Cocoa support it very well */
+ however neither GNUstep nor Cocoa support it very well. */
CGFloat r;
#if defined (NS_IMPL_COCOA) \
&& MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
/* Ensure auto resizing of scrollbars occurs within the emacs frame's view
locked against the top and bottom edges, and right edge on macOS, where
- scrollers are on right. */
+ scrollers are on right. */
#ifdef NS_IMPL_GNUSTEP
[self setAutoresizingMask: NSViewMaxXMargin | NSViewHeightSizable];
#else
NSView *sview = [[view window] contentView];
NSArray *subs = [sview subviews];
- /* disable optimization stopping redraw of other scrollbars */
+ /* Disable optimization stopping redraw of other scrollbars. */
view->scrollbarsNeedingUpdate = 0;
for (i =[subs count]-1; i >= 0; i--)
if ([[subs objectAtIndex: i] isKindOfClass: [EmacsScroller class]])
[sview addSubview: self];
}
-/* [self setFrame: r]; */
+ /* [self setFrame: r]; */
return self;
}
{
NSTRACE ("[EmacsScroller setFrame:]");
-/* block_input (); */
+ /* block_input (); */
if (horizontal)
pixel_length = NSWidth (newRect);
else
if (pixel_length == 0) pixel_length = 1;
min_portion = 20 / pixel_length;
[super setFrame: newRect];
-/* unblock_input (); */
+ /* unblock_input (); */
}
{
EmacsView *view;
block_input ();
- /* ensure other scrollbar updates after deletion */
+ /* Ensure other scrollbar updates after deletion. */
view = (EmacsView *)FRAME_NS_VIEW (frame);
if (view != nil)
view->scrollbarsNeedingUpdate++;
whole: (int) whole
{
return em_position ==position && em_portion ==portion && em_whole ==whole
- && portion != whole; /* needed for resize empty buf */
+ && portion != whole; /* Needed for resizing empty buffer. */
}
return self;
}
-/* set up emacs_event */
+/* Set up emacs_event. */
- (void) sendScrollEventAtLoc: (float)loc fromEvent: (NSEvent *)e
{
Lisp_Object win;
}
-/* called manually thru timer to implement repeated button action w/hold-down */
+/* Called manually through timer to implement repeated button action
+ with hold-down. */
- (instancetype)repeatScroll: (NSTimer *)scrollEntry
{
NSEvent *e = [[self window] currentEvent];
NSTRACE ("[EmacsScroller repeatScroll:]");
- /* clear timer if need be */
+ /* Clear timer if need be. */
if (inKnob || [scroll_repeat_entry timeInterval] == SCROLL_BAR_FIRST_DELAY)
{
[scroll_repeat_entry invalidate];
/* Asynchronous mouse tracking for scroller. This allows us to dispatch
- mouseDragged events without going into a modal loop. */
+ mouseDragged events without going into a modal loop. */
- (void)mouseDown: (NSEvent *)e
{
NSRect sr, kr;
- /* hitPart is only updated AFTER event is passed on */
+ /* hitPart is only updated AFTER event is passed on. */
NSScrollerPart part = [self testPart: [e locationInWindow]];
CGFloat loc, kloc, pos UNINIT;
int edge = 0;
}
else
{
- pos = 0; /* ignored */
+ pos = 0; /* ignored */
- /* set a timer to repeat, as we can't let superclass do this modally */
+ /* Set a timer to repeat, as we can't let superclass do this modally. */
scroll_repeat_entry
= [[NSTimer scheduledTimerWithTimeInterval: SCROLL_BAR_FIRST_DELAY
target: self
}
-/* Called as we manually track scroller drags, rather than superclass. */
+/* Called as we manually track scroller drags, rather than superclass. */
- (void)mouseDragged: (NSEvent *)e
{
NSRect sr;
}
-/* treat scrollwheel events in the bar as though they were in the main window */
+/* Treat scrollwheel events in the bar as though they were in the main window. */
- (void) scrollWheel: (NSEvent *)theEvent
{
NSTRACE ("[EmacsScroller scrollWheel:]");
/* XLFD: -foundry-family-weight-slant-swidth-adstyle-pxlsz-ptSz-resx-resy-spc-avgWidth-rgstry-encoding */
/* Note: ns_font_to_xlfd and ns_fontname_to_xlfd no longer needed, removed
- in 1.43. */
+ in 1.43. */
const char *
ns_xlfd_to_fontname (const char *xlfd)
name[i+1] = c_toupper (name[i+1]);
}
}
-/*fprintf (stderr, "converted '%s' to '%s'\n",xlfd,name); */
+ /* fprintf (stderr, "converted '%s' to '%s'\n",xlfd,name); */
ret = [[NSString stringWithUTF8String: name] UTF8String];
xfree (name);
return ret;
ns_antialias_threshold = 10.0;
- /* from 23+ we need to tell emacs what modifiers there are.. */
+ /* From 23+ we need to tell emacs what modifiers there are. */
DEFSYM (Qmodifier_value, "modifier-value");
DEFSYM (Qalt, "alt");
DEFSYM (Qhyper, "hyper");
DEFVAR_LISP ("ns-auto-hide-menu-bar", ns_auto_hide_menu_bar,
doc: /* Non-nil means that the menu bar is hidden, but appears when the mouse is near.
-Only works on Mac OS X 10.6 or later. */);
+Only works on Mac OS X. */);
ns_auto_hide_menu_bar = Qnil;
DEFVAR_BOOL ("ns-use-native-fullscreen", ns_use_native_fullscreen,
- doc: /*Non-nil means to use native fullscreen on Mac OS X 10.7 and later.
+ doc: /* Non-nil means to use native fullscreen on Mac OS X 10.7 and later.
Nil means use fullscreen the old (< 10.7) way. The old way works better with
multiple monitors, but lacks tool bar. This variable is ignored on
Mac OS X < 10.7. Default is t. */);
ns_last_use_native_fullscreen = ns_use_native_fullscreen;
DEFVAR_BOOL ("ns-use-fullscreen-animation", ns_use_fullscreen_animation,
- doc: /*Non-nil means use animation on non-native fullscreen.
+ doc: /* Non-nil means use animation on non-native fullscreen.
For native fullscreen, this does nothing.
Default is nil. */);
ns_use_fullscreen_animation = NO;
DEFVAR_BOOL ("ns-use-srgb-colorspace", ns_use_srgb_colorspace,
- doc: /*Non-nil means to use sRGB colorspace on Mac OS X 10.7 and later.
+ doc: /* Non-nil means to use sRGB colorspace on Mac OS X 10.7 and later.
Note that this does not apply to images.
This variable is ignored on Mac OS X < 10.7 and GNUstep. */);
ns_use_srgb_colorspace = YES;
DEFVAR_BOOL ("ns-use-mwheel-acceleration",
ns_use_mwheel_acceleration,
- doc: /*Non-nil means use macOS's standard mouse wheel acceleration.
+ doc: /* Non-nil means use macOS's standard mouse wheel acceleration.
This variable is ignored on macOS < 10.7 and GNUstep. Default is t. */);
ns_use_mwheel_acceleration = YES;
DEFVAR_LISP ("ns-mwheel-line-height", ns_mwheel_line_height,
- doc: /*The number of pixels touchpad scrolling considers one line.
+ doc: /* The number of pixels touchpad scrolling considers one line.
Nil or a non-number means use the default frame line height.
This variable is ignored on macOS < 10.7 and GNUstep. Default is nil. */);
ns_mwheel_line_height = Qnil;
DEFVAR_BOOL ("ns-use-mwheel-momentum", ns_use_mwheel_momentum,
- doc: /*Non-nil means mouse wheel scrolling uses momentum.
+ doc: /* Non-nil means mouse wheel scrolling uses momentum.
This variable is ignored on macOS < 10.7 and GNUstep. Default is t. */);
ns_use_mwheel_momentum = YES;
- /* TODO: move to common code */
+ /* TODO: Move to common code. */
DEFVAR_LISP ("x-toolkit-scroll-bars", Vx_toolkit_scroll_bars,
doc: /* SKIP: real doc in xterm.c. */);
Vx_toolkit_scroll_bars = Qt;