CodeEditor

Struct CodeEditor 

Source
pub struct CodeEditor {
    pub font_size: f32,
    pub cursor_pos: (usize, usize),
    pub cursor_rect: (usize, usize, usize, usize),
    pub mode: CodeEditorMode,
    pub theme: Theme,
    pub settings: Settings,
    pub drag_pos: Option<(usize, usize)>,
    /* private fields */
}

Fields§

§font_size: f32§cursor_pos: (usize, usize)§cursor_rect: (usize, usize, usize, usize)§mode: CodeEditorMode§theme: Theme§settings: Settings§drag_pos: Option<(usize, usize)>

Implementations§

Source§

impl CodeEditor

Source

pub fn new() -> Self
where Self: Sized,

Source

pub fn set_font(&mut self, path: &str)

Sets the path to the font file

Source

pub fn set_font_data(&mut self, font: Font)

Sets the font directly

Source

pub fn set_font_size(&mut self, font_size: f32)

Sets the font size

Source

pub fn set_text(&mut self, text: String)

Set the text / code to be edited

Source

pub fn get_text(&mut self) -> String

Returns the edited text

Source

pub fn set_theme(&mut self, theme: Theme)

Source

pub fn set_error(&mut self, error: Option<(String, Option<usize>)>)

Source

pub fn set_mode(&mut self, mode: CodeEditorMode)

Sets the mode of the editor

Source

pub fn draw( &mut self, frame: &mut [u8], rect: (usize, usize, usize, usize), stride: usize, )

Source

pub fn set_cursor(&mut self, pos: (usize, usize))

Sets the cursor to the given position

Source

pub fn key_down(&mut self, char: Option<char>, key: Option<WidgetKey>) -> bool

Source

pub fn mouse_down(&mut self, p: (usize, usize)) -> bool

Source

pub fn mouse_up(&mut self, _pos: (usize, usize)) -> bool

Source

pub fn mouse_dragged(&mut self, pos: (usize, usize)) -> bool

Source

pub fn mouse_hover(&mut self, _pos: (usize, usize)) -> bool

Source

pub fn mouse_wheel(&mut self, delta: (isize, isize)) -> bool

Source

pub fn offset_sanity_check(&mut self)

Makes sure that the offset is within a reasonable range.

Source

pub fn modifier_changed( &mut self, shift: bool, ctrl: bool, alt: bool, logo: bool, ) -> bool

Source

pub fn cut(&mut self) -> String

Cut

Source

pub fn copy(&mut self) -> String

Copy

Source

pub fn paste(&mut self, text: String)

Paste

Source

pub fn has_undo(&self) -> bool

Has Undo

Source

pub fn has_redo(&self) -> bool

Has Redo

Source

pub fn undo(&mut self)

Undo

Source

pub fn redo(&mut self)

Redo

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.