@@ -7,8 +7,6 @@ use crate::services::{apt::Apt, gfx::Gfx};
77
88use ctru_sys:: { errorConf, errorDisp, errorInit} ;
99
10- use std:: fmt:: Write ;
11-
1210/// Configuration struct to set up the Error applet.
1311#[ doc( alias = "errorConf" ) ]
1412pub struct PopUp {
@@ -54,17 +52,30 @@ impl PopUp {
5452 Self { state }
5553 }
5654
57- /// Sets the error text to display.
55+ /// Returns a [`Utf16Writer`] that writes its output to the [`PopUp`]'s internal text buffer.
56+ ///
57+ /// # Example
58+ ///
59+ /// ```
60+ /// # let _runner = test_runner::GdbRunner::default();
61+ /// # fn main() {
62+ /// #
63+ /// use std::fmt::Write;
64+ ///
65+ /// let mut popup = PopUp::new(WordWrap::Enabled);
66+ ///
67+ /// let _ = write!(popup.writer(), "Look mom, I'm a custom error message!");
68+ /// #
69+ /// # }
70+ /// ```
5871 ///
5972 /// # Notes
6073 ///
61- /// The text will be converted to UTF-16 for display with the applet, and the message will be truncated if it exceeds
62- /// 1900 UTF-16 code units in length after conversion.
74+ /// The input string be converted to UTF-16 for display with the applet, and the message will be
75+ /// truncated if it exceeds 1900 UTF-16 code units in length after conversion.
6376 #[ doc( alias = "errorText" ) ]
64- pub fn set_text ( & mut self , text : & str ) {
65- let mut writer = Utf16Writer :: new ( & mut self . state . Text ) ;
66-
67- let _ = writer. write_str ( text) ;
77+ pub fn writer < ' a > ( & ' a mut self ) -> Utf16Writer < ' a > {
78+ Utf16Writer :: new ( & mut self . state . Text )
6879 }
6980
7081 /// Launches the error applet.
0 commit comments