netsurf: branch master updated. release/3.0-578-g5809bce
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/5809bcefa6bcff43a9d22...
...commit http://git.netsurf-browser.org/netsurf.git/commit/5809bcefa6bcff43a9d2208...
...tree http://git.netsurf-browser.org/netsurf.git/tree/5809bcefa6bcff43a9d220872...
The branch, master has been updated
via 5809bcefa6bcff43a9d2208725105e4469624d28 (commit)
from 3bdc61a13186699a9f9ad955ab1c8fbf5e8f032c (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=5809bcefa6bcff43a9d...
commit 5809bcefa6bcff43a9d2208725105e4469624d28
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Wipe undo buffer on textarea_set_text.
diff --git a/desktop/textarea.c b/desktop/textarea.c
index 8afe127..a1ebe0d 100644
--- a/desktop/textarea.c
+++ b/desktop/textarea.c
@@ -1979,6 +1979,9 @@ bool textarea_set_text(struct textarea *ta, const char *text)
ta->text.len = len;
ta->text.utf8_len = utf8_length(ta->text.data);
+ ta->undo.next_detail = 0;
+ ta->undo.last_detail = 0;
+
textarea_normalise_text(ta, 0, len);
if (ta->flags & TEXTAREA_MULTILINE) {
-----------------------------------------------------------------------
Summary of changes:
desktop/textarea.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/desktop/textarea.c b/desktop/textarea.c
index 8afe127..a1ebe0d 100644
--- a/desktop/textarea.c
+++ b/desktop/textarea.c
@@ -1979,6 +1979,9 @@ bool textarea_set_text(struct textarea *ta, const char *text)
ta->text.len = len;
ta->text.utf8_len = utf8_length(ta->text.data);
+ ta->undo.next_detail = 0;
+ ta->undo.last_detail = 0;
+
textarea_normalise_text(ta, 0, len);
if (ta->flags & TEXTAREA_MULTILINE) {
--
NetSurf Browser
9 years, 5 months
netsurf: branch master updated. release/3.0-577-g3bdc61a
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/3bdc61a13186699a9f9ad...
...commit http://git.netsurf-browser.org/netsurf.git/commit/3bdc61a13186699a9f9ad95...
...tree http://git.netsurf-browser.org/netsurf.git/tree/3bdc61a13186699a9f9ad955a...
The branch, master has been updated
via 3bdc61a13186699a9f9ad955ab1c8fbf5e8f032c (commit)
from b22adee6fcf9c2ad34a3852dcb14cbdf3b301d59 (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=3bdc61a13186699a9f9...
commit 3bdc61a13186699a9f9ad955ab1c8fbf5e8f032c
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Ensure cut can be undone.
diff --git a/desktop/textarea.c b/desktop/textarea.c
index 5d84007..8afe127 100644
--- a/desktop/textarea.c
+++ b/desktop/textarea.c
@@ -1570,7 +1570,7 @@ static bool textarea_replace_text(struct textarea *ta, size_t b_start,
size_t b_end, const char *rep, size_t rep_len,
bool add_to_clipboard, int *byte_delta, struct rect *r)
{
- if (!(b_start != b_end && rep_len == 0 && add_to_clipboard) &&
+ if (!(b_start != b_end && rep == NULL && add_to_clipboard) &&
!(ta->flags & TEXTAREA_PASSWORD)) {
/* Not just copying to clipboard, and not a password field;
* Sort out undo buffer. */
@@ -1585,7 +1585,7 @@ static bool textarea_replace_text(struct textarea *ta, size_t b_start,
return false;
}
- if (!(b_start != b_end && rep_len == 0 && add_to_clipboard) &&
+ if (!(b_start != b_end && rep == NULL && add_to_clipboard) &&
!(ta->flags & TEXTAREA_PASSWORD)) {
/* Not just copying to clipboard, and not a password field;
* Update UNDO buffer */
-----------------------------------------------------------------------
Summary of changes:
desktop/textarea.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/desktop/textarea.c b/desktop/textarea.c
index 5d84007..8afe127 100644
--- a/desktop/textarea.c
+++ b/desktop/textarea.c
@@ -1570,7 +1570,7 @@ static bool textarea_replace_text(struct textarea *ta, size_t b_start,
size_t b_end, const char *rep, size_t rep_len,
bool add_to_clipboard, int *byte_delta, struct rect *r)
{
- if (!(b_start != b_end && rep_len == 0 && add_to_clipboard) &&
+ if (!(b_start != b_end && rep == NULL && add_to_clipboard) &&
!(ta->flags & TEXTAREA_PASSWORD)) {
/* Not just copying to clipboard, and not a password field;
* Sort out undo buffer. */
@@ -1585,7 +1585,7 @@ static bool textarea_replace_text(struct textarea *ta, size_t b_start,
return false;
}
- if (!(b_start != b_end && rep_len == 0 && add_to_clipboard) &&
+ if (!(b_start != b_end && rep == NULL && add_to_clipboard) &&
!(ta->flags & TEXTAREA_PASSWORD)) {
/* Not just copying to clipboard, and not a password field;
* Update UNDO buffer */
--
NetSurf Browser
9 years, 5 months
netsurf: branch master updated. release/3.0-576-gb22adee
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/b22adee6fcf9c2ad34a38...
...commit http://git.netsurf-browser.org/netsurf.git/commit/b22adee6fcf9c2ad34a3852...
...tree http://git.netsurf-browser.org/netsurf.git/tree/b22adee6fcf9c2ad34a3852dc...
The branch, master has been updated
via b22adee6fcf9c2ad34a3852dcb14cbdf3b301d59 (commit)
from 6a4601c3ce6a332d670b5288e3d7355bb9c109cd (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=b22adee6fcf9c2ad34a...
commit b22adee6fcf9c2ad34a3852dcb14cbdf3b301d59
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Add undo (F8) and redo (F9) keys. If caret is not in textarea, F8 is still view source.
diff --git a/riscos/window.c b/riscos/window.c
index 65ac536..9398e47 100644
--- a/riscos/window.c
+++ b/riscos/window.c
@@ -1859,6 +1859,13 @@ bool ro_gui_window_keypress(wimp_key *key)
c = KEY_DELETE_LEFT;
break;
+ case wimp_KEY_F8:
+ c = KEY_UNDO;
+ break;
+ case wimp_KEY_F9:
+ c = KEY_REDO;
+ break;
+
default:
break;
}
-----------------------------------------------------------------------
Summary of changes:
riscos/window.c | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/riscos/window.c b/riscos/window.c
index 65ac536..9398e47 100644
--- a/riscos/window.c
+++ b/riscos/window.c
@@ -1859,6 +1859,13 @@ bool ro_gui_window_keypress(wimp_key *key)
c = KEY_DELETE_LEFT;
break;
+ case wimp_KEY_F8:
+ c = KEY_UNDO;
+ break;
+ case wimp_KEY_F9:
+ c = KEY_REDO;
+ break;
+
default:
break;
}
--
NetSurf Browser
9 years, 5 months
netsurf: branch master updated. release/3.0-575-g6a4601c
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/6a4601c3ce6a332d670b5...
...commit http://git.netsurf-browser.org/netsurf.git/commit/6a4601c3ce6a332d670b528...
...tree http://git.netsurf-browser.org/netsurf.git/tree/6a4601c3ce6a332d670b5288e...
The branch, master has been updated
via 6a4601c3ce6a332d670b5288e3d7355bb9c109cd (commit)
via 2d14f0bb2e663f542d3997bb67c52e6e2ed96038 (commit)
from 308a24e66171190d321dfed622dc83e16bd64549 (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=6a4601c3ce6a332d670...
commit 6a4601c3ce6a332d670b5288e3d7355bb9c109cd
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Implement textarea undo and redo.
diff --git a/desktop/textarea.c b/desktop/textarea.c
index 8f53bf7..5d84007 100644
--- a/desktop/textarea.c
+++ b/desktop/textarea.c
@@ -1503,7 +1503,8 @@ static bool textarea_copy_to_undo_buffer(struct textarea *ta,
if (undo->next_detail == 0)
b_offset = 0;
else
- b_offset = undo->details[undo->next_detail - 1].b_limit;
+ b_offset = undo->details[undo->next_detail - 1].b_start +
+ undo->details[undo->next_detail - 1].b_limit;
len = len > rep_len ? len : rep_len;
@@ -1602,12 +1603,20 @@ static bool textarea_replace_text(struct textarea *ta, size_t b_start,
* Undo previous change.
*
* \param ta Textarea widget
- * \param byte_delta Updated to change in byte count in textarea (ta->show)
+ * \param caret Updated to new caret pos in textarea (ta->show)
* \param r Updated to area where redraw is required
* \return false if nothing to undo, true otherwise
*/
-static bool textarea_undo(struct textarea *ta, int *byte_delta, struct rect *r)
+static bool textarea_undo(struct textarea *ta,
+ unsigned int *caret, struct rect *r)
{
+ unsigned int detail_n;
+ struct textarea_undo_detail *detail;
+ char *temp = NULL;
+ unsigned int b_len;
+ unsigned int b_text_len;
+ int byte_delta;
+
if (ta->flags & TEXTAREA_PASSWORD)
/* No undo for password fields */
return false;
@@ -1616,7 +1625,38 @@ static bool textarea_undo(struct textarea *ta, int *byte_delta, struct rect *r)
/* Nothing to undo */
return false;
- /* TODO */
+ detail_n = ta->undo.next_detail - 1;
+ detail = &(ta->undo.details[detail_n]);
+
+ b_len = detail->b_end - detail->b_start;
+ b_text_len = detail->b_text_end - detail->b_text_start;
+
+ /* Take copy of any current textarea text that undo will remove */
+ if (detail->b_text_end > detail->b_text_start) {
+ temp = malloc(b_text_len);
+ if (temp == NULL) {
+ /* TODO */
+ return false;
+ }
+
+ memcpy(temp, ta->text.data + detail->b_text_start, b_text_len);
+ }
+
+ /* Replace textarea text with undo buffer text */
+ textarea_replace_text_internal(ta,
+ detail->b_text_start, detail->b_text_end,
+ ta->undo.text.data + detail->b_start, b_len,
+ false, &byte_delta, r);
+
+ /* Update undo buffer for redo */
+ memcpy(ta->undo.text.data + detail->b_start, temp, b_text_len);
+ detail->b_text_end = detail->b_text_start + b_len;
+ detail->b_end = detail->b_start + b_text_len;
+
+ *caret = detail->b_text_end;
+ ta->undo.next_detail--;
+
+ free(temp);
return true;
}
@@ -1626,21 +1666,60 @@ static bool textarea_undo(struct textarea *ta, int *byte_delta, struct rect *r)
* Redo previous undo.
*
* \param ta Textarea widget
- * \param byte_delta Updated to change in byte count in textarea (ta->show)
+ * \param caret Updated to new caret pos in textarea (ta->show)
* \param r Updated to area where redraw is required
* \return false if nothing to redo, true otherwise
*/
-static bool textarea_redo(struct textarea *ta, int *byte_delta, struct rect *r)
+static bool textarea_redo(struct textarea *ta,
+ unsigned int *caret, struct rect *r)
{
+ unsigned int detail_n;
+ struct textarea_undo_detail *detail;
+ char *temp = NULL;
+ unsigned int b_len;
+ unsigned int b_text_len;
+ int byte_delta;
+
if (ta->flags & TEXTAREA_PASSWORD)
- /* No REDO for password fields */
+ /* No redo for password fields */
return false;
if (ta->undo.next_detail > ta->undo.last_detail)
/* Nothing to redo */
return false;
- /* TODO */
+ detail_n = ta->undo.next_detail;
+ detail = &(ta->undo.details[detail_n]);
+
+ b_len = detail->b_end - detail->b_start;
+ b_text_len = detail->b_text_end - detail->b_text_start;
+
+ /* Take copy of any current textarea text that redo will remove */
+ if (detail->b_text_end > detail->b_text_start) {
+ temp = malloc(b_text_len);
+ if (temp == NULL) {
+ /* TODO */
+ return false;
+ }
+
+ memcpy(temp, ta->text.data + detail->b_text_start, b_text_len);
+ }
+
+ /* Replace textarea text with undo buffer text */
+ textarea_replace_text_internal(ta,
+ detail->b_text_start, detail->b_text_end,
+ ta->undo.text.data + detail->b_start, b_len,
+ false, &byte_delta, r);
+
+ /* Update undo buffer for redo */
+ memcpy(ta->undo.text.data + detail->b_start, temp, b_text_len);
+ detail->b_text_end = detail->b_text_start + b_len;
+ detail->b_end = detail->b_start + b_text_len;
+
+ *caret = detail->b_text_end;
+ ta->undo.next_detail++;
+
+ free(temp);
return true;
}
@@ -2710,24 +2789,22 @@ bool textarea_keypress(struct textarea *ta, uint32_t key)
caret += byte_delta;
break;
case KEY_UNDO:
- if (!textarea_undo(ta, &byte_delta, &r)) {
+ if (!textarea_undo(ta, &caret, &r)) {
/* We consume the UNDO, even if we can't act
* on it. */
return true;
}
- caret += byte_delta;
if (ta->sel_start != -1) {
textarea_clear_selection(ta);
}
redraw = true;
break;
case KEY_REDO:
- if (!textarea_redo(ta, &byte_delta, &r)) {
+ if (!textarea_redo(ta, &caret, &r)) {
/* We consume the REDO, even if we can't act
* on it. */
return true;
}
- caret += byte_delta;
if (ta->sel_start != -1) {
textarea_clear_selection(ta);
}
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=2d14f0bb2e663f542d3...
commit 2d14f0bb2e663f542d3997bb67c52e6e2ed96038
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Fix Ctrl+Shift+Z.
diff --git a/gtk/gui.c b/gtk/gui.c
index d7598c3..0968021 100644
--- a/gtk/gui.c
+++ b/gtk/gui.c
@@ -1089,14 +1089,12 @@ uint32_t gtk_gui_gdkkey_to_nskey(GdkEventKey *key)
if (key->state & GDK_CONTROL_MASK)
return KEY_CUT_SELECTION;
return gdk_keyval_to_unicode(key->keyval);
+ case 'Z':
case 'y':
if (key->state & GDK_CONTROL_MASK)
return KEY_REDO;
return gdk_keyval_to_unicode(key->keyval);
case 'z':
- if (key->state & GDK_CONTROL_MASK &&
- key->state & GDK_SHIFT_MASK)
- return KEY_REDO;
if (key->state & GDK_CONTROL_MASK)
return KEY_UNDO;
return gdk_keyval_to_unicode(key->keyval);
-----------------------------------------------------------------------
Summary of changes:
desktop/textarea.c | 101 +++++++++++++++++++++++++++++++++++++++++++++------
gtk/gui.c | 4 +--
2 files changed, 90 insertions(+), 15 deletions(-)
diff --git a/desktop/textarea.c b/desktop/textarea.c
index 8f53bf7..5d84007 100644
--- a/desktop/textarea.c
+++ b/desktop/textarea.c
@@ -1503,7 +1503,8 @@ static bool textarea_copy_to_undo_buffer(struct textarea *ta,
if (undo->next_detail == 0)
b_offset = 0;
else
- b_offset = undo->details[undo->next_detail - 1].b_limit;
+ b_offset = undo->details[undo->next_detail - 1].b_start +
+ undo->details[undo->next_detail - 1].b_limit;
len = len > rep_len ? len : rep_len;
@@ -1602,12 +1603,20 @@ static bool textarea_replace_text(struct textarea *ta, size_t b_start,
* Undo previous change.
*
* \param ta Textarea widget
- * \param byte_delta Updated to change in byte count in textarea (ta->show)
+ * \param caret Updated to new caret pos in textarea (ta->show)
* \param r Updated to area where redraw is required
* \return false if nothing to undo, true otherwise
*/
-static bool textarea_undo(struct textarea *ta, int *byte_delta, struct rect *r)
+static bool textarea_undo(struct textarea *ta,
+ unsigned int *caret, struct rect *r)
{
+ unsigned int detail_n;
+ struct textarea_undo_detail *detail;
+ char *temp = NULL;
+ unsigned int b_len;
+ unsigned int b_text_len;
+ int byte_delta;
+
if (ta->flags & TEXTAREA_PASSWORD)
/* No undo for password fields */
return false;
@@ -1616,7 +1625,38 @@ static bool textarea_undo(struct textarea *ta, int *byte_delta, struct rect *r)
/* Nothing to undo */
return false;
- /* TODO */
+ detail_n = ta->undo.next_detail - 1;
+ detail = &(ta->undo.details[detail_n]);
+
+ b_len = detail->b_end - detail->b_start;
+ b_text_len = detail->b_text_end - detail->b_text_start;
+
+ /* Take copy of any current textarea text that undo will remove */
+ if (detail->b_text_end > detail->b_text_start) {
+ temp = malloc(b_text_len);
+ if (temp == NULL) {
+ /* TODO */
+ return false;
+ }
+
+ memcpy(temp, ta->text.data + detail->b_text_start, b_text_len);
+ }
+
+ /* Replace textarea text with undo buffer text */
+ textarea_replace_text_internal(ta,
+ detail->b_text_start, detail->b_text_end,
+ ta->undo.text.data + detail->b_start, b_len,
+ false, &byte_delta, r);
+
+ /* Update undo buffer for redo */
+ memcpy(ta->undo.text.data + detail->b_start, temp, b_text_len);
+ detail->b_text_end = detail->b_text_start + b_len;
+ detail->b_end = detail->b_start + b_text_len;
+
+ *caret = detail->b_text_end;
+ ta->undo.next_detail--;
+
+ free(temp);
return true;
}
@@ -1626,21 +1666,60 @@ static bool textarea_undo(struct textarea *ta, int *byte_delta, struct rect *r)
* Redo previous undo.
*
* \param ta Textarea widget
- * \param byte_delta Updated to change in byte count in textarea (ta->show)
+ * \param caret Updated to new caret pos in textarea (ta->show)
* \param r Updated to area where redraw is required
* \return false if nothing to redo, true otherwise
*/
-static bool textarea_redo(struct textarea *ta, int *byte_delta, struct rect *r)
+static bool textarea_redo(struct textarea *ta,
+ unsigned int *caret, struct rect *r)
{
+ unsigned int detail_n;
+ struct textarea_undo_detail *detail;
+ char *temp = NULL;
+ unsigned int b_len;
+ unsigned int b_text_len;
+ int byte_delta;
+
if (ta->flags & TEXTAREA_PASSWORD)
- /* No REDO for password fields */
+ /* No redo for password fields */
return false;
if (ta->undo.next_detail > ta->undo.last_detail)
/* Nothing to redo */
return false;
- /* TODO */
+ detail_n = ta->undo.next_detail;
+ detail = &(ta->undo.details[detail_n]);
+
+ b_len = detail->b_end - detail->b_start;
+ b_text_len = detail->b_text_end - detail->b_text_start;
+
+ /* Take copy of any current textarea text that redo will remove */
+ if (detail->b_text_end > detail->b_text_start) {
+ temp = malloc(b_text_len);
+ if (temp == NULL) {
+ /* TODO */
+ return false;
+ }
+
+ memcpy(temp, ta->text.data + detail->b_text_start, b_text_len);
+ }
+
+ /* Replace textarea text with undo buffer text */
+ textarea_replace_text_internal(ta,
+ detail->b_text_start, detail->b_text_end,
+ ta->undo.text.data + detail->b_start, b_len,
+ false, &byte_delta, r);
+
+ /* Update undo buffer for redo */
+ memcpy(ta->undo.text.data + detail->b_start, temp, b_text_len);
+ detail->b_text_end = detail->b_text_start + b_len;
+ detail->b_end = detail->b_start + b_text_len;
+
+ *caret = detail->b_text_end;
+ ta->undo.next_detail++;
+
+ free(temp);
return true;
}
@@ -2710,24 +2789,22 @@ bool textarea_keypress(struct textarea *ta, uint32_t key)
caret += byte_delta;
break;
case KEY_UNDO:
- if (!textarea_undo(ta, &byte_delta, &r)) {
+ if (!textarea_undo(ta, &caret, &r)) {
/* We consume the UNDO, even if we can't act
* on it. */
return true;
}
- caret += byte_delta;
if (ta->sel_start != -1) {
textarea_clear_selection(ta);
}
redraw = true;
break;
case KEY_REDO:
- if (!textarea_redo(ta, &byte_delta, &r)) {
+ if (!textarea_redo(ta, &caret, &r)) {
/* We consume the REDO, even if we can't act
* on it. */
return true;
}
- caret += byte_delta;
if (ta->sel_start != -1) {
textarea_clear_selection(ta);
}
diff --git a/gtk/gui.c b/gtk/gui.c
index d7598c3..0968021 100644
--- a/gtk/gui.c
+++ b/gtk/gui.c
@@ -1089,14 +1089,12 @@ uint32_t gtk_gui_gdkkey_to_nskey(GdkEventKey *key)
if (key->state & GDK_CONTROL_MASK)
return KEY_CUT_SELECTION;
return gdk_keyval_to_unicode(key->keyval);
+ case 'Z':
case 'y':
if (key->state & GDK_CONTROL_MASK)
return KEY_REDO;
return gdk_keyval_to_unicode(key->keyval);
case 'z':
- if (key->state & GDK_CONTROL_MASK &&
- key->state & GDK_SHIFT_MASK)
- return KEY_REDO;
if (key->state & GDK_CONTROL_MASK)
return KEY_UNDO;
return gdk_keyval_to_unicode(key->keyval);
--
NetSurf Browser
9 years, 5 months