Repository: alacritty/alacritty
File: alacritty_terminal/src/term/mod.rs (Rust)

Code before:
                                cell.bg
                            },
                            _ => self.cursor.text_color.color(cell.fg, cell.bg),
                        };
                    }

                    return Some(cell);
                } else {
                    // Handle cursor.
                    self.cursor.rendered = true;

                    let buffer_point = self.grid.visible_to_buffer(self.cursor.point);
                    let cell = Indexed {
                        inner: self.grid[buffer_point.line][buffer_point.col],
                        column: self.cursor.point.col,
                        line: self.cursor.point.line,
                    };

                    let mut cell = RenderableCell::new(self, cell);
                    cell.inner = RenderableCellContent::Cursor(self.cursor.key);

                    // Only apply static color if it isn't close to the cell's current
                    // background or refers to cell colors.
                    match self.cursor.cursor_color {
                        CellRgb::Rgb(color) if color.contrast(cell.bg) < MIN_CURSOR_CONTRAST => (),
                        _ => cell.fg = self.cursor.cursor_color.color(cell.fg, cell.bg),
                    }

                    return Some(cell);
                }
            } else {
                let cell = self.inner.next()?;
                let cell = RenderableCell::new(self, cell);

                if !cell.is_empty() {
                    return Some(cell);
                }
            }
        }
    }
}

pub mod mode {
    use bitflags::bitflags;

    bitflags! {
        pub struct TermMode: u32 {
            const NONE                = 0;
            const SHOW_CURSOR         = 0b0000_0000_0000_0000_0001;
            const APP_CURSOR          = 0b0000_0000_0000_0000_0010;
            const APP_KEYPAD          = 0b0000_0000_0000_0000_0100;

Review comment (suggestion):
I think the following would be better, it requires 1.42.0 though. But chances are that's fine for 0.6.0?

```suggestion
                    if !matches!(self.cursor.cursor_color, CellRgb::Rgb(color) if color.contrast(cell.bg) < MIN_CURSOR_CONTRAST) {
                        cell.fg = self.cursor.cursor_color.color(cell.fg, cell.bg);
```

Code after:
                                cell.bg
                            },
                            _ => self.cursor.text_color.color(cell.fg, cell.bg),
                        };
                    }

                    return Some(cell);
                } else {
                    // Handle cursor.
                    self.cursor.rendered = true;

                    let buffer_point = self.grid.visible_to_buffer(self.cursor.point);
                    let cell = Indexed {
                        inner: self.grid[buffer_point.line][buffer_point.col],
                        column: self.cursor.point.col,
                        line: self.cursor.point.line,
                    };

                    let mut cell = RenderableCell::new(self, cell);
                    cell.inner = RenderableCellContent::Cursor(self.cursor.key);

                    // Apply cursor color, or invert the cursor if it has a fixed background close
                    // to the cell's background.
                    match self.cursor.cursor_color {
                        CellRgb::Rgb(color) if color.contrast(cell.bg) < MIN_CURSOR_CONTRAST => (),
                        _ => cell.fg = self.cursor.cursor_color.color(cell.fg, cell.bg),
                    }

                    return Some(cell);
                }
            } else {
                let cell = self.inner.next()?;
                let cell = RenderableCell::new(self, cell);

                if !cell.is_empty() {
                    return Some(cell);
                }
            }
        }
    }
}

pub mod mode {
    use bitflags::bitflags;

    bitflags! {
        pub struct TermMode: u32 {
            const NONE                = 0;
            const SHOW_CURSOR         = 0b0000_0000_0000_0000_0001;
            const APP_CURSOR          = 0b0000_0000_0000_0000_0010;
            const APP_KEYPAD          = 0b0000_0000_0000_0000_0100;