[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 7360813208: Try to preserve font styles in the Haiku font dialog
From: |
Po Lu |
Subject: |
master 7360813208: Try to preserve font styles in the Haiku font dialog |
Date: |
Tue, 10 May 2022 22:02:55 -0400 (EDT) |
branch: master
commit 736081320803c6d1f987f753f63581a0fd42b1fe
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>
Try to preserve font styles in the Haiku font dialog
* haiku_support.cc (class EmacsFontSelectionDialog)
(UpdateStylesForIndex): If a style was previously selected and
exists in the new family as well, select it after adding the new
items.
---
src/haiku_support.cc | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/src/haiku_support.cc b/src/haiku_support.cc
index 6b4951e139..cb9dfabc4e 100644
--- a/src/haiku_support.cc
+++ b/src/haiku_support.cc
@@ -2619,13 +2619,22 @@ class EmacsFontSelectionDialog : public BWindow
void
UpdateStylesForIndex (int idx)
{
- int n, i;
+ int n, i, previous_selection;
uint32 flags;
font_family family;
font_style style;
BStringItem *item;
+ char *current_style;
n = all_styles.CountItems ();
+ current_style = NULL;
+ previous_selection = font_style_pane.CurrentSelection ();
+
+ if (previous_selection >= 0)
+ {
+ item = all_styles.ItemAt (previous_selection);
+ current_style = strdup (item->Text ());
+ }
font_style_pane.MakeEmpty ();
all_styles.MakeEmpty ();
@@ -2641,6 +2650,10 @@ class EmacsFontSelectionDialog : public BWindow
else
item = new BStringItem ("<error>");
+ if (current_style && pending_selection_idx < 0
+ && !strcmp (current_style, style))
+ pending_selection_idx = i;
+
font_style_pane.AddItem (item);
all_styles.AddItem (item);
}
@@ -2654,6 +2667,9 @@ class EmacsFontSelectionDialog : public BWindow
pending_selection_idx = -1;
UpdateForSelectedStyle ();
+
+ if (current_style)
+ free (current_style);
}
bool
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 7360813208: Try to preserve font styles in the Haiku font dialog,
Po Lu <=