aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/textinput.rs
diff options
context:
space:
mode:
authorbors-servo <metajack+bors@gmail.com>2014-12-17 18:45:49 -0700
committerbors-servo <metajack+bors@gmail.com>2014-12-17 18:45:49 -0700
commitfbf42c951b2f53d91e2f32f8035484a07ea83493 (patch)
tree1d7bfb30cbddebba633fe1f2c8844cf4133aabc1 /components/script/textinput.rs
parentb8900782b0fcb409f37189bdc08eb7f8b3564a5f (diff)
parent1a9be88a1d1f9138287f5b1ee04300b7e1bd7025 (diff)
downloadservo-fbf42c951b2f53d91e2f32f8035484a07ea83493.tar.gz
servo-fbf42c951b2f53d91e2f32f8035484a07ea83493.zip
auto merge of #4405 : servo/servo/rustup_20141124, r=jdm
Diffstat (limited to 'components/script/textinput.rs')
-rw-r--r--components/script/textinput.rs45
1 files changed, 25 insertions, 20 deletions
diff --git a/components/script/textinput.rs b/components/script/textinput.rs
index ed120aae943..843838933c2 100644
--- a/components/script/textinput.rs
+++ b/components/script/textinput.rs
@@ -11,6 +11,7 @@ use servo_util::str::DOMString;
use std::cmp::{min, max};
use std::default::Default;
+use std::num::SignedInt;
#[jstraceable]
struct TextPoint {
@@ -70,7 +71,7 @@ impl TextInput {
lines: vec!(),
edit_point: Default::default(),
selection_begin: None,
- multiline: lines == Multiple,
+ multiline: lines == Lines::Multiple,
};
i.set_content(initial);
i
@@ -79,7 +80,11 @@ impl TextInput {
/// Remove a character at the current editing point
fn delete_char(&mut self, dir: DeleteDir) {
if self.selection_begin.is_none() {
- self.adjust_horizontal(if dir == Forward {1} else {-1}, true);
+ self.adjust_horizontal(if dir == DeleteDir::Forward {
+ 1
+ } else {
+ -1
+ }, true);
}
self.replace_selection("".to_string());
}
@@ -210,10 +215,10 @@ impl TextInput {
/// Deal with a newline input.
fn handle_return(&mut self) -> KeyReaction {
if !self.multiline {
- return TriggerDefaultAction;
+ return KeyReaction::TriggerDefaultAction;
}
self.insert_char('\n');
- return DispatchInput;
+ return KeyReaction::DispatchInput;
}
/// Process a given `KeyboardEvent` and return an action for the caller to execute.
@@ -222,55 +227,55 @@ impl TextInput {
// printable characters have single-character key values
c if c.len() == 1 => {
self.insert_char(c.char_at(0));
- return DispatchInput;
+ return KeyReaction::DispatchInput;
}
"Space" => {
self.insert_char(' ');
- DispatchInput
+ KeyReaction::DispatchInput
}
"Delete" => {
- self.delete_char(Forward);
- DispatchInput
+ self.delete_char(DeleteDir::Forward);
+ KeyReaction::DispatchInput
}
"Backspace" => {
- self.delete_char(Backward);
- DispatchInput
+ self.delete_char(DeleteDir::Backward);
+ KeyReaction::DispatchInput
}
"ArrowLeft" => {
self.adjust_horizontal(-1, event.ShiftKey());
- Nothing
+ KeyReaction::Nothing
}
"ArrowRight" => {
self.adjust_horizontal(1, event.ShiftKey());
- Nothing
+ KeyReaction::Nothing
}
"ArrowUp" => {
self.adjust_vertical(-1, event.ShiftKey());
- Nothing
+ KeyReaction::Nothing
}
"ArrowDown" => {
self.adjust_vertical(1, event.ShiftKey());
- Nothing
+ KeyReaction::Nothing
}
"Enter" => self.handle_return(),
"Home" => {
self.edit_point.index = 0;
- Nothing
+ KeyReaction::Nothing
}
"End" => {
self.edit_point.index = self.current_line_length();
- Nothing
+ KeyReaction::Nothing
}
"PageUp" => {
self.adjust_vertical(-28, event.ShiftKey());
- Nothing
+ KeyReaction::Nothing
}
"PageDown" => {
self.adjust_vertical(28, event.ShiftKey());
- Nothing
+ KeyReaction::Nothing
}
- "Tab" => TriggerDefaultAction,
- _ => Nothing,
+ "Tab" => KeyReaction::TriggerDefaultAction,
+ _ => KeyReaction::Nothing,
}
}