mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 07:57:47 +00:00
LibGUI: Add EngineType to EditingEngine classes
This will allow users of EditingEngine classes to determine current type of EditingEngine (currently either vim or regular).
This commit is contained in:
parent
c9062b4ed5
commit
fa94978a7e
3 changed files with 13 additions and 0 deletions
|
@ -17,6 +17,11 @@ enum CursorWidth {
|
||||||
WIDE
|
WIDE
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum EngineType {
|
||||||
|
Regular,
|
||||||
|
Vim,
|
||||||
|
};
|
||||||
|
|
||||||
class EditingEngine {
|
class EditingEngine {
|
||||||
AK_MAKE_NONCOPYABLE(EditingEngine);
|
AK_MAKE_NONCOPYABLE(EditingEngine);
|
||||||
AK_MAKE_NONMOVABLE(EditingEngine);
|
AK_MAKE_NONMOVABLE(EditingEngine);
|
||||||
|
@ -37,6 +42,9 @@ public:
|
||||||
|
|
||||||
virtual bool on_key(const KeyEvent& event);
|
virtual bool on_key(const KeyEvent& event);
|
||||||
|
|
||||||
|
bool is_regular() const { return engine_type() == EngineType::Regular; }
|
||||||
|
bool is_vim() const { return engine_type() == EngineType::Vim; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
EditingEngine() { }
|
EditingEngine() { }
|
||||||
|
|
||||||
|
@ -73,6 +81,8 @@ protected:
|
||||||
void delete_line();
|
void delete_line();
|
||||||
void delete_char();
|
void delete_char();
|
||||||
|
|
||||||
|
virtual EngineType engine_type() const = 0;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void move_selected_lines_up();
|
void move_selected_lines_up();
|
||||||
void move_selected_lines_down();
|
void move_selected_lines_down();
|
||||||
|
|
|
@ -19,6 +19,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void sort_selected_lines();
|
void sort_selected_lines();
|
||||||
|
virtual EngineType engine_type() const override { return EngineType::Regular; }
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -187,6 +187,8 @@ private:
|
||||||
bool on_key_in_insert_mode(const KeyEvent& event);
|
bool on_key_in_insert_mode(const KeyEvent& event);
|
||||||
bool on_key_in_normal_mode(const KeyEvent& event);
|
bool on_key_in_normal_mode(const KeyEvent& event);
|
||||||
bool on_key_in_visual_mode(const KeyEvent& event);
|
bool on_key_in_visual_mode(const KeyEvent& event);
|
||||||
|
|
||||||
|
virtual EngineType engine_type() const override { return EngineType::Vim; }
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue