Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/libgtk2ui/gtk2_key_bindings_handler.h" | 5 #include "chrome/browser/ui/libgtk2ui/gtk2_key_bindings_handler.h" |
| 6 | 6 |
| 7 #include <gdk/gdkkeysyms.h> | 7 #include <gdk/gdkkeysyms.h> |
| 8 #include <X11/Xlib.h> | 8 #include <X11/Xlib.h> |
| 9 #include <stddef.h> | 9 #include <stddef.h> |
| 10 #include <X11/XKBlib.h> | 10 #include <X11/XKBlib.h> |
| 11 | 11 |
| 12 #include <string> | 12 #include <string> |
| 13 | 13 |
| 14 #include "base/logging.h" | 14 #include "base/logging.h" |
| 15 #include "base/macros.h" | 15 #include "base/macros.h" |
| 16 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" |
| 17 #include "chrome/browser/ui/libgtk2ui/gtk2_util.h" | 17 #include "chrome/browser/ui/libgtk2ui/gtk2_util.h" |
| 18 #include "content/public/browser/native_web_keyboard_event.h" | 18 #include "content/public/browser/native_web_keyboard_event.h" |
| 19 #include "ui/base/x/x11_util.h" | 19 #include "ui/base/x/x11_util.h" |
| 20 #include "ui/events/event.h" | 20 #include "ui/events/event.h" |
| 21 #include "ui/events/text_edit_commands.h" | |
| 21 | 22 |
| 22 using ui::TextEditCommandAuraLinux; | 23 using ui::TextEditCommand; |
| 23 | 24 |
| 24 // TODO(erg): Rewrite the old gtk_key_bindings_handler_unittest.cc and get them | 25 // TODO(erg): Rewrite the old gtk_key_bindings_handler_unittest.cc and get them |
| 25 // in a state that links. This code was adapted from the content layer GTK | 26 // in a state that links. This code was adapted from the content layer GTK |
| 26 // code, which had some simple unit tests. However, the changes in the public | 27 // code, which had some simple unit tests. However, the changes in the public |
| 27 // interface basically meant the tests need to be rewritten; this imposes weird | 28 // interface basically meant the tests need to be rewritten; this imposes weird |
| 28 // linking requirements regarding GTK+ as we don't have a libgtk2ui_unittests | 29 // linking requirements regarding GTK+ as we don't have a libgtk2ui_unittests |
| 29 // yet. http://crbug.com/358297. | 30 // yet. http://crbug.com/358297. |
| 30 | 31 |
| 31 namespace libgtk2ui { | 32 namespace libgtk2ui { |
| 32 | 33 |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 43 &major, &minor); | 44 &major, &minor); |
| 44 } | 45 } |
| 45 | 46 |
| 46 Gtk2KeyBindingsHandler::~Gtk2KeyBindingsHandler() { | 47 Gtk2KeyBindingsHandler::~Gtk2KeyBindingsHandler() { |
| 47 gtk_widget_destroy(handler_); | 48 gtk_widget_destroy(handler_); |
| 48 gtk_widget_destroy(fake_window_); | 49 gtk_widget_destroy(fake_window_); |
| 49 } | 50 } |
| 50 | 51 |
| 51 bool Gtk2KeyBindingsHandler::MatchEvent( | 52 bool Gtk2KeyBindingsHandler::MatchEvent( |
| 52 const ui::Event& event, | 53 const ui::Event& event, |
| 53 std::vector<TextEditCommandAuraLinux>* edit_commands) { | 54 std::vector<ui::TextEditCommandAuraLinux>* edit_commands) { |
| 54 CHECK(event.IsKeyEvent()); | 55 CHECK(event.IsKeyEvent()); |
| 55 | 56 |
| 56 const ui::KeyEvent& key_event = static_cast<const ui::KeyEvent&>(event); | 57 const ui::KeyEvent& key_event = static_cast<const ui::KeyEvent&>(event); |
| 57 if (key_event.is_char() || !key_event.native_event()) | 58 if (key_event.is_char() || !key_event.native_event()) |
| 58 return false; | 59 return false; |
| 59 | 60 |
| 60 GdkEventKey gdk_event; | 61 GdkEventKey gdk_event; |
| 61 BuildGdkEventKeyFromXEvent(key_event.native_event(), &gdk_event); | 62 BuildGdkEventKeyFromXEvent(key_event.native_event(), &gdk_event); |
| 62 | 63 |
| 63 edit_commands_.clear(); | 64 edit_commands_.clear(); |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 89 gtk_widget_set_size_request(GTK_WIDGET(handler), 0, 0); | 90 gtk_widget_set_size_request(GTK_WIDGET(handler), 0, 0); |
| 90 | 91 |
| 91 // Prevents it from handling any events by itself. | 92 // Prevents it from handling any events by itself. |
| 92 gtk_widget_set_sensitive(GTK_WIDGET(handler), FALSE); | 93 gtk_widget_set_sensitive(GTK_WIDGET(handler), FALSE); |
| 93 gtk_widget_set_events(GTK_WIDGET(handler), 0); | 94 gtk_widget_set_events(GTK_WIDGET(handler), 0); |
| 94 gtk_widget_set_can_focus(GTK_WIDGET(handler), TRUE); | 95 gtk_widget_set_can_focus(GTK_WIDGET(handler), TRUE); |
| 95 | 96 |
| 96 return GTK_WIDGET(handler); | 97 return GTK_WIDGET(handler); |
| 97 } | 98 } |
| 98 | 99 |
| 99 void Gtk2KeyBindingsHandler::EditCommandMatched( | 100 void Gtk2KeyBindingsHandler::EditCommandMatched(TextEditCommand command, |
| 100 TextEditCommandAuraLinux::CommandId id, | 101 const std::string& value) { |
| 101 const std::string& value, | 102 edit_commands_.push_back(ui::TextEditCommandAuraLinux(command, value)); |
| 102 bool extend_selection) { | |
| 103 edit_commands_.push_back(TextEditCommandAuraLinux(id, | |
| 104 value, | |
| 105 extend_selection)); | |
| 106 } | 103 } |
| 107 | 104 |
| 108 void Gtk2KeyBindingsHandler::BuildGdkEventKeyFromXEvent( | 105 void Gtk2KeyBindingsHandler::BuildGdkEventKeyFromXEvent( |
| 109 const base::NativeEvent& xevent, | 106 const base::NativeEvent& xevent, |
| 110 GdkEventKey* gdk_event) { | 107 GdkEventKey* gdk_event) { |
| 111 GdkKeymap *keymap = gdk_keymap_get_for_display(gdk_display_get_default()); | 108 GdkKeymap *keymap = gdk_keymap_get_for_display(gdk_display_get_default()); |
| 112 GdkModifierType consumed, state; | 109 GdkModifierType consumed, state; |
| 113 | 110 |
| 114 gdk_event->type = xevent->xany.type == KeyPress ? | 111 gdk_event->type = xevent->xany.type == KeyPress ? |
| 115 GDK_KEY_PRESS : GDK_KEY_RELEASE; | 112 GDK_KEY_PRESS : GDK_KEY_RELEASE; |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 205 | 202 |
| 206 Gtk2KeyBindingsHandler* Gtk2KeyBindingsHandler::GetHandlerOwner( | 203 Gtk2KeyBindingsHandler* Gtk2KeyBindingsHandler::GetHandlerOwner( |
| 207 GtkTextView* text_view) { | 204 GtkTextView* text_view) { |
| 208 Handler* handler = G_TYPE_CHECK_INSTANCE_CAST( | 205 Handler* handler = G_TYPE_CHECK_INSTANCE_CAST( |
| 209 text_view, HandlerGetType(), Handler); | 206 text_view, HandlerGetType(), Handler); |
| 210 DCHECK(handler); | 207 DCHECK(handler); |
| 211 return handler->owner; | 208 return handler->owner; |
| 212 } | 209 } |
| 213 | 210 |
| 214 void Gtk2KeyBindingsHandler::BackSpace(GtkTextView* text_view) { | 211 void Gtk2KeyBindingsHandler::BackSpace(GtkTextView* text_view) { |
| 215 GetHandlerOwner(text_view) | 212 GetHandlerOwner(text_view)->EditCommandMatched( |
| 216 ->EditCommandMatched( | 213 TextEditCommand::DELETE_BACKWARD, std::string()); |
| 217 TextEditCommandAuraLinux::DELETE_BACKWARD, std::string(), false); | |
| 218 } | 214 } |
| 219 | 215 |
| 220 void Gtk2KeyBindingsHandler::CopyClipboard(GtkTextView* text_view) { | 216 void Gtk2KeyBindingsHandler::CopyClipboard(GtkTextView* text_view) { |
| 221 GetHandlerOwner(text_view)->EditCommandMatched( | 217 GetHandlerOwner(text_view)->EditCommandMatched(TextEditCommand::COPY, |
| 222 TextEditCommandAuraLinux::COPY, std::string(), false); | 218 std::string()); |
| 223 } | 219 } |
| 224 | 220 |
| 225 void Gtk2KeyBindingsHandler::CutClipboard(GtkTextView* text_view) { | 221 void Gtk2KeyBindingsHandler::CutClipboard(GtkTextView* text_view) { |
| 226 GetHandlerOwner(text_view)->EditCommandMatched( | 222 GetHandlerOwner(text_view)->EditCommandMatched(TextEditCommand::CUT, |
| 227 TextEditCommandAuraLinux::CUT, std::string(), false); | 223 std::string()); |
| 228 } | 224 } |
| 229 | 225 |
| 230 void Gtk2KeyBindingsHandler::DeleteFromCursor( | 226 void Gtk2KeyBindingsHandler::DeleteFromCursor( |
| 231 GtkTextView* text_view, GtkDeleteType type, gint count) { | 227 GtkTextView* text_view, GtkDeleteType type, gint count) { |
| 232 if (!count) | 228 if (!count) |
| 233 return; | 229 return; |
| 234 | 230 |
| 235 TextEditCommandAuraLinux::CommandId commands[2] = { | 231 TextEditCommand commands[2] = { |
| 236 TextEditCommandAuraLinux::INVALID_COMMAND, | 232 TextEditCommand::INVALID_COMMAND, TextEditCommand::INVALID_COMMAND, |
| 237 TextEditCommandAuraLinux::INVALID_COMMAND, | |
| 238 }; | 233 }; |
| 239 switch (type) { | 234 switch (type) { |
| 240 case GTK_DELETE_CHARS: | 235 case GTK_DELETE_CHARS: |
| 241 commands[0] = (count > 0 ? | 236 commands[0] = (count > 0 ? TextEditCommand::DELETE_FORWARD |
| 242 TextEditCommandAuraLinux::DELETE_FORWARD : | 237 : TextEditCommand::DELETE_BACKWARD); |
| 243 TextEditCommandAuraLinux::DELETE_BACKWARD); | |
| 244 break; | 238 break; |
| 245 case GTK_DELETE_WORD_ENDS: | 239 case GTK_DELETE_WORD_ENDS: |
| 246 commands[0] = (count > 0 ? | 240 commands[0] = (count > 0 ? TextEditCommand::DELETE_WORD_FORWARD |
| 247 TextEditCommandAuraLinux::DELETE_WORD_FORWARD : | 241 : TextEditCommand::DELETE_WORD_BACKWARD); |
| 248 TextEditCommandAuraLinux::DELETE_WORD_BACKWARD); | |
| 249 break; | 242 break; |
| 250 case GTK_DELETE_WORDS: | 243 case GTK_DELETE_WORDS: |
| 251 if (count > 0) { | 244 if (count > 0) { |
| 252 commands[0] = TextEditCommandAuraLinux::MOVE_WORD_FORWARD; | 245 commands[0] = TextEditCommand::MOVE_WORD_FORWARD; |
| 253 commands[1] = TextEditCommandAuraLinux::DELETE_WORD_BACKWARD; | 246 commands[1] = TextEditCommand::DELETE_WORD_BACKWARD; |
| 254 } else { | 247 } else { |
| 255 commands[0] = TextEditCommandAuraLinux::MOVE_WORD_BACKWARD; | 248 commands[0] = TextEditCommand::MOVE_WORD_BACKWARD; |
| 256 commands[1] = TextEditCommandAuraLinux::DELETE_WORD_FORWARD; | 249 commands[1] = TextEditCommand::DELETE_WORD_FORWARD; |
| 257 } | 250 } |
| 258 break; | 251 break; |
| 259 case GTK_DELETE_DISPLAY_LINES: | 252 case GTK_DELETE_DISPLAY_LINES: |
| 260 commands[0] = TextEditCommandAuraLinux::MOVE_TO_BEGINNING_OF_LINE; | 253 commands[0] = TextEditCommand::MOVE_TO_BEGINNING_OF_LINE; |
| 261 commands[1] = TextEditCommandAuraLinux::DELETE_TO_END_OF_LINE; | 254 commands[1] = TextEditCommand::DELETE_TO_END_OF_LINE; |
| 262 break; | 255 break; |
| 263 case GTK_DELETE_DISPLAY_LINE_ENDS: | 256 case GTK_DELETE_DISPLAY_LINE_ENDS: |
| 264 commands[0] = | 257 commands[0] = (count > 0 ? TextEditCommand::DELETE_TO_END_OF_LINE |
| 265 (count > 0 ? TextEditCommandAuraLinux::DELETE_TO_END_OF_LINE | 258 : TextEditCommand::DELETE_TO_BEGINNING_OF_LINE); |
| 266 : TextEditCommandAuraLinux::DELETE_TO_BEGINNING_OF_LINE); | |
| 267 break; | 259 break; |
| 268 case GTK_DELETE_PARAGRAPH_ENDS: | 260 case GTK_DELETE_PARAGRAPH_ENDS: |
| 269 commands[0] = | 261 commands[0] = |
| 270 (count > 0 | 262 (count > 0 ? TextEditCommand::DELETE_TO_END_OF_PARAGRAPH |
| 271 ? TextEditCommandAuraLinux::DELETE_TO_END_OF_PARAGRAPH | 263 : TextEditCommand::DELETE_TO_BEGINNING_OF_PARAGRAPH); |
| 272 : TextEditCommandAuraLinux::DELETE_TO_BEGINNING_OF_PARAGRAPH); | |
| 273 break; | 264 break; |
| 274 case GTK_DELETE_PARAGRAPHS: | 265 case GTK_DELETE_PARAGRAPHS: |
| 275 commands[0] = TextEditCommandAuraLinux::MOVE_TO_BEGINNING_OF_PARAGRAPH; | 266 commands[0] = TextEditCommand::MOVE_TO_BEGINNING_OF_PARAGRAPH; |
| 276 commands[1] = TextEditCommandAuraLinux::DELETE_TO_END_OF_PARAGRAPH; | 267 commands[1] = TextEditCommand::DELETE_TO_END_OF_PARAGRAPH; |
| 277 break; | 268 break; |
| 278 default: | 269 default: |
| 279 // GTK_DELETE_WHITESPACE has no corresponding editor command. | 270 // GTK_DELETE_WHITESPACE has no corresponding editor command. |
| 280 return; | 271 return; |
| 281 } | 272 } |
| 282 | 273 |
| 283 Gtk2KeyBindingsHandler* owner = GetHandlerOwner(text_view); | 274 Gtk2KeyBindingsHandler* owner = GetHandlerOwner(text_view); |
| 284 if (count < 0) | 275 if (count < 0) |
| 285 count = -count; | 276 count = -count; |
| 286 for (; count > 0; --count) { | 277 for (; count > 0; --count) { |
| 287 for (size_t i = 0; i < arraysize(commands); ++i) | 278 for (size_t i = 0; i < arraysize(commands); ++i) |
| 288 if (commands[i] != TextEditCommandAuraLinux::INVALID_COMMAND) | 279 if (commands[i] != TextEditCommand::INVALID_COMMAND) |
| 289 owner->EditCommandMatched(commands[i], std::string(), false); | 280 owner->EditCommandMatched(commands[i], std::string()); |
| 290 } | 281 } |
| 291 } | 282 } |
| 292 | 283 |
| 293 void Gtk2KeyBindingsHandler::InsertAtCursor(GtkTextView* text_view, | 284 void Gtk2KeyBindingsHandler::InsertAtCursor(GtkTextView* text_view, |
| 294 const gchar* str) { | 285 const gchar* str) { |
| 295 if (str && *str) | 286 if (str && *str) |
|
msw
2016/06/10 01:33:23
nit: add curlies
karandeepb
2016/06/15 08:13:34
Done.
| |
| 296 GetHandlerOwner(text_view)->EditCommandMatched( | 287 GetHandlerOwner(text_view)->EditCommandMatched(TextEditCommand::INSERT_TEXT, |
| 297 TextEditCommandAuraLinux::INSERT_TEXT, str, false); | 288 str); |
| 298 } | 289 } |
| 299 | 290 |
| 300 void Gtk2KeyBindingsHandler::MoveCursor( | 291 void Gtk2KeyBindingsHandler::MoveCursor( |
| 301 GtkTextView* text_view, GtkMovementStep step, gint count, | 292 GtkTextView* text_view, GtkMovementStep step, gint count, |
| 302 gboolean extend_selection) { | 293 gboolean extend_selection) { |
| 303 if (!count) | 294 if (!count) |
| 304 return; | 295 return; |
| 305 | 296 |
| 306 TextEditCommandAuraLinux::CommandId command; | 297 TextEditCommand command; |
| 307 switch (step) { | 298 switch (step) { |
| 308 case GTK_MOVEMENT_LOGICAL_POSITIONS: | 299 case GTK_MOVEMENT_LOGICAL_POSITIONS: |
| 309 command = (count > 0 ? | 300 if (extend_selection) { |
| 310 TextEditCommandAuraLinux::MOVE_FORWARD : | 301 command = |
| 311 TextEditCommandAuraLinux::MOVE_BACKWARD); | 302 (count > 0 ? TextEditCommand::MOVE_FORWARD_AND_MODIFY_SELECTION |
| 303 : TextEditCommand::MOVE_BACKWARD_AND_MODIFY_SELECTION); | |
| 304 } else { | |
| 305 command = (count > 0 ? TextEditCommand::MOVE_FORWARD | |
| 306 : TextEditCommand::MOVE_BACKWARD); | |
| 307 } | |
| 312 break; | 308 break; |
| 313 case GTK_MOVEMENT_VISUAL_POSITIONS: | 309 case GTK_MOVEMENT_VISUAL_POSITIONS: |
| 314 command = (count > 0 ? | 310 if (extend_selection) { |
| 315 TextEditCommandAuraLinux::MOVE_RIGHT : | 311 command = (count > 0 ? TextEditCommand::MOVE_RIGHT_AND_MODIFY_SELECTION |
| 316 TextEditCommandAuraLinux::MOVE_LEFT); | 312 : TextEditCommand::MOVE_LEFT_AND_MODIFY_SELECTION); |
| 313 } else { | |
| 314 command = (count > 0 ? TextEditCommand::MOVE_RIGHT | |
| 315 : TextEditCommand::MOVE_LEFT); | |
| 316 } | |
| 317 break; | 317 break; |
| 318 case GTK_MOVEMENT_WORDS: | 318 case GTK_MOVEMENT_WORDS: |
| 319 command = (count > 0 ? | 319 if (extend_selection) { |
| 320 TextEditCommandAuraLinux::MOVE_WORD_RIGHT : | 320 command = |
| 321 TextEditCommandAuraLinux::MOVE_WORD_LEFT); | 321 (count > 0 ? TextEditCommand::MOVE_WORD_RIGHT_AND_MODIFY_SELECTION |
| 322 : TextEditCommand::MOVE_WORD_LEFT_AND_MODIFY_SELECTION); | |
| 323 } else { | |
| 324 command = (count > 0 ? TextEditCommand::MOVE_WORD_RIGHT | |
| 325 : TextEditCommand::MOVE_WORD_LEFT); | |
| 326 } | |
| 322 break; | 327 break; |
| 323 case GTK_MOVEMENT_DISPLAY_LINES: | 328 case GTK_MOVEMENT_DISPLAY_LINES: |
| 324 command = (count > 0 ? | 329 if (extend_selection) { |
| 325 TextEditCommandAuraLinux::MOVE_DOWN : | 330 command = (count > 0 ? TextEditCommand::MOVE_DOWN_AND_MODIFY_SELECTION |
| 326 TextEditCommandAuraLinux::MOVE_UP); | 331 : TextEditCommand::MOVE_UP_AND_MODIFY_SELECTION); |
| 332 } else { | |
| 333 command = | |
| 334 (count > 0 ? TextEditCommand::MOVE_DOWN : TextEditCommand::MOVE_UP); | |
| 335 } | |
| 327 break; | 336 break; |
| 328 case GTK_MOVEMENT_DISPLAY_LINE_ENDS: | 337 case GTK_MOVEMENT_DISPLAY_LINE_ENDS: |
| 329 command = | 338 if (extend_selection) { |
| 330 (count > 0 ? TextEditCommandAuraLinux::MOVE_TO_END_OF_LINE | 339 command = |
| 331 : TextEditCommandAuraLinux::MOVE_TO_BEGINNING_OF_LINE); | 340 (count > 0 |
| 341 ? TextEditCommand::MOVE_TO_END_OF_LINE_AND_MODIFY_SELECTION | |
| 342 : TextEditCommand:: | |
| 343 MOVE_TO_BEGINNING_OF_LINE_AND_MODIFY_SELECTION); | |
| 344 } else { | |
| 345 command = (count > 0 ? TextEditCommand::MOVE_TO_END_OF_LINE | |
| 346 : TextEditCommand::MOVE_TO_BEGINNING_OF_LINE); | |
| 347 } | |
| 332 break; | 348 break; |
| 333 case GTK_MOVEMENT_PARAGRAPH_ENDS: | 349 case GTK_MOVEMENT_PARAGRAPH_ENDS: |
| 334 command = | 350 if (extend_selection) { |
| 335 (count > 0 | 351 command = |
| 336 ? TextEditCommandAuraLinux::MOVE_TO_END_OF_PARAGRAPH | 352 (count > 0 |
| 337 : TextEditCommandAuraLinux::MOVE_TO_BEGINNING_OF_PARAGRAPH); | 353 ? TextEditCommand:: |
| 354 MOVE_TO_END_OF_PARAGRAPH_AND_MODIFY_SELECTION | |
| 355 : TextEditCommand:: | |
| 356 MOVE_TO_BEGINNING_OF_PARAGRAPH_AND_MODIFY_SELECTION); | |
| 357 } else { | |
| 358 command = (count > 0 ? TextEditCommand::MOVE_TO_END_OF_PARAGRAPH | |
| 359 : TextEditCommand::MOVE_TO_BEGINNING_OF_PARAGRAPH); | |
| 360 } | |
| 338 break; | 361 break; |
| 339 case GTK_MOVEMENT_PAGES: | 362 case GTK_MOVEMENT_PAGES: |
| 340 command = (count > 0 ? TextEditCommandAuraLinux::MOVE_PAGE_DOWN : | 363 if (extend_selection) { |
| 341 TextEditCommandAuraLinux::MOVE_PAGE_UP); | 364 command = |
| 365 (count > 0 ? TextEditCommand::MOVE_PAGE_DOWN_AND_MODIFY_SELECTION | |
| 366 : TextEditCommand::MOVE_PAGE_UP_AND_MODIFY_SELECTION); | |
| 367 } else { | |
| 368 command = (count > 0 ? TextEditCommand::MOVE_PAGE_DOWN | |
| 369 : TextEditCommand::MOVE_PAGE_UP); | |
| 370 } | |
| 342 break; | 371 break; |
| 343 case GTK_MOVEMENT_BUFFER_ENDS: | 372 case GTK_MOVEMENT_BUFFER_ENDS: |
| 344 command = | 373 if (extend_selection) { |
| 345 (count > 0 ? TextEditCommandAuraLinux::MOVE_TO_END_OF_DOCUMENT | 374 command = |
| 346 : TextEditCommandAuraLinux::MOVE_TO_BEGINNING_OF_DOCUMENT); | 375 (count > 0 |
| 376 ? TextEditCommand::MOVE_TO_END_OF_DOCUMENT_AND_MODIFY_SELECTION | |
| 377 : TextEditCommand:: | |
| 378 MOVE_TO_BEGINNING_OF_DOCUMENT_AND_MODIFY_SELECTION); | |
| 379 } else { | |
| 380 command = (count > 0 ? TextEditCommand::MOVE_TO_END_OF_DOCUMENT | |
| 381 : TextEditCommand::MOVE_TO_BEGINNING_OF_DOCUMENT); | |
| 382 } | |
| 347 break; | 383 break; |
| 348 default: | 384 default: |
| 349 // GTK_MOVEMENT_PARAGRAPHS and GTK_MOVEMENT_HORIZONTAL_PAGES have | 385 // GTK_MOVEMENT_PARAGRAPHS and GTK_MOVEMENT_HORIZONTAL_PAGES have |
| 350 // no corresponding editor commands. | 386 // no corresponding editor commands. |
| 351 return; | 387 return; |
| 352 } | 388 } |
| 353 | 389 |
| 354 Gtk2KeyBindingsHandler* owner = GetHandlerOwner(text_view); | 390 Gtk2KeyBindingsHandler* owner = GetHandlerOwner(text_view); |
| 355 if (count < 0) | 391 if (count < 0) |
| 356 count = -count; | 392 count = -count; |
| 357 for (; count > 0; --count) | 393 for (; count > 0; --count) |
| 358 owner->EditCommandMatched(command, std::string(), extend_selection); | 394 owner->EditCommandMatched(command, std::string()); |
| 359 } | 395 } |
| 360 | 396 |
| 361 void Gtk2KeyBindingsHandler::MoveViewport( | 397 void Gtk2KeyBindingsHandler::MoveViewport( |
| 362 GtkTextView* text_view, GtkScrollStep step, gint count) { | 398 GtkTextView* text_view, GtkScrollStep step, gint count) { |
| 363 // Not supported by webkit. | 399 // Not supported by webkit. |
| 364 } | 400 } |
| 365 | 401 |
| 366 void Gtk2KeyBindingsHandler::PasteClipboard(GtkTextView* text_view) { | 402 void Gtk2KeyBindingsHandler::PasteClipboard(GtkTextView* text_view) { |
| 367 GetHandlerOwner(text_view)->EditCommandMatched( | 403 GetHandlerOwner(text_view)->EditCommandMatched(TextEditCommand::PASTE, |
| 368 TextEditCommandAuraLinux::PASTE, std::string(), false); | 404 std::string()); |
| 369 } | 405 } |
| 370 | 406 |
| 371 void Gtk2KeyBindingsHandler::SelectAll(GtkTextView* text_view, | 407 void Gtk2KeyBindingsHandler::SelectAll(GtkTextView* text_view, |
| 372 gboolean select) { | 408 gboolean select) { |
| 373 if (select) { | 409 if (select) { |
| 374 GetHandlerOwner(text_view)->EditCommandMatched( | 410 GetHandlerOwner(text_view)->EditCommandMatched(TextEditCommand::SELECT_ALL, |
|
msw
2016/06/10 01:33:23
optional nit: GetHandlerOwner(text_view)->EditComm
karandeepb
2016/06/15 08:13:34
Done.
| |
| 375 TextEditCommandAuraLinux::SELECT_ALL, std::string(), false); | 411 std::string()); |
| 376 } else { | 412 } else { |
| 377 GetHandlerOwner(text_view)->EditCommandMatched( | 413 GetHandlerOwner(text_view)->EditCommandMatched(TextEditCommand::UNSELECT, |
| 378 TextEditCommandAuraLinux::UNSELECT, std::string(), false); | 414 std::string()); |
| 379 } | 415 } |
| 380 } | 416 } |
| 381 | 417 |
| 382 void Gtk2KeyBindingsHandler::SetAnchor(GtkTextView* text_view) { | 418 void Gtk2KeyBindingsHandler::SetAnchor(GtkTextView* text_view) { |
| 383 GetHandlerOwner(text_view)->EditCommandMatched( | 419 GetHandlerOwner(text_view)->EditCommandMatched(TextEditCommand::SET_MARK, |
| 384 TextEditCommandAuraLinux::SET_MARK, std::string(), false); | 420 std::string()); |
| 385 } | 421 } |
| 386 | 422 |
| 387 void Gtk2KeyBindingsHandler::ToggleCursorVisible(GtkTextView* text_view) { | 423 void Gtk2KeyBindingsHandler::ToggleCursorVisible(GtkTextView* text_view) { |
| 388 // Not supported by webkit. | 424 // Not supported by webkit. |
| 389 } | 425 } |
| 390 | 426 |
| 391 void Gtk2KeyBindingsHandler::ToggleOverwrite(GtkTextView* text_view) { | 427 void Gtk2KeyBindingsHandler::ToggleOverwrite(GtkTextView* text_view) { |
| 392 // Not supported by webkit. | 428 // Not supported by webkit. |
| 393 } | 429 } |
| 394 | 430 |
| 395 gboolean Gtk2KeyBindingsHandler::ShowHelp(GtkWidget* widget, | 431 gboolean Gtk2KeyBindingsHandler::ShowHelp(GtkWidget* widget, |
| 396 GtkWidgetHelpType arg1) { | 432 GtkWidgetHelpType arg1) { |
| 397 // Just for disabling the default handler. | 433 // Just for disabling the default handler. |
| 398 return FALSE; | 434 return FALSE; |
| 399 } | 435 } |
| 400 | 436 |
| 401 void Gtk2KeyBindingsHandler::MoveFocus(GtkWidget* widget, | 437 void Gtk2KeyBindingsHandler::MoveFocus(GtkWidget* widget, |
| 402 GtkDirectionType arg1) { | 438 GtkDirectionType arg1) { |
| 403 // Just for disabling the default handler. | 439 // Just for disabling the default handler. |
| 404 } | 440 } |
| 405 | 441 |
| 406 } // namespace libgtk2ui | 442 } // namespace libgtk2ui |
| OLD | NEW |