fn psv_helper(
    s: &str, indent: i32, no_first_indent: bool,
    window_height: i32, mut lines_to_print: i32,
) -> i32 {
    if window_height != 0 {
        if lines_to_print == 0 {
            let mut stdout = io::stdout().into_raw_mode().unwrap();
            let stdin = std::io::stdin();
            for c in stdin.keys() {
                match c.unwrap() {
                    termion::event::Key::Char('q') => {
                        stdout.suspend_raw_mode().unwrap();
                        return -1;
                    }
                    termion::event::Key::Ctrl('c') => {
                        stdout.suspend_raw_mode().unwrap();
                        return -1;
                    }
                    termion::event::Key::PageDown => {
                        lines_to_print = lines_to_print + window_height;
                    }
                    _ => {
                        lines_to_print = lines_to_print + 1;
                    }
                }
                stdout.flush().unwrap();
                break;
            }
            stdout.suspend_raw_mode().unwrap();
        }
    }
    if !no_first_indent {
        for _ in 0..indent {
            print!(" ");
        }
    }
    print!("{}\n", s);
    return lines_to_print - 1;
}
/// Helper function for print_stack_value.  Takes a string, an indent
/// count, whether the first indent needs to be skipped, the window
/// height, and the number of lines that can be printed without
/// waiting as its arguments.  Prints the string to standard output,
/// waiting for user input as required.  Returns the new number of
/// lines that can be printed without waiting.  Returns -1 if the user
/// cancels further output.  (A window height of zero indicates that
/// the current program is not being run interactively, in which case
/// no waiting is required.)
Helper function for print_stack_value.  Takes a string, an indent
count, whether the first indent needs to be skipped, the window
height, and the number of lines that can be printed without
waiting as its arguments.  Prints the string to standard output,
waiting for user input as required.  Returns the new number of
lines that can be printed without waiting.  Returns -1 if the user
cancels further output.  (A window height of zero indicates that
the current program is not being run interactively, in which case
no waiting is required.)
Helper function for print_stack_value . Takes a string an indent count whether the first indent needs to be skipped the window height and the number of lines that can be printed without waiting as its arguments . Prints the string to standard output waiting for user input as required . Returns the new number of lines that can be printed without waiting . Returns - 1 if the user cancels further output . ( A window height of zero indicates that the current program is not being run interactively in which case no waiting is required . )
fn psv_helper(
    s: &str, indent: i32, no_first_indent: bool,
    window_height: i32, mut lines_to_print: i32,
) -> i32 {
    if window_height != 0 {
        if lines_to_print == 0 {
            let mut stdout = io::stdout().into_raw_mode().unwrap();
            let stdin = std::io::stdin();
            for c in stdin.keys() {
                match c.unwrap() {
                    termion::event::Key::Char('q') => {
                        stdout.suspend_raw_mode().unwrap();
                        return -1;
                    }
                    termion::event::Key::Ctrl('c') => {
                        stdout.suspend_raw_mode().unwrap();
                        return -1;
                    }
                    termion::event::Key::PageDown => {
                        lines_to_print = lines_to_print + window_height;
                    }
                    _ => {
                        lines_to_print = lines_to_print + 1;
                    }
                }
                stdout.flush().unwrap();
                break;
            }
            stdout.suspend_raw_mode().unwrap();
        }
    }
    if !no_first_indent {
        for _ in 0..indent {
            print!(" ");
        }
    }
    print!("{}\n", s);
    return lines_to_print - 1;
}
fn psv_helper ( s : & str , indent : i32 , no_first_indent : bool , window_height : i32 , mut lines_to_print : i32 , ) -> i32 { if window_height != 0 { if lines_to_print == 0 { let mut stdout = io :: stdout ( ) . into_raw_mode ( ) . unwrap ( ) ; let stdin = std :: io :: stdin ( ) ; for c in stdin . keys ( ) { match c . unwrap ( ) { termion :: event :: Key :: Char ( 'q' ) => { stdout . suspend_raw_mode ( ) . unwrap ( ) ; return - 1 ; } termion :: event :: Key :: Ctrl ( 'c' ) => { stdout . suspend_raw_mode ( ) . unwrap ( ) ; return - 1 ; } termion :: event :: Key :: PageDown => { lines_to_print = lines_to_print + window_height ; } _ => { lines_to_print = lines_to_print + 1 ; } } stdout . flush ( ) . unwrap ( ) ; break ; } stdout . suspend_raw_mode ( ) . unwrap ( ) ; } } if ! no_first_indent { for _ in 0 .. indent { print ! ( " " ) ; } } print ! ( " \n " s ) ; return lines_to_print - 1 ; }
Helper function for print_stack_value.
Helper function for print_stack_value .
s
&str
indent
i32
no_first_indent
bool
window_height
i32
lines_to_print
i32