[][src]Struct titik::InputBuffer

pub struct InputBuffer { /* fields omitted */ }

Input buffer is a 1 dimensional text buffer. It process keystroke and create a string representation depending on each key added to it. If arrow key (ie. left, right) is pressed the cursor location will be changed 1 cell backward/forward with respect to the key being pressed. If backspace stroke is receive, the left most cell relative to the cursor will be remove and all the elements on the right side will be shifted to the left.

TODO: deal with character that spans more than 1 cell

Implementations

impl InputBuffer[src]

pub fn new() -> Self[src]

create a new input buffer

pub fn new_with_value<S: ToString>(value: S) -> Self[src]

create an instance of this input buffer with the buffer content set to value.

pub fn get_content(&self) -> &str[src]

return the content of the buffer

pub fn get_cursor_location(&self) -> usize[src]

return the cursor location of the buffer

pub fn set_cursor_loc(&mut self, x: usize)[src]

set the cursor location on this buffer

pub fn process_key_event(
    &mut self,
    KeyEvent { code: code, modifiers: _ }: KeyEvent
)
[src]

Process key events

Keys to be processed:

  • Left
  • Right
  • Home
  • End
  • Delete
  • Backspace
  • Char(char)

Trait Implementations

impl Clone for InputBuffer[src]

impl Debug for InputBuffer[src]

impl Default for InputBuffer[src]

impl PartialEq<InputBuffer> for InputBuffer[src]

impl StructuralPartialEq for InputBuffer[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.