Gitweb links:

...log 
http://git.netsurf-browser.org/netsurf.git/shortlog/88d5ea866858506aae2ff2ecbdee2b4f960ab89f
...commit 
http://git.netsurf-browser.org/netsurf.git/commit/88d5ea866858506aae2ff2ecbdee2b4f960ab89f
...tree 
http://git.netsurf-browser.org/netsurf.git/tree/88d5ea866858506aae2ff2ecbdee2b4f960ab89f

The branch, master has been updated
       via  88d5ea866858506aae2ff2ecbdee2b4f960ab89f (commit)
       via  76ede0f7d6e24996a7b886389c57dd502a046454 (commit)
      from  9f305e4c3ba211834b194e5fac98089866c13d82 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commitdiff 
http://git.netsurf-browser.org/netsurf.git/commit/?id=88d5ea866858506aae2ff2ecbdee2b4f960ab89f
commit 88d5ea866858506aae2ff2ecbdee2b4f960ab89f
Author: Michael Drake <t...@netsurf-browser.org>
Commit: Michael Drake <t...@netsurf-browser.org>

    GTK: Add support for word delete left/right.
    
    These are ctrl+delete and ctrl+backspace.

diff --git a/frontends/gtk/gui.c b/frontends/gtk/gui.c
index a826b05..76bbd99 100644
--- a/frontends/gtk/gui.c
+++ b/frontends/gtk/gui.c
@@ -131,12 +131,16 @@ uint32_t gtk_gui_gdkkey_to_nskey(GdkEventKey *key)
        case GDK_KEY(BackSpace):
                if (key->state & GDK_SHIFT_MASK)
                        return NS_KEY_DELETE_LINE_START;
+               else if (key->state & GDK_CONTROL_MASK)
+                       return NS_KEY_DELETE_WORD_LEFT;
                else
                        return NS_KEY_DELETE_LEFT;
 
        case GDK_KEY(Delete):
                if (key->state & GDK_SHIFT_MASK)
                        return NS_KEY_DELETE_LINE_END;
+               else if (key->state & GDK_CONTROL_MASK)
+                       return NS_KEY_DELETE_WORD_RIGHT;
                else
                        return NS_KEY_DELETE_RIGHT;
 


commitdiff 
http://git.netsurf-browser.org/netsurf.git/commit/?id=76ede0f7d6e24996a7b886389c57dd502a046454
commit 76ede0f7d6e24996a7b886389c57dd502a046454
Author: Pranjal Kole <pranjal.ko...@gmail.com>
Commit: Michael Drake <t...@netsurf-browser.org>

    textarea: implement NS_KEY_DELETE_WORD_{LEFT,RIGHT}
    
    NS_KEY_DELETE_WORD_{LEFT,RIGHT} have been added to
    include/netsurf/keypress.h and implemented in desktop/textarea.c
    
    An unsigned int, caret_copy, has been added since both of these require
    a temporary variable to hold the original position of the caret.
    
    The LEFT one deletes separators towards the left till it encounters a
    non-separator and then deletes the non-separators until it encounters a
    separator. The caret is moved towards the left by the number of
    characters deleted.
    
    The RIGHT one does the same towards the right, but the caret is kept at
    its original position.
    
    These are intended to be mapped to Ctrl+Backspace and Ctrl+Delete by
    most frontends.
    
    Additionally, some style and typo fixes have been made.

diff --git a/desktop/textarea.c b/desktop/textarea.c
index 5bae27a..e25c633 100644
--- a/desktop/textarea.c
+++ b/desktop/textarea.c
@@ -58,7 +58,7 @@ struct line_info {
 struct textarea_drag {
        textarea_drag_type type;
        union {
-               struct scrollbar* scrollbar;
+               struct scrollbar *scrollbar;
        } data;
 };
 
@@ -625,7 +625,7 @@ static bool textarea_select(struct textarea *ta, int 
b_start, int b_end,
  * \param ta  Text area
  * \return True on success, false otherwise
  */
-static bool textarea_select_fragment(struct textarea * ta)
+static bool textarea_select_fragment(struct textarea *ta)
 {
        int caret_pos;
        size_t sel_start, sel_end;
@@ -676,7 +676,7 @@ static bool textarea_select_fragment(struct textarea * ta)
  * \param ta  textarea widget
  * \return True on success, false otherwise
  */
-static bool textarea_select_paragraph(struct textarea * ta)
+static bool textarea_select_paragraph(struct textarea *ta)
 {
        int caret_pos;
        size_t sel_start, sel_end;
@@ -1607,7 +1607,7 @@ static bool textarea_copy_to_undo_buffer(struct textarea 
*ta,
  * \param b_end                End byte index of replaced section (exclusive)
  * \param rep          Replacement UTF-8 text to insert
  * \param rep_len      Byte length of replacement UTF-8 text
- * \param add_to_clipboard     True iff replaced text to be added to clipboard
+ * \param add_to_clipboard     True if replaced text to be added to clipboard
  * \param byte_delta   Updated to change in byte count in textarea (ta->show)
  * \param r            Updated to area where redraw is required
  * \return false on memory exhaustion, true otherwise
@@ -2452,7 +2452,7 @@ bool textarea_keypress(struct textarea *ta, uint32_t key)
        struct textarea_msg msg;
        struct rect r;  /**< Redraw rectangle */
        char utf8[6];
-       unsigned int caret, length, b_off, b_len;
+       unsigned int caret, caret_copy, length, b_off, b_len;
        int h_extent = ta->h_extent;
        int v_extent = ta->v_extent;
        int line;
@@ -2466,7 +2466,7 @@ bool textarea_keypress(struct textarea *ta, uint32_t key)
        /* Word separators */
        static const char *sep = " .\n";
 
-       caret = textarea_get_caret(ta);
+       caret = caret_copy = textarea_get_caret(ta);
        line = ta->caret_pos.line;
        readonly = (ta->flags & TEXTAREA_READONLY ? true : false);
 
@@ -2760,6 +2760,50 @@ bool textarea_keypress(struct textarea *ta, uint32_t key)
                                textarea_clear_selection(ta);
                        }
                        break;
+               case NS_KEY_DELETE_WORD_LEFT:
+                       if (readonly)
+                               break;
+
+                       /* If there is a selection, remove the selected
+                       * characters */
+                       if (ta->sel_start != -1) {
+                               if (!textarea_replace_text(ta, ta->sel_start,
+                                               ta->sel_end, "", 0, false,
+                                               &byte_delta, &r))
+                                       return false;
+                               caret = ta->sel_start;
+                               textarea_clear_selection(ta);
+                               redraw = true;
+                               break;
+                       }
+
+                       if (caret == 0)
+                               break;
+
+                       /* caret goes left until a non-separator is
+                       * encountered */
+                       caret--;
+                       while (strchr(sep, ta->show->data[caret]) != NULL &&
+                                       caret > 0)
+                               caret--;
+
+                       /* caret goes left until a separator is encountered */
+                       for (; caret > 0; caret--) {
+                               if (strchr(sep, ta->show->data[caret]) !=
+                                               NULL) {
+                                       caret++;
+                                       break;
+                               }
+                       }
+
+                       /* Remove the characters from new caret position to
+                       * original caret position */
+                       if (!textarea_replace_text(ta, caret, caret_copy,
+                                       "", 0, false, &byte_delta, &r))
+                               return false;
+
+                       redraw = true;
+                       break;
                case NS_KEY_WORD_RIGHT:
                        if (readonly)
                                break;
@@ -2783,6 +2827,49 @@ bool textarea_keypress(struct textarea *ta, uint32_t key)
                                textarea_clear_selection(ta);
                        }
                        break;
+               case NS_KEY_DELETE_WORD_RIGHT:
+                       if (readonly)
+                               break;
+
+                       /* If there is a selection, remove the selected
+                       * characters */
+                       if (ta->sel_start != -1) {
+                               if (!textarea_replace_text(ta, ta->sel_start,
+                                               ta->sel_end, "", 0, false,
+                                               &byte_delta, &r))
+                                       return false;
+                               caret = ta->sel_start;
+                               textarea_clear_selection(ta);
+                               redraw = true;
+                               break;
+                       }
+
+                       if (caret == ta->show->len - 1)
+                               break;
+
+                       /* caret_copy goes right until a non-separator is
+                       * encountered */
+                       while (strchr(sep, ta->show->data[caret_copy]) != NULL
+                                       && caret_copy < ta->show->len - 1)
+                               caret_copy++;
+
+                       /* caret_copy goes right until a separator is
+                       * encountered */
+                       for (; caret_copy < ta->show->len - 1; caret_copy++) {
+                               if (strchr(sep, ta->show->data[caret_copy]) !=
+                                               NULL) {
+                                       break;
+                               }
+                       }
+
+                       /* Remove all the characters from original caret
+                       * position to caret_copy */
+                       if (!textarea_replace_text(ta, caret, caret_copy,
+                                       "", 0, false, &byte_delta, &r))
+                               return false;
+
+                       redraw = true;
+                       break;
                case NS_KEY_DELETE_LINE:
                        if (readonly)
                                break;
diff --git a/include/netsurf/keypress.h b/include/netsurf/keypress.h
index 604d2dd..84d9d41 100644
--- a/include/netsurf/keypress.h
+++ b/include/netsurf/keypress.h
@@ -59,7 +59,9 @@ enum input_key {
        NS_KEY_TEXT_START,
        NS_KEY_TEXT_END,
        NS_KEY_WORD_LEFT,
+       NS_KEY_DELETE_WORD_LEFT,
        NS_KEY_WORD_RIGHT,
+       NS_KEY_DELETE_WORD_RIGHT,
        NS_KEY_PAGE_UP,
        NS_KEY_PAGE_DOWN,
        NS_KEY_DELETE_LINE_END,


-----------------------------------------------------------------------

Summary of changes:
 desktop/textarea.c         |   99 +++++++++++++++++++++++++++++++++++++++++---
 frontends/gtk/gui.c        |    4 ++
 include/netsurf/keypress.h |    2 +
 3 files changed, 99 insertions(+), 6 deletions(-)

diff --git a/desktop/textarea.c b/desktop/textarea.c
index 5bae27a..e25c633 100644
--- a/desktop/textarea.c
+++ b/desktop/textarea.c
@@ -58,7 +58,7 @@ struct line_info {
 struct textarea_drag {
        textarea_drag_type type;
        union {
-               struct scrollbar* scrollbar;
+               struct scrollbar *scrollbar;
        } data;
 };
 
@@ -625,7 +625,7 @@ static bool textarea_select(struct textarea *ta, int 
b_start, int b_end,
  * \param ta  Text area
  * \return True on success, false otherwise
  */
-static bool textarea_select_fragment(struct textarea * ta)
+static bool textarea_select_fragment(struct textarea *ta)
 {
        int caret_pos;
        size_t sel_start, sel_end;
@@ -676,7 +676,7 @@ static bool textarea_select_fragment(struct textarea * ta)
  * \param ta  textarea widget
  * \return True on success, false otherwise
  */
-static bool textarea_select_paragraph(struct textarea * ta)
+static bool textarea_select_paragraph(struct textarea *ta)
 {
        int caret_pos;
        size_t sel_start, sel_end;
@@ -1607,7 +1607,7 @@ static bool textarea_copy_to_undo_buffer(struct textarea 
*ta,
  * \param b_end                End byte index of replaced section (exclusive)
  * \param rep          Replacement UTF-8 text to insert
  * \param rep_len      Byte length of replacement UTF-8 text
- * \param add_to_clipboard     True iff replaced text to be added to clipboard
+ * \param add_to_clipboard     True if replaced text to be added to clipboard
  * \param byte_delta   Updated to change in byte count in textarea (ta->show)
  * \param r            Updated to area where redraw is required
  * \return false on memory exhaustion, true otherwise
@@ -2452,7 +2452,7 @@ bool textarea_keypress(struct textarea *ta, uint32_t key)
        struct textarea_msg msg;
        struct rect r;  /**< Redraw rectangle */
        char utf8[6];
-       unsigned int caret, length, b_off, b_len;
+       unsigned int caret, caret_copy, length, b_off, b_len;
        int h_extent = ta->h_extent;
        int v_extent = ta->v_extent;
        int line;
@@ -2466,7 +2466,7 @@ bool textarea_keypress(struct textarea *ta, uint32_t key)
        /* Word separators */
        static const char *sep = " .\n";
 
-       caret = textarea_get_caret(ta);
+       caret = caret_copy = textarea_get_caret(ta);
        line = ta->caret_pos.line;
        readonly = (ta->flags & TEXTAREA_READONLY ? true : false);
 
@@ -2760,6 +2760,50 @@ bool textarea_keypress(struct textarea *ta, uint32_t key)
                                textarea_clear_selection(ta);
                        }
                        break;
+               case NS_KEY_DELETE_WORD_LEFT:
+                       if (readonly)
+                               break;
+
+                       /* If there is a selection, remove the selected
+                       * characters */
+                       if (ta->sel_start != -1) {
+                               if (!textarea_replace_text(ta, ta->sel_start,
+                                               ta->sel_end, "", 0, false,
+                                               &byte_delta, &r))
+                                       return false;
+                               caret = ta->sel_start;
+                               textarea_clear_selection(ta);
+                               redraw = true;
+                               break;
+                       }
+
+                       if (caret == 0)
+                               break;
+
+                       /* caret goes left until a non-separator is
+                       * encountered */
+                       caret--;
+                       while (strchr(sep, ta->show->data[caret]) != NULL &&
+                                       caret > 0)
+                               caret--;
+
+                       /* caret goes left until a separator is encountered */
+                       for (; caret > 0; caret--) {
+                               if (strchr(sep, ta->show->data[caret]) !=
+                                               NULL) {
+                                       caret++;
+                                       break;
+                               }
+                       }
+
+                       /* Remove the characters from new caret position to
+                       * original caret position */
+                       if (!textarea_replace_text(ta, caret, caret_copy,
+                                       "", 0, false, &byte_delta, &r))
+                               return false;
+
+                       redraw = true;
+                       break;
                case NS_KEY_WORD_RIGHT:
                        if (readonly)
                                break;
@@ -2783,6 +2827,49 @@ bool textarea_keypress(struct textarea *ta, uint32_t key)
                                textarea_clear_selection(ta);
                        }
                        break;
+               case NS_KEY_DELETE_WORD_RIGHT:
+                       if (readonly)
+                               break;
+
+                       /* If there is a selection, remove the selected
+                       * characters */
+                       if (ta->sel_start != -1) {
+                               if (!textarea_replace_text(ta, ta->sel_start,
+                                               ta->sel_end, "", 0, false,
+                                               &byte_delta, &r))
+                                       return false;
+                               caret = ta->sel_start;
+                               textarea_clear_selection(ta);
+                               redraw = true;
+                               break;
+                       }
+
+                       if (caret == ta->show->len - 1)
+                               break;
+
+                       /* caret_copy goes right until a non-separator is
+                       * encountered */
+                       while (strchr(sep, ta->show->data[caret_copy]) != NULL
+                                       && caret_copy < ta->show->len - 1)
+                               caret_copy++;
+
+                       /* caret_copy goes right until a separator is
+                       * encountered */
+                       for (; caret_copy < ta->show->len - 1; caret_copy++) {
+                               if (strchr(sep, ta->show->data[caret_copy]) !=
+                                               NULL) {
+                                       break;
+                               }
+                       }
+
+                       /* Remove all the characters from original caret
+                       * position to caret_copy */
+                       if (!textarea_replace_text(ta, caret, caret_copy,
+                                       "", 0, false, &byte_delta, &r))
+                               return false;
+
+                       redraw = true;
+                       break;
                case NS_KEY_DELETE_LINE:
                        if (readonly)
                                break;
diff --git a/frontends/gtk/gui.c b/frontends/gtk/gui.c
index a826b05..76bbd99 100644
--- a/frontends/gtk/gui.c
+++ b/frontends/gtk/gui.c
@@ -131,12 +131,16 @@ uint32_t gtk_gui_gdkkey_to_nskey(GdkEventKey *key)
        case GDK_KEY(BackSpace):
                if (key->state & GDK_SHIFT_MASK)
                        return NS_KEY_DELETE_LINE_START;
+               else if (key->state & GDK_CONTROL_MASK)
+                       return NS_KEY_DELETE_WORD_LEFT;
                else
                        return NS_KEY_DELETE_LEFT;
 
        case GDK_KEY(Delete):
                if (key->state & GDK_SHIFT_MASK)
                        return NS_KEY_DELETE_LINE_END;
+               else if (key->state & GDK_CONTROL_MASK)
+                       return NS_KEY_DELETE_WORD_RIGHT;
                else
                        return NS_KEY_DELETE_RIGHT;
 
diff --git a/include/netsurf/keypress.h b/include/netsurf/keypress.h
index 604d2dd..84d9d41 100644
--- a/include/netsurf/keypress.h
+++ b/include/netsurf/keypress.h
@@ -59,7 +59,9 @@ enum input_key {
        NS_KEY_TEXT_START,
        NS_KEY_TEXT_END,
        NS_KEY_WORD_LEFT,
+       NS_KEY_DELETE_WORD_LEFT,
        NS_KEY_WORD_RIGHT,
+       NS_KEY_DELETE_WORD_RIGHT,
        NS_KEY_PAGE_UP,
        NS_KEY_PAGE_DOWN,
        NS_KEY_DELETE_LINE_END,


-- 
NetSurf Browser
_______________________________________________
netsurf-commits mailing list -- netsurf-commits@netsurf-browser.org
To unsubscribe send an email to netsurf-commits-le...@netsurf-browser.org

Reply via email to