rizzler 0.1.0

the rizz editor
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
use std::io;
use std::path::Path;
use std::rc::Rc;

use crossterm::event::KeyEvent;
use rizz::RizzError;
use rizz::runtime::Value;

use crate::{
    action::Action,
    buffer::{Buffer, BufferKind},
    keymap::KeymapRegistry,
    lisp::{EditorGuard, LispRuntime, init_script_path},
    mode::EditingMode,
    position::Position,
    render::{CursorStyle, Renderer, StateSnapshot},
    render_ratatui::RatatuiRenderer,
    slots::SlotRegistry,
    styling::ThemeCell,
    window::{SplitDir, WindowTree},
};

/// Bottom-of-screen reservation: one row for the status line, one for the
/// minibuffer. Subtracted from the terminal height when sizing the editor
/// area for the window tree.
const STATUS_LINE_ROWS: u16 = 1;
const MINIBUFFER_ROWS: u16 = 1;

/// Bundle of plugin points injected into [`State`]. Swap any field to
/// customise the editor without touching `State`'s internals.
pub struct Config {
    pub renderer: Box<dyn Renderer>,
}

impl Config {
    pub fn new() -> io::Result<Self> {
        Ok(Self {
            renderer: Box::new(RatatuiRenderer::new()?),
        })
    }
}

pub struct State {
    /// All live buffers. Index 0 is the minibuffer by construction; file
    /// buffers occupy index 1..
    bufs: Vec<Buffer>,
    /// Tree of editor windows. Leaves point at indices into `bufs`. The
    /// minibuffer is not part of this tree.
    windows: WindowTree,
    /// When true, key events route to the minibuffer instead of the focused
    /// editor window.
    focus_minibuffer: bool,
    /// Index of the minibuffer (always kind = Minibuffer).
    minibuffer: usize,
    quit: bool,
    keymap: KeymapRegistry,
    renderer: Box<dyn Renderer>,
    keyevent: Option<KeyEvent>,
    /// Embedded lisp runtime. Held as `Option` so `eval_lisp*` can `take` it
    /// for the duration of an eval — this also blocks re-entrant evaluation.
    lisp: Option<LispRuntime>,
    /// Named styles registered by lisp (`face-define`). `RefCell` so render
    /// callbacks can introspect without holding `&mut State`.
    theme: ThemeCell,
    /// Ordered registry of customization slots (status segments, gutters,
    /// line decorators, bottom-strip components). Owned, not RefCell — only
    /// the lisp builtins that hold `&mut State` mutate it.
    slots: SlotRegistry,
}

impl State {
    pub fn new() -> io::Result<Self> {
        Self::with_config(Config::new()?)
    }

    pub fn with_config(config: Config) -> io::Result<Self> {
        // Layout: [minibuffer, first file buffer]. The window tree starts as
        // a single leaf pointing at the file buffer.
        let mut state = Self {
            bufs: vec![Buffer::minibuffer(), Buffer::new()],
            windows: WindowTree::new(1),
            focus_minibuffer: false,
            minibuffer: 0,
            quit: false,
            keymap: KeymapRegistry::new(),
            renderer: config.renderer,
            keyevent: None,
            lisp: Some(LispRuntime::new()),
            theme: ThemeCell::default(),
            slots: SlotRegistry::new(),
        };
        state.refresh_viewport();

        // Bundled defaults: keybindings, then visual configuration, then
        // (optional) user `init.lisp`. Each layer can override the previous.
        if let Err(e) = state.eval_lisp_script(include_str!("../default.lisp")) {
            eprintln!("default.lisp eval failed: {e}");
        }
        if let Err(e) = state.eval_lisp_script(include_str!("../default-style.lisp")) {
            eprintln!("default-style.lisp eval failed: {e}");
        }
        if let Some(path) = init_script_path()
            && let Ok(src) = std::fs::read_to_string(&path)
            && let Err(e) = state.eval_lisp_script(&src)
        {
            eprintln!("init.lisp ({}) eval failed: {e}", path.display());
        }

        Ok(state)
    }

    /// Parse `src` as one lisp form and evaluate it in the embedded runtime.
    /// Re-entrant calls panic — see [`crate::lisp::EditorGuard`].
    pub fn eval_lisp(&mut self, src: &str) -> Result<Rc<Value>, RizzError> {
        let mut lisp = self
            .lisp
            .take()
            .expect("recursive eval_lisp is not supported");
        let result = {
            let _guard = EditorGuard::new(self);
            lisp.eval_str(src)
        };
        self.lisp = Some(lisp);
        result
    }

    /// Evaluate an already-parsed form. Used to dispatch keymap-bound lisp.
    pub fn eval_lisp_value(&mut self, form: Rc<Value>) -> Result<Rc<Value>, RizzError> {
        let mut lisp = self
            .lisp
            .take()
            .expect("recursive eval_lisp is not supported");
        let result = {
            let _guard = EditorGuard::new(self);
            lisp.eval_value(form)
        };
        self.lisp = Some(lisp);
        result
    }

    /// Evaluate a multi-form script (e.g. `default.lisp`, `init.lisp`).
    pub fn eval_lisp_script(&mut self, src: &str) -> Result<(), RizzError> {
        let mut lisp = self
            .lisp
            .take()
            .expect("recursive eval_lisp is not supported");
        let result = {
            let _guard = EditorGuard::new(self);
            lisp.eval_script(src)
        };
        self.lisp = Some(lisp);
        result
    }

    /// Read-only accessor for the focused buffer. Exposed for lisp builtins
    /// that need to query buffer state without going through `Action`.
    pub(crate) fn focused_buf(&self) -> &Buffer {
        let i = self.focused_bufno();
        &self.bufs[i]
    }

    /// Accessor for the [`crate::styling::Theme`] cell. Used by `face-define`
    /// / `face-of` builtins.
    pub(crate) fn theme(&self) -> &ThemeCell {
        &self.theme
    }

    /// Mutable accessor for the slot registry. Used by the `*-add`/`*-remove`
    /// builtins.
    pub(crate) fn slots_mut(&mut self) -> &mut SlotRegistry {
        &mut self.slots
    }

    /// Write `msg` into the minibuffer as a status line. Used by lisp's
    /// `(message ...)` and as the sink for eval errors.
    pub(crate) fn set_minibuffer_message(&mut self, msg: &str) {
        let b = &mut self.bufs[self.minibuffer];
        b.clear();
        for c in msg.chars() {
            b.insert_char(c);
        }
    }

    /// Read the current minibuffer text and leave the minibuffer. Used by the
    /// `command-submit` lisp builtin, which then evaluates the text inline
    /// using the env already in scope (calling back into `eval_lisp` from here
    /// would re-take `self.lisp` and panic).
    pub(crate) fn take_minibuffer_command(&mut self) -> String {
        let cmd = self.bufs[self.minibuffer].text();
        self.exit_minibuffer();
        cmd
    }

    /// The buffer currently receiving key events.
    fn focused_bufno(&self) -> usize {
        if self.focus_minibuffer {
            self.minibuffer
        } else {
            self.windows.focused_bufno()
        }
    }

    /// Update viewports of all buffers currently displayed in a window plus
    /// the minibuffer. Per-leaf rect comes from the window tree layout.
    /// Silently ignores terminal::size errors so tests without a real TTY
    /// still work.
    fn refresh_viewport(&mut self) {
        let Ok((cols, rows)) = crossterm::terminal::size() else {
            return;
        };
        let editor_h = rows.saturating_sub(STATUS_LINE_ROWS + MINIBUFFER_ROWS);
        let editor_area = ratatui::layout::Rect::new(0, 0, cols, editor_h);
        for leaf in self.windows.layout(editor_area) {
            if let Some(buf) = self.bufs.get_mut(leaf.bufno) {
                buf.viewport = Position::new(leaf.area.width, leaf.area.height);
            }
        }
        self.bufs[self.minibuffer].viewport = Position::new(cols, MINIBUFFER_ROWS);
    }

    pub fn quit_requested(&self) -> bool {
        self.quit
    }

    pub fn handle_key_event(&mut self, event: KeyEvent) -> io::Result<()> {
        self.keyevent = Some(event);
        let mode = self.bufs[self.focused_bufno()].mode();
        if let Some(action) = self.keymap.resolve(mode, event.into()) {
            self.apply(&action)?;
        }
        // Refresh after apply: window splits/closes and buffer switches may
        // have changed which buffer occupies which viewport.
        self.refresh_viewport();
        let focused = self.focused_bufno();
        self.bufs[focused].clamp_cursor();
        self.render()
    }

    pub fn apply(&mut self, actions: &[Rc<Action>]) -> io::Result<()> {
        for action in actions {
            match action.as_ref() {
                Action::Noop => {}
                Action::Quit => self.quit = true,
                Action::SetMode(m) => self.set_mode(*m),
                Action::InsertChar(c) => {
                    let f = self.focused_bufno();
                    self.bufs[f].insert_char(*c);
                }
                Action::InsertNewline => {
                    let f = self.focused_bufno();
                    self.bufs[f].insert_char('\n');
                }
                Action::DeleteChar => {
                    let f = self.focused_bufno();
                    self.bufs[f].delete_char();
                }
                Action::MoveCursor(m) => {
                    let f = self.focused_bufno();
                    self.bufs[f].move_cursor(*m);
                }
                Action::CommandCancel => self.exit_minibuffer(),
                Action::BufCreate { path, set_active } => {
                    self.create_buf(*set_active, path.clone())?;
                }
                Action::BufDelete => {
                    let editor = self.windows.focused_bufno();
                    self.delete_buf(editor);
                }
                Action::BufNext => self.next_buffer(),
                Action::BufPrev => self.previous_buffer(),
                Action::BufEdit(path) => {
                    self.edit_buf(path.clone())?;
                }
                Action::BufWrite(path) => self.write_buf(path.clone())?,
                Action::WindowSplit(dir) => self.window_split(*dir),
                Action::WindowClose => self.window_close(),
                Action::WindowFocusNext => self.windows.focus_next(),
                Action::WindowFocus(d) => self.windows.focus_dir(*d),
                Action::KeymapSet { mode, lhs, rhs } => {
                    self.keymap.set(*mode, lhs, rhs.clone());
                }
                Action::KeymapRemove { mode, lhs } => {
                    self.keymap.remove(*mode, lhs);
                }
                Action::EvalLisp(form) => {
                    if let Err(e) = self.eval_lisp_value(form.clone()) {
                        self.set_minibuffer_message(&e.to_string());
                    }
                }
            }
        }
        Ok(())
    }

    /// Apply a SetMode action. Command is special: it moves focus to the
    /// minibuffer instead of changing an editor buffer's mode.
    fn set_mode(&mut self, mode: EditingMode) {
        if mode == EditingMode::Command {
            // Wipe any leftover status text from a previous eval.
            self.bufs[self.minibuffer].clear();
            self.bufs[self.minibuffer].set_mode(EditingMode::Command);
            self.focus_minibuffer = true;
        } else {
            let f = self.focused_bufno();
            self.bufs[f].set_mode(mode);
        }
    }

    /// Clear the minibuffer, drop focus from it, and reset the focused
    /// editor buffer to Normal mode.
    fn exit_minibuffer(&mut self) {
        self.bufs[self.minibuffer].clear();
        self.bufs[self.minibuffer].set_mode(EditingMode::Command);
        self.focus_minibuffer = false;
        let editor = self.windows.focused_bufno();
        self.bufs[editor].set_mode(EditingMode::Normal);
    }

    fn create_buf(&mut self, set_active: bool, path: Option<Rc<Path>>) -> io::Result<usize> {
        let buf = match path {
            Some(ref p) => self
                .bufs
                .iter()
                .find(|b| b.fs_path == path)
                .cloned()
                .unwrap_or_else(|| Buffer::with_path(p.clone())),
            None => Buffer::new(),
        };

        self.bufs.push(buf);
        let bufno = self.bufs.len() - 1;
        if set_active {
            self.windows.set_focused_bufno(bufno);
        }
        Ok(bufno)
    }

    fn edit_buf(&mut self, path: Rc<Path>) -> io::Result<usize> {
        let idx = self
            .bufs
            .iter()
            .position(|b| b.fs_path.as_ref() == Some(&path));
        match idx {
            Some(idx) => {
                self.windows.set_focused_bufno(idx);
                Ok(idx)
            }
            None => {
                self.bufs.push(Buffer::with_path(path));
                let idx = self.bufs.len() - 1;
                self.windows.set_focused_bufno(idx);
                Ok(idx)
            }
        }
    }

    fn write_buf(&mut self, path: Option<Rc<Path>>) -> io::Result<()> {
        let editor = self.windows.focused_bufno();
        self.bufs[editor].write(path)
    }

    /// Refuses to delete the minibuffer; keeps at least one file buffer alive.
    fn delete_buf(&mut self, bufno: usize) {
        if bufno >= self.bufs.len() || self.bufs[bufno].kind() == BufferKind::Minibuffer {
            return;
        }

        if self.file_buf_count() == 1 {
            // Last file buffer: reset it in place instead of removing.
            self.bufs[bufno] = Buffer::new();
            self.windows.for_each_leaf_mut(|b| *b = bufno);
            return;
        }

        self.bufs.remove(bufno);
        if self.minibuffer > bufno {
            self.minibuffer -= 1;
        }
        // Reindex every leaf that pointed past the removed buffer; any leaf
        // that pointed AT the removed buffer falls back to the first file buf.
        let first = self.first_file_buf();
        self.windows.for_each_leaf_mut(|b| {
            if *b == bufno {
                *b = first;
            } else if *b > bufno {
                *b -= 1;
            }
        });
    }

    fn window_split(&mut self, dir: SplitDir) {
        // New pane gets a fresh scratch buffer.
        self.bufs.push(Buffer::new());
        let new_bufno = self.bufs.len() - 1;
        self.windows.split(dir, new_bufno);
    }

    fn window_close(&mut self) {
        self.windows.close_focused();
    }

    fn file_buf_count(&self) -> usize {
        self.bufs
            .iter()
            .filter(|b| b.kind() != BufferKind::Minibuffer)
            .count()
    }

    fn first_file_buf(&self) -> usize {
        self.bufs
            .iter()
            .position(|b| b.kind() != BufferKind::Minibuffer)
            .expect("at least one file buffer always exists")
    }

    /// Cycle the focused window to the previous file buffer in `bufs`,
    /// skipping the minibuffer.
    fn previous_buffer(&mut self) {
        let n = self.bufs.len();
        let mut i = self.windows.focused_bufno();
        for _ in 0..n {
            i = if i == 0 { n - 1 } else { i - 1 };
            if self.bufs[i].kind() != BufferKind::Minibuffer {
                self.windows.set_focused_bufno(i);
                return;
            }
        }
    }

    fn next_buffer(&mut self) {
        let n = self.bufs.len();
        let mut i = self.windows.focused_bufno();
        for _ in 0..n {
            i = if i + 1 >= n { 0 } else { i + 1 };
            if self.bufs[i].kind() != BufferKind::Minibuffer {
                self.windows.set_focused_bufno(i);
                return;
            }
        }
    }

    pub fn render(&mut self) -> io::Result<()> {
        let focused = self.focused_bufno();
        // Build the precomputed frame first. This installs an `EditorGuard`
        // so lisp render callbacks can reach back into `State` for queries,
        // and runs each slot to a plain value the renderer can consume.
        let (frame, error_msg) = self.precompute_frame();
        let snap = StateSnapshot {
            bufs: &self.bufs,
            windows: &self.windows,
            minibuffer: &self.bufs[self.minibuffer],
            focus_minibuffer: self.focus_minibuffer,
            bufno: self.windows.focused_bufno(),
            keyevent: self.keyevent.map(|e| e.into()),
            cursor_style: match self.bufs[focused].mode() {
                EditingMode::Insert | EditingMode::Command => CursorStyle::Bar,
                _ => CursorStyle::Block,
            },
        };
        let result = self.renderer.render(snap, &frame);
        // Surface any render-callback error to the minibuffer *after* the
        // frame draws so the message itself isn't part of the failing pass.
        if let Some(msg) = error_msg {
            self.set_minibuffer_message(&msg);
        }
        result
    }

    /// Run every slot under an `EditorGuard`, packing the results into a
    /// `RenderedFrame` the renderer can consume without ever touching lisp.
    /// Returns the frame plus an optional error message (concatenated from
    /// the first few slot failures) to surface to the minibuffer.
    pub(crate) fn precompute_frame(&mut self) -> (crate::render::RenderedFrame, Option<String>) {
        use crate::render::{RenderedBottom, RenderedBuffer, RenderedFrame};
        use crate::slots::{
            SegmentSide, produce_bottom, produce_decorator, produce_gutter, produce_status_segment,
        };

        let lisp = self.lisp.take().expect("recursive render is not supported");
        let _editor_guard = crate::lisp::EditorGuard::new(self);
        let _phase_guard = crate::lisp::RenderPhaseGuard::enter();

        // Snapshot the theme so callbacks that mutate it (`face-define`) only
        // affect the next frame.
        let theme = self.theme.borrow().clone();
        let env = lisp.env().clone();

        let mut error_chunks: Vec<String> = Vec::new();
        let record = |chunks: &mut Vec<String>, slot_name: &str, err: rizz::RizzError| {
            if chunks.len() < 3 {
                chunks.push(format!("[{slot_name}] {err}"));
            }
        };

        // Build a synthetic snapshot for status/bottom slots. They take a
        // `&StateSnapshot`, which is just a read-only window onto fields
        // we already own.
        let snap = StateSnapshot {
            bufs: &self.bufs,
            windows: &self.windows,
            minibuffer: &self.bufs[self.minibuffer],
            focus_minibuffer: self.focus_minibuffer,
            bufno: self.windows.focused_bufno(),
            keyevent: self.keyevent.map(|e| e.into()),
            cursor_style: CursorStyle::Block, // placeholder; segments don't use it
        };

        // Status segments
        let mut status_left = Vec::new();
        for s in self.slots.status_segments(SegmentSide::Left) {
            match produce_status_segment(s, &snap, &theme, &env) {
                Ok(spans) => status_left.extend(spans),
                Err(e) => record(&mut error_chunks, &s.name, e),
            }
        }
        let mut status_right = Vec::new();
        for s in self.slots.status_segments(SegmentSide::Right) {
            match produce_status_segment(s, &snap, &theme, &env) {
                Ok(spans) => status_right.extend(spans),
                Err(e) => record(&mut error_chunks, &s.name, e),
            }
        }

        // Bottom rows (user-added only — status line and minibuffer are
        // hardcoded into the renderer's layout).
        let mut bottom_extra = Vec::new();
        for s in self.slots.bottom() {
            match produce_bottom(s, &snap, &theme, &env) {
                Ok(lines) => bottom_extra.push(RenderedBottom { lines }),
                Err(e) => record(&mut error_chunks, &s.name, e),
            }
        }

        // Per-buffer gutters and decorators.
        let mut per_buf = Vec::with_capacity(self.bufs.len());
        for (i, buf) in self.bufs.iter().enumerate() {
            // Skip the minibuffer — it has its own component.
            if i == self.minibuffer {
                per_buf.push(RenderedBuffer::default());
                continue;
            }
            let mut rb = RenderedBuffer::default();
            for s in self.slots.gutters() {
                match produce_gutter(s, buf, &theme, &env) {
                    Ok(g) => rb.gutters.push(g),
                    Err(e) => record(&mut error_chunks, &s.name, e),
                }
            }
            for s in self.slots.decorators() {
                match produce_decorator(s, buf, &theme, &env) {
                    Ok(d) => rb.decorators.push(d),
                    Err(e) => record(&mut error_chunks, &s.name, e),
                }
            }
            per_buf.push(rb);
        }

        // `runtime::apply` discards a callee's local bindings, so the env
        // hasn't moved. Drop both guards before restoring lisp.
        drop(_phase_guard);
        drop(_editor_guard);
        self.lisp = Some(lisp);

        let error_msg = if error_chunks.is_empty() {
            None
        } else {
            Some(error_chunks.join("; "))
        };

        (
            RenderedFrame {
                status_left,
                status_right,
                bottom_extra,
                per_buf,
            },
            error_msg,
        )
    }
}

#[cfg(test)]
pub(crate) mod test_support {
    use super::*;

    /// A renderer that does nothing — used in tests that don't want to touch a terminal.
    pub struct NullRenderer;
    impl Renderer for NullRenderer {
        fn render(
            &mut self,
            _snap: StateSnapshot<'_>,
            _frame: &crate::render::RenderedFrame,
        ) -> io::Result<()> {
            Ok(())
        }
    }

    pub fn test_state() -> State {
        State::with_config(Config {
            renderer: Box::new(NullRenderer),
        })
        .unwrap()
    }
}

#[cfg(test)]
mod tests {
    use super::test_support::test_state;
    use super::*;

    #[test]
    fn render_does_not_panic_on_empty_buffer() {
        let mut s = test_state();
        s.render().unwrap();
    }

    #[test]
    fn split_then_close_returns_to_single_window() {
        let mut s = test_state();
        s.apply(&[Rc::new(Action::WindowSplit(SplitDir::Horizontal))])
            .unwrap();
        s.apply(&[Rc::new(Action::WindowClose)]).unwrap();
        s.render().unwrap();
    }

    #[test]
    fn default_precompute_produces_expected_slots() {
        // Confirms the bundled `default-style.lisp` loads cleanly and
        // produces a populated frame. We assert structural invariants only
        // (no slot errors, at least one gutter, the standard decorators,
        // both status sides have content). The exact shape is theme-defined.
        let mut s = test_state();
        let (frame, err) = s.precompute_frame();
        assert!(err.is_none(), "no slot errors expected: {err:?}");
        assert!(!frame.status_left.is_empty(), "expected left segments");
        assert!(!frame.status_right.is_empty(), "expected right segments");
        let bufno = s.windows.focused_bufno();
        let bf = &frame.per_buf[bufno];
        assert!(!bf.gutters.is_empty());
        assert!(bf.decorators.len() >= 3);
        // The bundled theme adds one bottom hint bar.
        assert!(!frame.bottom_extra.is_empty());
    }
}