This example is a set of action routines that support clipboard support for rows in a table. They allow copy, cut, and paste of selected rows. Note that the clipboard support for text in a single cell is provided automatically in the same way as entry fields.
This sample does not handle selected columns, just rows.
You could modify this code to pass the formatted text, by using text of ROW, but then it would be much more difficult to support paste operations.
# Sample code for table object to manage multiple rows of text
# data. Copy, Cut and Paste to and from the clipboard.
include esllib.inc
string ManyRows_SV Row_SV ColDelim_SV RowDelim_SV
integer Y
# Define a table with 'multiple row selection' named Table.
# Use 'column delimiter is tab', to communicate with other
# applications that expect column data (such as a spreadsheet).
action CopyToClip is
# Copy selected rows to the clipboard
copy "" to ManyRows_SV
for each selected row Y of Table loop
copy textual row Y of Table to Row_SV
append Row_SV (row delimiter of Table) to ManyRows_SV
end loop
copy ManyRows_SV to clipboard
action CutToClip is
# Cut selected rows to the clipboard
copy "" to ManyRows_SV
for each selected row Y of Table loop
copy textual row Y of Table to Row_SV
append Row_SV (row delimiter of Table) to ManyRows_SV
remove row Y from Table
# Since removed this row, must back up one row
copy (Y - 1) to Y
end loop
copy ManyRows_SV to clipboard
action PasteFromClip is
# Insert rows from clipboard, after current row
copy clipboard to ManyRows_SV
copy ycursor of Table to Y
copy (column delimiter of Table) to ColDelim_SV
copy (row delimiter of Table) to RowDelim_SV
while (length of ManyRows_SV > 0) loop
copy EslParseRow(ManyRows_SV, ColDelim_SV, RowDelim_SV)
to Row_SV
# If last row is empty, don't insert it.
if (length of ManyRows_SV = 0 and length of Row_SV = 0)
then
leave loop
end if
# create an empty row so you can use 'copy'; it parses by column
add to Table insert row after row Y
copy (Y + 1) to Y # number of the new row
copy Row_SV to row Y of Table
end loop