diff options
author | Po Lu <luangruo@yahoo.com> | 2022-05-02 05:48:48 +0000 |
---|---|---|
committer | Po Lu <luangruo@yahoo.com> | 2022-05-02 05:49:42 +0000 |
commit | 3ea1a6672b1cc8c7ea505585e8687500014e524b (patch) | |
tree | 29e7ebd531f1accfe3d8405b2f4d59ee105ac1be /src/haiku_support.cc | |
parent | 2fa11123e5e3ebe3703da1968f66d14265358ac5 (diff) | |
download | emacs-3ea1a6672b1cc8c7ea505585e8687500014e524b.tar.gz emacs-3ea1a6672b1cc8c7ea505585e8687500014e524b.tar.bz2 emacs-3ea1a6672b1cc8c7ea505585e8687500014e524b.zip |
Default to currently selected font in Haiku font dialogs
* src/haiku_font_support.cc (be_find_font_indices): New
function.
* src/haiku_support.cc (class EmacsFontSelectionDialog)
(UpdateStylesForIndex, EmacsFontSelectionDialog): Allow
specifying an initial font family and style.
(be_select_font): New parameters `initial_family' and
`initial_style'.
* src/haiku_support.h: Update prototypes.
* src/haikufont.c (haikufont_lisp_to_weight)
(haikufont_lisp_to_slant, haikufont_lisp_to_width): Handle
`regular'.
(haikufont_pattern_from_object): New function.
(haikufont_spec_or_entity_to_pattern): Fix coding style.
(Fx_select_font): Compute indices based on currently selected
font.
(syms_of_haikufont): New defsyms.
Diffstat (limited to 'src/haiku_support.cc')
-rw-r--r-- | src/haiku_support.cc | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/src/haiku_support.cc b/src/haiku_support.cc index 9e31e1b870f..12934faa1c8 100644 --- a/src/haiku_support.cc +++ b/src/haiku_support.cc @@ -2448,6 +2448,7 @@ class EmacsFontSelectionDialog : public BWindow BTextControl size_entry; port_id comm_port; bool allow_monospace_only; + int pending_selection_idx; void UpdateStylesForIndex (int idx) @@ -2479,6 +2480,13 @@ class EmacsFontSelectionDialog : public BWindow } } + if (pending_selection_idx >= 0) + { + font_style_pane.Select (pending_selection_idx); + font_style_pane.ScrollToSelection (); + } + + pending_selection_idx = -1; UpdateForSelectedStyle (); } @@ -2559,7 +2567,9 @@ public: 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, @@ -2583,7 +2593,8 @@ public: 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; @@ -2638,6 +2649,12 @@ public: } } + 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) @@ -4701,7 +4718,8 @@ be_select_font (void (*process_pending_signals_function) (void), 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; @@ -4709,7 +4727,8 @@ be_select_font (void (*process_pending_signals_function) (void), 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) |