Only accept +/= for resize if ctrl is pressed
This commit is contained in:
parent
08d5069327
commit
1651c4f792
1 changed files with 15 additions and 11 deletions
|
|
@ -105,6 +105,7 @@ fn main() {
|
||||||
window.width() as i32 - line_x * 2,
|
window.width() as i32 - line_x * 2,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
let mut ctrl_pressed = false;
|
||||||
let mut mouse_x = -1;
|
let mut mouse_x = -1;
|
||||||
let mut mouse_y = -1;
|
let mut mouse_y = -1;
|
||||||
let mut mouse_left = false;
|
let mut mouse_left = false;
|
||||||
|
|
@ -221,30 +222,33 @@ fn main() {
|
||||||
|
|
||||||
for event in window.events() {
|
for event in window.events() {
|
||||||
match event.to_option() {
|
match event.to_option() {
|
||||||
EventOption::Key(event) => if event.pressed {
|
EventOption::Key(event) => {
|
||||||
match event.scancode {
|
match event.scancode {
|
||||||
orbclient::K_LEFT => buffer.action(TextAction::Left),
|
orbclient::K_CTRL => ctrl_pressed = event.pressed,
|
||||||
orbclient::K_RIGHT => buffer.action(TextAction::Right),
|
orbclient::K_LEFT if event.pressed => buffer.action(TextAction::Left),
|
||||||
orbclient::K_UP => buffer.action(TextAction::Up),
|
orbclient::K_RIGHT if event.pressed => buffer.action(TextAction::Right),
|
||||||
orbclient::K_DOWN => buffer.action(TextAction::Down),
|
orbclient::K_UP if event.pressed => buffer.action(TextAction::Up),
|
||||||
orbclient::K_BKSP => buffer.action(TextAction::Backspace),
|
orbclient::K_DOWN if event.pressed => buffer.action(TextAction::Down),
|
||||||
orbclient::K_DEL => buffer.action(TextAction::Delete),
|
orbclient::K_BKSP if event.pressed => buffer.action(TextAction::Backspace),
|
||||||
orbclient::K_0 => {
|
orbclient::K_DEL if event.pressed => buffer.action(TextAction::Delete),
|
||||||
|
orbclient::K_0 if event.pressed && ctrl_pressed => {
|
||||||
font_size_i = font_size_default;
|
font_size_i = font_size_default;
|
||||||
buffer.set_font_size(font_sizes[font_size_i].0 * display_scale);
|
buffer.set_font_size(font_sizes[font_size_i].0 * display_scale);
|
||||||
},
|
},
|
||||||
orbclient::K_MINUS => if font_size_i > 0 {
|
orbclient::K_MINUS if event.pressed && ctrl_pressed => if font_size_i > 0 {
|
||||||
font_size_i -= 1;
|
font_size_i -= 1;
|
||||||
buffer.set_font_size(font_sizes[font_size_i].0 * display_scale);
|
buffer.set_font_size(font_sizes[font_size_i].0 * display_scale);
|
||||||
},
|
},
|
||||||
orbclient::K_EQUALS => if font_size_i + 1 < font_sizes.len() {
|
orbclient::K_EQUALS if event.pressed && ctrl_pressed => if font_size_i + 1 < font_sizes.len() {
|
||||||
font_size_i += 1;
|
font_size_i += 1;
|
||||||
buffer.set_font_size(font_sizes[font_size_i].0 * display_scale);
|
buffer.set_font_size(font_sizes[font_size_i].0 * display_scale);
|
||||||
},
|
},
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
EventOption::TextInput(event) => buffer.action(TextAction::Insert(event.character)),
|
EventOption::TextInput(event) if ! ctrl_pressed => {
|
||||||
|
buffer.action(TextAction::Insert(event.character));
|
||||||
|
},
|
||||||
EventOption::Mouse(event) => {
|
EventOption::Mouse(event) => {
|
||||||
mouse_x = event.x;
|
mouse_x = event.x;
|
||||||
mouse_y = event.y;
|
mouse_y = event.y;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue