Back to index

lightning-sunbird  0.9+nobinonly
Functions | Variables
nsNativeKeyBindings.cpp File Reference
#include "nsNativeKeyBindings.h"
#include "nsString.h"
#include "nsMemory.h"
#include "nsGtkKeyUtils.h"
#include <gtk/gtkentry.h>
#include <gtk/gtktextview.h>
#include <gtk/gtkbindings.h>
#include <gtk/gtkmain.h>
#include <gdk/gdkkeysyms.h>

Go to the source code of this file.

Functions

static void copy_clipboard_cb (GtkWidget *w, gpointer user_data)
static void cut_clipboard_cb (GtkWidget *w, gpointer user_data)
static void delete_from_cursor_cb (GtkWidget *w, GtkDeleteType del_type, gint count, gpointer user_data)
static void move_cursor_cb (GtkWidget *w, GtkMovementStep step, gint count, gboolean extend_selection, gpointer user_data)
static void paste_clipboard_cb (GtkWidget *w, gpointer user_data)
static void select_all_cb (GtkWidget *w, gboolean select, gpointer user_data)

Variables

static
nsINativeKeyBindings::DoCommandCallback 
gCurrentCallback
static voidgCurrentCallbackData
static PRBool gHandled
static const char *const sDeleteCommands [][2]
static const char *const sMoveCommands [][2][2]

Function Documentation

static void copy_clipboard_cb ( GtkWidget *  w,
gpointer  user_data 
) [static]

Definition at line 56 of file nsNativeKeyBindings.cpp.

{
  gCurrentCallback("cmd_copy", gCurrentCallbackData);
  g_signal_stop_emission_by_name(w, "copy_clipboard");
  gHandled = PR_TRUE;
}
static void cut_clipboard_cb ( GtkWidget *  w,
gpointer  user_data 
) [static]

Definition at line 64 of file nsNativeKeyBindings.cpp.

{
  gCurrentCallback("cmd_cut", gCurrentCallbackData);
  g_signal_stop_emission_by_name(w, "cut_clipboard");
  gHandled = PR_TRUE;
}
static void delete_from_cursor_cb ( GtkWidget *  w,
GtkDeleteType  del_type,
gint  count,
gpointer  user_data 
) [static]

Definition at line 92 of file nsNativeKeyBindings.cpp.

{
  g_signal_stop_emission_by_name(w, "delete_from_cursor");
  gHandled = PR_TRUE;

  PRBool forward = count > 0;
  if (PRUint32(del_type) >= NS_ARRAY_LENGTH(sDeleteCommands)) {
    // unsupported deletion type
    return;
  }

  if (del_type == GTK_DELETE_WORDS) {
    // This works like word_ends, except we first move the caret to the
    // beginning/end of the current word.
    if (forward) {
      gCurrentCallback("cmd_wordNext", gCurrentCallbackData);
      gCurrentCallback("cmd_wordPrevious", gCurrentCallbackData);
    } else {
      gCurrentCallback("cmd_wordPrevious", gCurrentCallbackData);
      gCurrentCallback("cmd_wordNext", gCurrentCallbackData);
    }
  } else if (del_type == GTK_DELETE_DISPLAY_LINES ||
             del_type == GTK_DELETE_PARAGRAPHS) {

    // This works like display_line_ends, except we first move the caret to the
    // beginning/end of the current line.
    if (forward) {
      gCurrentCallback("cmd_beginLine", gCurrentCallbackData);
    } else {
      gCurrentCallback("cmd_endLine", gCurrentCallbackData);
    }
  }

  const char *cmd = sDeleteCommands[del_type][forward];
  if (!cmd)
    return; // unsupported command

  count = PR_ABS(count);
  for (int i = 0; i < count; ++i) {
    gCurrentCallback(cmd, gCurrentCallbackData);
  }
}
static void move_cursor_cb ( GtkWidget *  w,
GtkMovementStep  step,
gint  count,
gboolean  extend_selection,
gpointer  user_data 
) [static]

Definition at line 184 of file nsNativeKeyBindings.cpp.

{
  g_signal_stop_emission_by_name(w, "move_cursor");
  gHandled = PR_TRUE;
  PRBool forward = count > 0;
  if (PRUint32(step) >= NS_ARRAY_LENGTH(sMoveCommands)) {
    // unsupported movement type
    return;
  }

  const char *cmd = sMoveCommands[step][extend_selection][forward];
  if (!cmd)
    return; // unsupported command

  
  count = PR_ABS(count);
  for (int i = 0; i < count; ++i) {
    gCurrentCallback(cmd, gCurrentCallbackData);
  }
}
static void paste_clipboard_cb ( GtkWidget *  w,
gpointer  user_data 
) [static]

Definition at line 207 of file nsNativeKeyBindings.cpp.

{
  gCurrentCallback("cmd_paste", gCurrentCallbackData);
  g_signal_stop_emission_by_name(w, "paste_clipboard");
  gHandled = PR_TRUE;
}
static void select_all_cb ( GtkWidget *  w,
gboolean  select,
gpointer  user_data 
) [static]

Definition at line 216 of file nsNativeKeyBindings.cpp.

{
  gCurrentCallback("cmd_selectAll", gCurrentCallbackData);
  g_signal_stop_emission_by_name(w, "select_all");
  gHandled = PR_TRUE;
}

Variable Documentation

Definition at line 50 of file nsNativeKeyBindings.cpp.

Definition at line 51 of file nsNativeKeyBindings.cpp.

PRBool gHandled [static]

Definition at line 52 of file nsNativeKeyBindings.cpp.

const char* const sDeleteCommands[][2] [static]
Initial value:
 {
  
  { "cmd_deleteCharBackward", "cmd_deleteCharForward" },    
  { "cmd_deleteWordBackward", "cmd_deleteWordForward" },    
  { "cmd_deleteWordBackward", "cmd_deleteWordForward" },    
  { "cmd_deleteToBeginningOfLine", "cmd_deleteToEndOfLine" }, 
  { "cmd_deleteToBeginningOfLine", "cmd_deleteToEndOfLine" }, 
  { "cmd_deleteToBeginningOfLine", "cmd_deleteToEndOfLine" }, 
  { "cmd_deleteToBeginningOfLine", "cmd_deleteToEndOfLine" }, 
  
  
  
  { nsnull, nsnull } 
}

Definition at line 76 of file nsNativeKeyBindings.cpp.

const char* const sMoveCommands[][2][2] [static]

Definition at line 136 of file nsNativeKeyBindings.cpp.