chiark / gitweb /
Give MenuKeypressLine a width reset option.
authorSimon Tatham <anakin@pobox.com>
Wed, 3 Jan 2024 06:56:05 +0000 (06:56 +0000)
committerSimon Tatham <anakin@pobox.com>
Wed, 3 Jan 2024 06:56:05 +0000 (06:56 +0000)
Then when I change menu items on the fly they won't always remember
the largest width the menu has ever had.

src/text.rs

index fc1277198047f0c1d133a463425be64e8f7065fc..7f1250baab86e812c095a61a3b5e7655a6c0698c 100644 (file)
@@ -1293,6 +1293,7 @@ fn test_filestatus_render() {
 pub struct MenuKeypressLine {
     keypress: Keypress,
     lwid: usize,
+    rwid: usize,
     lmaxwid: usize,
     rmaxwid: usize,
 }
@@ -1310,12 +1311,17 @@ impl MenuKeypressLine {
                 description,
             },
             lwid,
+            rwid,
             lmaxwid: lwid,
             rmaxwid: rwid,
         }
     }
 
-    pub fn get_widths(&self) -> (usize, usize) { (self.lmaxwid, self.rmaxwid) }
+    pub fn get_widths(&self) -> (usize, usize) { (self.lwid, self.rwid) }
+    pub fn reset_widths(&mut self) {
+        self.lmaxwid = self.lwid;
+        self.rmaxwid = self.rwid;
+    }
     pub fn ensure_widths(&mut self, lmaxwid: usize, rmaxwid: usize) {
         self.lmaxwid = max(self.lmaxwid, lmaxwid);
         self.rmaxwid = max(self.rmaxwid, rmaxwid);