pub fn draw<T>(
        &mut self,
        terminal: MutexGuard<'_, Term<T>>,
        message_buffer: &MessageBuffer,
        config: &Config,
        mouse: &Mouse,
        mods: ModifiersState,
    ) {
        let grid_cells: Vec<RenderableCell> = terminal.renderable_cells(config).collect();
        let visual_bell_intensity = terminal.visual_bell.intensity();
        let background_color = terminal.background_color();
        let metrics = self.glyph_cache.font_metrics();
        let glyph_cache = &mut self.glyph_cache;
        let size_info = self.size_info;

        let selection = !terminal.selection().as_ref().map(Selection::is_empty).unwrap_or(true);
        let mouse_mode = terminal.mode().intersects(TermMode::MOUSE_MODE);

        // Update IME position
        #[cfg(not(windows))]
        self.window.update_ime_position(&terminal, &self.size_info);

        // Drop terminal as early as possible to free lock
        drop(terminal);

        self.renderer.with_api(&config, &size_info, |api| {
            api.clear(background_color);
        });

        let mut lines = RenderLines::new();
        let mut urls = Urls::new();

        // Draw grid
        {
            let _sampler = self.meter.sampler();

            self.renderer.with_api(&config, &size_info, |mut api| {
                // Iterate over all non-empty cells in the grid
                for cell in grid_cells {
                    // Update URL underlines
                    urls.update(size_info.cols().0, cell);

                    // Update underline/strikeout
                    lines.update(cell);

                    // Draw the cell
                    api.render_cell(cell, glyph_cache);
                }
            });
        }

        let mut rects = lines.rects(&metrics, &size_info);

        // Update visible URLs
        self.urls = urls;
        if let Some(url) = self.urls.highlighted(config, mouse, mods, mouse_mode, selection) {
            rects.append(&mut url.rects(&metrics, &size_info));

            self.window.set_mouse_cursor(CursorIcon::Hand);

            self.highlighted_url = Some(url);
        } else if self.highlighted_url.is_some() {
            self.highlighted_url = None;

            if mouse_mode {
                self.window.set_mouse_cursor(CursorIcon::Default);
            } else {
                self.window.set_mouse_cursor(CursorIcon::Text);
            }
        }

        // Push visual bell after url/underline/strikeout rects
        if visual_bell_intensity != 0. {
            let visual_bell_rect = RenderRect::new(
                0.,
                0.,
                size_info.width,
                size_info.height,
                config.visual_bell.color,
                visual_bell_intensity as f32,
            );
            rects.push(visual_bell_rect);
        }

        if let Some(message) = message_buffer.message() {
            let text = message.text(&size_info);

            // Create a new rectangle for the background
            let start_line = size_info.lines().0 - text.len();
            let y = size_info.cell_height.mul_add(start_line as f32, size_info.padding_y);
            let message_bar_rect =
                RenderRect::new(0., y, size_info.width, size_info.height - y, message.color(), 1.);

            // Push message_bar in the end, so it'll be above all other content
            rects.push(message_bar_rect);

            // Draw rectangles
            self.renderer.draw_rects(&size_info, rects);

            // Relay messages to the user
            let mut offset = 1;
            for message_text in text.iter().rev() {
                self.renderer.with_api(&config, &size_info, |mut api| {
                    api.render_string(
                        &message_text,
                        Line(size_info.lines().saturating_sub(offset)),
                        glyph_cache,
                        None,
                    );
                });
                offset += 1;
            }
        } else {
            // Draw rectangles
            self.renderer.draw_rects(&size_info, rects);
        }

        // Draw render timer
        if config.render_timer() {
            let timing = format!("{:.3} usec", self.meter.average());
            let color = Rgb { r: 0xd5, g: 0x4e, b: 0x53 };
            self.renderer.with_api(&config, &size_info, |mut api| {
                api.render_string(&timing[..], size_info.lines() - 2, glyph_cache, Some(color));
            });
        }

        self.window.swap_buffers();
    }
/// Draw the screen
///
/// A reference to Term whose state is being drawn must be provided.
///
/// This call may block if vsync is enabled
Draw the screen
A reference to Term whose state is being drawn must be provided.

This call may block if vsync is enabled
Draw the screen A reference to Term whose state is being drawn must be provided . This call may block if vsync is enabled
pub fn draw<T>(
        &mut self,
        terminal: MutexGuard<'_, Term<T>>,
        message_buffer: &MessageBuffer,
        config: &Config,
        mouse: &Mouse,
        mods: ModifiersState,
    ) {
        let grid_cells: Vec<RenderableCell> = terminal.renderable_cells(config).collect();
        let visual_bell_intensity = terminal.visual_bell.intensity();
        let background_color = terminal.background_color();
        let metrics = self.glyph_cache.font_metrics();
        let glyph_cache = &mut self.glyph_cache;
        let size_info = self.size_info;
        let selection = !terminal.selection().as_ref().map(Selection::is_empty).unwrap_or(true);
        let mouse_mode = terminal.mode().intersects(TermMode::MOUSE_MODE);
        // Update IME position
        #[cfg(not(windows))]
        self.window.update_ime_position(&terminal, &self.size_info);
        // Drop terminal as early as possible to free lock
        drop(terminal);
        self.renderer.with_api(&config, &size_info, |api| {
            api.clear(background_color);
        });
        let mut lines = RenderLines::new();
        let mut urls = Urls::new();
        // Draw grid
        {
            let _sampler = self.meter.sampler();
            self.renderer.with_api(&config, &size_info, |mut api| {
                // Iterate over all non-empty cells in the grid
                for cell in grid_cells {
                    // Update URL underlines
                    urls.update(size_info.cols().0, cell);
                    // Update underline/strikeout
                    lines.update(cell);
                    // Draw the cell
                    api.render_cell(cell, glyph_cache);
                }
            });
        }
        let mut rects = lines.rects(&metrics, &size_info);
        // Update visible URLs
        self.urls = urls;
        if let Some(url) = self.urls.highlighted(config, mouse, mods, mouse_mode, selection) {
            rects.append(&mut url.rects(&metrics, &size_info));
            self.window.set_mouse_cursor(CursorIcon::Hand);
            self.highlighted_url = Some(url);
        } else if self.highlighted_url.is_some() {
            self.highlighted_url = None;
            if mouse_mode {
                self.window.set_mouse_cursor(CursorIcon::Default);
            } else {
                self.window.set_mouse_cursor(CursorIcon::Text);
            }
        }
        // Push visual bell after url/underline/strikeout rects
        if visual_bell_intensity != 0. {
            let visual_bell_rect = RenderRect::new(
                0.,
                0.,
                size_info.width,
                size_info.height,
                config.visual_bell.color,
                visual_bell_intensity as f32,
            );
            rects.push(visual_bell_rect);
        }
        if let Some(message) = message_buffer.message() {
            let text = message.text(&size_info);
            // Create a new rectangle for the background
            let start_line = size_info.lines().0 - text.len();
            let y = size_info.cell_height.mul_add(start_line as f32, size_info.padding_y);
            let message_bar_rect =
                RenderRect::new(0., y, size_info.width, size_info.height - y, message.color(), 1.);
            // Push message_bar in the end, so it'll be above all other content
            rects.push(message_bar_rect);
            // Draw rectangles
            self.renderer.draw_rects(&size_info, rects);
            // Relay messages to the user
            let mut offset = 1;
            for message_text in text.iter().rev() {
                self.renderer.with_api(&config, &size_info, |mut api| {
                    api.render_string(
                        &message_text,
                        Line(size_info.lines().saturating_sub(offset)),
                        glyph_cache,
                        None,
                    );
                });
                offset += 1;
            }
        } else {
            // Draw rectangles
            self.renderer.draw_rects(&size_info, rects);
        }
        // Draw render timer
        if config.render_timer() {
            let timing = format!("{:.3} usec", self.meter.average());
            let color = Rgb { r: 0xd5, g: 0x4e, b: 0x53 };
            self.renderer.with_api(&config, &size_info, |mut api| {
                api.render_string(&timing[..], size_info.lines() - 2, glyph_cache, Some(color));
            });
        }
        self.window.swap_buffers();
    }
pub fn draw < T > ( & mut self , terminal : MutexGuard < ' _ , Term < T > > , message_buffer : & MessageBuffer , config : & Config , mouse : & Mouse , mods : ModifiersState , ) { let grid_cells : Vec < RenderableCell > = terminal . renderable_cells ( config ) . collect ( ) ; let visual_bell_intensity = terminal . visual_bell . intensity ( ) ; let background_color = terminal . background_color ( ) ; let metrics = self . glyph_cache . font_metrics ( ) ; let glyph_cache = & mut self . glyph_cache ; let size_info = self . size_info ; let selection = ! terminal . selection ( ) . as_ref ( ) . map ( Selection :: is_empty ) . unwrap_or ( true ) ; let mouse_mode = terminal . mode ( ) . intersects ( TermMode :: MOUSE_MODE ) ; // Update IME position # [ cfg ( not ( windows ) ) ] self . window . update_ime_position ( & terminal , & self . size_info ) ; // Drop terminal as early as possible to free lock drop ( terminal ) ; self . renderer . with_api ( & config , & size_info , | api | { api . clear ( background_color ) ; } ) ; let mut lines = RenderLines :: new ( ) ; let mut urls = Urls :: new ( ) ; // Draw grid { let _sampler = self . meter . sampler ( ) ; self . renderer . with_api ( & config , & size_info , | mut api | { // Iterate over all non-empty cells in the grid for cell in grid_cells { // Update URL underlines urls . update ( size_info . cols ( ) . 0 , cell ) ; // Update underline/strikeout lines . update ( cell ) ; // Draw the cell api . render_cell ( cell , glyph_cache ) ; } } ) ; } let mut rects = lines . rects ( & metrics , & size_info ) ; // Update visible URLs self . urls = urls ; if let Some ( url ) = self . urls . highlighted ( config , mouse , mods , mouse_mode , selection ) { rects . append ( & mut url . rects ( & metrics , & size_info ) ) ; self . window . set_mouse_cursor ( CursorIcon :: Hand ) ; self . highlighted_url = Some ( url ) ; } else if self . highlighted_url . is_some ( ) { self . highlighted_url = None ; if mouse_mode { self . window . set_mouse_cursor ( CursorIcon :: Default ) ; } else { self . window . set_mouse_cursor ( CursorIcon :: Text ) ; } } // Push visual bell after url/underline/strikeout rects if visual_bell_intensity != 0. { let visual_bell_rect = RenderRect :: new ( 0. , 0. , size_info . width , size_info . height , config . visual_bell . color , visual_bell_intensity as f32 , ) ; rects . push ( visual_bell_rect ) ; } if let Some ( message ) = message_buffer . message ( ) { let text = message . text ( & size_info ) ; // Create a new rectangle for the background let start_line = size_info . lines ( ) . 0 - text . len ( ) ; let y = size_info . cell_height . mul_add ( start_line as f32 , size_info . padding_y ) ; let message_bar_rect = RenderRect :: new ( 0. , y , size_info . width , size_info . height - y , message . color ( ) , 1. ) ; // Push message_bar in the end, so it'll be above all other content rects . push ( message_bar_rect ) ; // Draw rectangles self . renderer . draw_rects ( & size_info , rects ) ; // Relay messages to the user let mut offset = 1 ; for message_text in text . iter ( ) . rev ( ) { self . renderer . with_api ( & config , & size_info , | mut api | { api . render_string ( & message_text , Line ( size_info . lines ( ) . saturating_sub ( offset ) ) , glyph_cache , None , ) ; } ) ; offset += 1 ; } } else { // Draw rectangles self . renderer . draw_rects ( & size_info , rects ) ; } // Draw render timer if config . render_timer ( ) { let timing = format ! ( " " self meter average ( ) ) ; let color = Rgb { r : 0xd5 , g : 0x4e , b : 0x53 } ; self . renderer . with_api ( & config , & size_info , | mut api | { api . render_string ( & timing [ .. ] , size_info . lines ( ) - 2 , glyph_cache , Some ( color ) ) ; } ) ; } self . window . swap_buffers ( ) ; }
Draw the screen
A reference to Term whose state is being drawn must be provided.
Draw the screen A reference to Term whose state is being drawn must be provided .
&mut self
terminal
MutexGuard<'_, Term<T>>
message_buffer
&MessageBuffer
config
&Config
mouse
&Mouse
mods
ModifiersState
&mut self
terminal
MutexGuard<'_, Term<T>>
message_buffer
&MessageBuffer
config
&Config
mouse
&Mouse
mods
ModifiersState