Revision: 4393
http://vexi.svn.sourceforge.net/vexi/?rev=4393&view=rev
Author: clrg
Date: 2012-05-31 12:29:13 +0000 (Thu, 31 May 2012)
Log Message:
-----------
Make cut/copy/paste accessible functions.
Modified Paths:
--------------
trunk/org.vexi-vexi.widgets/src_main/org/vexi/lib/text/block.t
trunk/org.vexi-vexi.widgets/src_main/org/vexi/lib/text/edit.t
Modified: trunk/org.vexi-vexi.widgets/src_main/org/vexi/lib/text/block.t
===================================================================
--- trunk/org.vexi-vexi.widgets/src_main/org/vexi/lib/text/block.t
2012-05-31 12:25:20 UTC (rev 4392)
+++ trunk/org.vexi-vexi.widgets/src_main/org/vexi/lib/text/block.t
2012-05-31 12:29:13 UTC (rev 4393)
@@ -1,4 +1,4 @@
-<!-- Copyright 2011 - see COPYING for details [LGPL] -->
+<!-- Copyright 2012 - see COPYING for details [LGPL] -->
<vexi xmlns:ui="vexi://ui" xmlns:meta="vexi://meta" xmlns="org.vexi.lib.text">
<meta:doc>
@@ -110,8 +110,8 @@
var wrapwidth = b.wrapwidth ? b.wrapwidth : b.width;
var width = 0;
- // single line behaviour
if (!b.multiline) {
+ // single line behaviour
for (var j=0; numchildren>j; j++) {
w = b[j];
w.x = cur_x;
@@ -169,8 +169,8 @@
}
// move onto next word
i++;
- // process completed lines
if (eol or i==numchildren) {
+ // process completed lines
offset = align_left ? 0 : ((wrapwidth-cur_x) / right_mark);
for (var j=sol; i>j; j++) {
w = b[j];
Modified: trunk/org.vexi-vexi.widgets/src_main/org/vexi/lib/text/edit.t
===================================================================
--- trunk/org.vexi-vexi.widgets/src_main/org/vexi/lib/text/edit.t
2012-05-31 12:25:20 UTC (rev 4392)
+++ trunk/org.vexi-vexi.widgets/src_main/org/vexi/lib/text/edit.t
2012-05-31 12:29:13 UTC (rev 4393)
@@ -152,6 +152,41 @@
thisbox.selectAll; // publicly accessible function for
selecting all text
thisbox.unselectAll; // publicly accessible function for
unselecting all text
+ thisbox.copy = function() {
+ if (select) {
+ var t = getSelectedText();
+ vexi.ui.clipboard = t;
+ }
+ }
+
+ thisbox.copyAll = function() {
+ selectAll();
+ copy();
+ unselectAll();
+ }
+
+ thisbox.cut = function() {
+ if (select) {
+ var t = getSelectedText();
+ vexi.ui.clipboard = t;
+ deleteSelectedText();
+ }
+ }
+
+ thisbox.cutAll = function() {
+ selectAll();
+ copy();
+ deleteSelectedText();
+ }
+
+ thisbox.paste = function() {
+ if (select) {
+ deleteSelectedText();
+ }
+ var t = vexi.ui.clipboard;
+ insertText(t);
+ }
+
///////////////////////////////////////////////////////////////
//////// Internal Behaviour ///////////////////////////////////
///////////////////////////////////////////////////////////////
@@ -192,7 +227,7 @@
* - a* represent the new cursor position
* - s* represent the starting cursor position (when selection was
started)
*/
- var selectWords = function() {
+ thisbox.selectWords = function() {
// lock cursor
cursorLock = true;
if (cBlock == null or aBlock == null) {
@@ -301,7 +336,7 @@
}
/** deletes all select words */
- var deleteSelectedText = function() {
+ thisbox.deleteSelectedText = function() {
// check for select mode
if (!select) return;
@@ -428,7 +463,7 @@
}
/** returns the selected text as a string */
- var getSelectedText = function() {
+ thisbox.getSelectedText = function() {
// block indice
var cbi = thisbox.indexof(cBlock);
var sbi = thisbox.indexof(sBlock);
@@ -501,7 +536,7 @@
}
/** inserts text at the point cBlock.cWord[cPos] */
- var insertText = function(t) {
+ thisbox.insertText = function(t) {
if (select) deleteSelectedText();
if (t == "" or !t) return;
@@ -1025,27 +1060,19 @@
// copy
case "C-c":
case "C-C":
- if (select) {
- vexi.ui.clipboard = getSelectedText();
- }
+ copy();
break;
// cut
case "C-x":
case "C-X":
- if (select) {
- vexi.ui.clipboard = getSelectedText();
- deleteSelectedText();
- }
+ cut();
break;
// paste
case "C-v":
case "C-V":
- if (select) {
- deleteSelectedText();
- }
- insertText(vexi.ui.clipboard);
+ paste();
break;
// add circumflex (caret) accent
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Vexi-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/vexi-svn