BTextControl size_entry;
port_id comm_port;
bool allow_monospace_only;
+ int pending_selection_idx;
void
UpdateStylesForIndex (int idx)
}
}
+ if (pending_selection_idx >= 0)
+ {
+ font_style_pane.Select (pending_selection_idx);
+ font_style_pane.ScrollToSelection ();
+ }
+
+ pending_selection_idx = -1;
UpdateForSelectedStyle ();
}
delete_port (comm_port);
}
- EmacsFontSelectionDialog (bool monospace_only)
+ EmacsFontSelectionDialog (bool monospace_only,
+ int initial_family_idx,
+ int initial_style_idx)
: BWindow (BRect (0, 0, 500, 500),
"Select font from list",
B_TITLED_WINDOW_LOOK,
new BMessage (B_CANCEL)),
ok_button ("OK", "OK", new BMessage (B_OK)),
size_entry (NULL, "Size:", NULL, NULL),
- allow_monospace_only (monospace_only)
+ allow_monospace_only (monospace_only),
+ pending_selection_idx (initial_style_idx)
{
BStringItem *family_item;
int i, n_families;
}
}
+ if (initial_family_idx >= 0)
+ {
+ font_family_pane.Select (initial_family_idx);
+ font_family_pane.ScrollToSelection ();
+ }
+
size_text = size_entry.TextView ();
for (c = 0; c <= 47; ++c)
bool (*should_quit_function) (void),
haiku_font_family_or_style *family,
haiku_font_family_or_style *style,
- int *size, bool allow_monospace_only)
+ int *size, bool allow_monospace_only,
+ int initial_family, int initial_style)
{
EmacsFontSelectionDialog *dialog;
struct font_selection_dialog_message msg;
font_family family_buffer;
font_style style_buffer;
- dialog = new EmacsFontSelectionDialog (allow_monospace_only);
+ dialog = new EmacsFontSelectionDialog (allow_monospace_only,
+ initial_family, initial_style);
dialog->CenterOnScreen ();
if (dialog->InitCheck () < B_OK)
return HAIKU_LIGHT;
if (EQ (weight, Qsemi_light))
return HAIKU_SEMI_LIGHT;
- if (EQ (weight, Qnormal))
+ if (EQ (weight, Qnormal) || EQ (weight, Qregular))
return HAIKU_REGULAR;
if (EQ (weight, Qsemi_bold))
return HAIKU_SEMI_BOLD;
if (EQ (weight, Qmedium))
return HAIKU_MEDIUM;
- emacs_abort ();
+ return HAIKU_REGULAR;
}
static Lisp_Object
static enum haiku_font_slant
haikufont_lisp_to_slant (Lisp_Object slant)
{
- if (EQ (slant, Qitalic) ||
- EQ (slant, Qreverse_italic))
+ if (EQ (slant, Qitalic)
+ || EQ (slant, Qreverse_italic))
return SLANT_ITALIC;
- if (EQ (slant, Qoblique) ||
- EQ (slant, Qreverse_oblique))
+ if (EQ (slant, Qoblique)
+ || EQ (slant, Qreverse_oblique))
return SLANT_OBLIQUE;
- if (EQ (slant, Qnormal))
+ if (EQ (slant, Qnormal) || EQ (slant, Qregular))
return SLANT_REGULAR;
- emacs_abort ();
+
+ return SLANT_REGULAR;
}
static Lisp_Object
return CONDENSED;
if (EQ (lisp, Qsemi_condensed))
return SEMI_CONDENSED;
- if (EQ (lisp, Qnormal))
+ if (EQ (lisp, Qnormal) || EQ (lisp, Qregular))
return NORMAL_WIDTH;
if (EQ (lisp, Qexpanded))
return EXPANDED;
return EXTRA_EXPANDED;
if (EQ (lisp, Qultra_expanded))
return ULTRA_EXPANDED;
- emacs_abort ();
+
+ return NORMAL_WIDTH;
}
static int
return ent;
}
+static void
+haikufont_pattern_from_object (struct haiku_font_pattern *pattern,
+ Lisp_Object font_object)
+{
+ Lisp_Object val;
+
+ pattern->specified = 0;
+
+ val = AREF (font_object, FONT_FAMILY_INDEX);
+ if (!NILP (val))
+ {
+ pattern->specified |= FSPEC_FAMILY;
+ strncpy ((char *) &pattern->family,
+ SSDATA (SYMBOL_NAME (val)),
+ sizeof pattern->family - 1);
+ pattern->family[sizeof pattern->family - 1] = '\0';
+ }
+
+ val = AREF (font_object, FONT_ADSTYLE_INDEX);
+ if (!NILP (val))
+ {
+ pattern->specified |= FSPEC_STYLE;
+ strncpy ((char *) &pattern->style,
+ SSDATA (SYMBOL_NAME (val)),
+ sizeof pattern->style - 1);
+ pattern->style[sizeof pattern->style - 1] = '\0';
+ }
+
+ val = FONT_WEIGHT_FOR_FACE (font_object);
+ if (!NILP (val) && !EQ (val, Qunspecified))
+ {
+ pattern->specified |= FSPEC_WEIGHT;
+ pattern->weight = haikufont_lisp_to_weight (val);
+ }
+
+ val = FONT_SLANT_FOR_FACE (font_object);
+ if (!NILP (val) && !EQ (val, Qunspecified))
+ {
+ pattern->specified |= FSPEC_SLANT;
+ pattern->slant = haikufont_lisp_to_slant (font_object);
+ }
+
+ val = FONT_WIDTH_FOR_FACE (font_object);
+ if (!NILP (val) && !EQ (val, Qunspecified))
+ {
+ pattern->specified |= FSPEC_WIDTH;
+ pattern->width = haikufont_lisp_to_width (font_object);
+ }
+}
+
static void
haikufont_spec_or_entity_to_pattern (Lisp_Object ent, int list_p,
struct haiku_font_pattern *ptn)
}
tem = AREF (ent, FONT_FAMILY_INDEX);
- if (!NILP (tem) && !EQ (tem, Qunspecified) &&
- (list_p && !haikufont_maybe_handle_special_family (tem, ptn)))
+ if (!NILP (tem) && !EQ (tem, Qunspecified)
+ && (list_p
+ && !haikufont_maybe_handle_special_family (tem, ptn)))
{
ptn->specified |= FSPEC_FAMILY;
strncpy ((char *) &ptn->family,
in the font selection dialog. */)
(Lisp_Object frame, Lisp_Object exclude_proportional)
{
+ struct frame *f;
+ struct font *font;
+ Lisp_Object font_object;
haiku_font_family_or_style family, style;
- int rc, size;
+ int rc, size, initial_family, initial_style;
struct haiku_font_pattern pattern;
Lisp_Object lfamily, lweight, lslant, lwidth, ladstyle, lsize;
- decode_window_system_frame (frame);
+ f = decode_window_system_frame (frame);
if (popup_activated_p)
error ("Trying to use a menu from within a menu-entry");
+ initial_style = -1;
+ initial_family = -1;
+
+ font = FRAME_FONT (f);
+
+ if (font)
+ {
+ XSETFONT (font_object, font);
+
+ haikufont_pattern_from_object (&pattern, font_object);
+ be_find_font_indices (&pattern, &initial_family,
+ &initial_style);
+ haikufont_done_with_query_pattern (&pattern);
+ }
+
popup_activated_p++;
unrequest_sigio ();
rc = be_select_font (process_pending_signals,
haikufont_should_quit_popup,
&family, &style, &size,
- !NILP (exclude_proportional));
+ !NILP (exclude_proportional),
+ initial_family, initial_style);
request_sigio ();
popup_activated_p--;
DEFSYM (Qexpanded, "expanded");
DEFSYM (Qextra_expanded, "extra-expanded");
DEFSYM (Qultra_expanded, "ultra-expanded");
+ DEFSYM (Qregular, "regular");
DEFSYM (Qzh, "zh");
DEFSYM (Qko, "ko");
DEFSYM (Qjp, "jp");