emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 268713e227: Set initial size in the Haiku font dialog


From: Po Lu
Subject: master 268713e227: Set initial size in the Haiku font dialog
Date: Wed, 4 May 2022 01:46:50 -0400 (EDT)

branch: master
commit 268713e227e8b665b1874c96ea96d1e7fccaab11
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>

    Set initial size in the Haiku font dialog
    
    * src/haiku_support.cc (class EmacsFontSelectionDialog)
    (EmacsFontSelectionDialog): New argument `initial_size'.
    (be_select_font): Likewise.
    * src/haiku_support.h: Update prototypes.
    * src/haikufont.c (Fx_select_font): Set font dialog size to the
    pixel size of the current font.
---
 src/haiku_support.cc | 16 +++++++++++++---
 src/haiku_support.h  |  2 +-
 src/haikufont.c      |  8 ++++++--
 3 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/src/haiku_support.cc b/src/haiku_support.cc
index 1280a77b22..311df2e06b 100644
--- a/src/haiku_support.cc
+++ b/src/haiku_support.cc
@@ -2577,7 +2577,8 @@ public:
 
   EmacsFontSelectionDialog (bool monospace_only,
                            int initial_family_idx,
-                           int initial_style_idx)
+                           int initial_style_idx,
+                           int initial_size)
     : BWindow (BRect (0, 0, 500, 500),
               "Select font from list",
               B_TITLED_WINDOW_LOOK,
@@ -2610,6 +2611,7 @@ public:
     uint32 flags, c;
     BMessage *selection;
     BTextView *size_text;
+    char format_buffer[4];
 
     AddChild (&basic_view);
 
@@ -2670,6 +2672,12 @@ public:
 
     for (c = 58; c <= 127; ++c)
       size_text->DisallowChar (c);
+
+    if (initial_size > 0 && initial_size < 1000)
+      {
+       sprintf (format_buffer, "%d", initial_size);
+       size_entry.SetText (format_buffer);
+      }
   }
 
   void
@@ -4719,7 +4727,8 @@ be_select_font (void (*process_pending_signals_function) 
(void),
                haiku_font_family_or_style *family,
                haiku_font_family_or_style *style,
                int *size, bool allow_monospace_only,
-               int initial_family, int initial_style)
+               int initial_family, int initial_style,
+               int initial_size)
 {
   EmacsFontSelectionDialog *dialog;
   struct font_selection_dialog_message msg;
@@ -4728,7 +4737,8 @@ be_select_font (void (*process_pending_signals_function) 
(void),
   font_style style_buffer;
 
   dialog = new EmacsFontSelectionDialog (allow_monospace_only,
-                                        initial_family, initial_style);
+                                        initial_family, initial_style,
+                                        initial_size);
   dialog->CenterOnScreen ();
 
   if (dialog->InitCheck () < B_OK)
diff --git a/src/haiku_support.h b/src/haiku_support.h
index 722c05511c..63ba726050 100644
--- a/src/haiku_support.h
+++ b/src/haiku_support.h
@@ -648,7 +648,7 @@ extern bool be_replay_menu_bar_event (void *, struct 
haiku_menu_bar_click_event
 extern bool be_select_font (void (*) (void), bool (*) (void),
                            haiku_font_family_or_style *,
                            haiku_font_family_or_style *,
-                           int *, bool, int, int);
+                           int *, bool, int, int, int);
 
 extern int be_find_font_indices (struct haiku_font_pattern *, int *, int *);
 #ifdef __cplusplus
diff --git a/src/haikufont.c b/src/haikufont.c
index cf7cc83085..d18c1a393a 100644
--- a/src/haikufont.c
+++ b/src/haikufont.c
@@ -1151,7 +1151,7 @@ in the font selection dialog.  */)
   struct font *font;
   Lisp_Object font_object;
   haiku_font_family_or_style family, style;
-  int rc, size, initial_family, initial_style;
+  int rc, size, initial_family, initial_style, initial_size;
   struct haiku_font_pattern pattern;
   Lisp_Object lfamily, lweight, lslant, lwidth, ladstyle, lsize;
 
@@ -1162,6 +1162,7 @@ in the font selection dialog.  */)
 
   initial_style = -1;
   initial_family = -1;
+  initial_size = -1;
 
   font = FRAME_FONT (f);
 
@@ -1173,6 +1174,8 @@ in the font selection dialog.  */)
       be_find_font_indices (&pattern, &initial_family,
                            &initial_style);
       haikufont_done_with_query_pattern (&pattern);
+
+      initial_size = font->pixel_size;
     }
 
   popup_activated_p++;
@@ -1181,7 +1184,8 @@ in the font selection dialog.  */)
                       haikufont_should_quit_popup,
                       &family, &style, &size,
                       !NILP (exclude_proportional),
-                      initial_family, initial_style);
+                      initial_family, initial_style,
+                      initial_size);
   request_sigio ();
   popup_activated_p--;
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]