Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Readers > Amazon Kindle > Kindle Developer's Corner

Notices

Reply
 
Thread Tools Search this Thread
Old 10-07-2012, 03:50 PM   #1
Elizabeth H
Junior Member
Elizabeth H is kind to children and small, furry animalsElizabeth H is kind to children and small, furry animalsElizabeth H is kind to children and small, furry animalsElizabeth H is kind to children and small, furry animalsElizabeth H is kind to children and small, furry animalsElizabeth H is kind to children and small, furry animalsElizabeth H is kind to children and small, furry animalsElizabeth H is kind to children and small, furry animalsElizabeth H is kind to children and small, furry animalsElizabeth H is kind to children and small, furry animalsElizabeth H is kind to children and small, furry animals
 
Posts: 1
Karma: 6666
Join Date: Oct 2012
Device: Kindle3 3Ggb
Copy & Paste

Hi,

I've been lurking around on this forum for about a month now, trying out various hacks and having a good deal of fun pimping my Kindle 3. So I thought it was about time I developed some ideas of my own and posted them. Copy and Paste functionality is something that I often wish the Kindle had so I decided to have an initial stab at putting something together this afternoon. It can no doubt be improved but I think it's usable enough to be worthwhile sharing what I have so far.

Installation
Copy and paste the texts below into a text editor and save them somewhere on the Kindle. In my examples I'll assume that you put them somewhere on the system path and chmoded the two shell scripts to make them executable (if necessary). (I have /mnt/us/system on my path and put my shell scripts in there.)

Usage
Copying and Pasting One Piece of Text at a Time
To copy a single piece of text:

Use the Kindle's highlighting feature to highlight the text that you wish to copy. The last highlight or bookmark created is the text in the "clipboard".

To append the contents of the "clipboard" onto a file (pre-existing or not) called foo.txt in the Kindle's documents directory type the following in a terminal window:

paste2doc.sh foo

To paste just the highlighted text without the citation information:

paste2doc.sh -o foo

To paste the contents of the "clipboard" into a KindleNote document called foo:

paste2doc.sh -n foo

Batch Copying and Pasting
To begin copying a batch of items at once, run:

startcopy.sh

and then highlight all the pieces of text that you want to copy.

To paste all of the items in the batch at once:

paste2doc.sh -m foo

or,

paste2doc.sh -n -m foo

Practical Usage
Set up launchpad commands for pasting into your favourite documents (todo list, shopping list, whatever).

Source Code
paste2doc.sh (Unix line endings):
Code:
#!/bin/sh

if [ "$1" == '-n' ] ; then
	PASTE_DIR=/mnt/us/developer/KindleNote/work
	shift
else
	PASTE_DIR=/mnt/us/documents
fi

if [ "$1" == '-m' ] ; then
	BEGIN_LINE=`grep -n <'/mnt/us/documents/My Clippings.txt' '^___BEGIN_COPY_AND_PASTE___' | tail -n 1 | cut -d: -f1`
	BEGIN_LINE=$((BEGIN_LINE+5))	
	shift
else
	BEGIN_LINE=`grep -n <'/mnt/us/documents/My Clippings.txt' '^==========' | tail -n 2 | head -n 1 | cut -d: -f1`
	BEGIN_LINE=$((BEGIN_LINE+1))
	if [ "$1" == '-o' ] ; then
		CITATION=no
		shift
	fi
fi

if [ "$1" == '-n' ] ; then
	PASTE_DIR=/mnt/us/developer/KindleNote/work
	shift
fi

if [ "$1" == '' ] ; then
	echo >&2 "Usage $0 [-n] [-m|-o] memoname"
	exit 1
fi

if [ "$PASTE_DIR" == '/mnt/us/documents' -a  ! -e "/mnt/us/documents/$1.txt" ] ; then
	REFRESH=yes
fi

if [ "$CITATION" == 'no' ] ; then
	BEGIN_LINE=$((BEGIN_LINE+3))
	tail '/mnt/us/documents/My Clippings.txt' -n +$BEGIN_LINE | grep -v '^==========' >>"$PASTE_DIR/$1.txt"
else
	tail '/mnt/us/documents/My Clippings.txt' -n +$BEGIN_LINE >>"$PASTE_DIR/$1.txt"
fi

if [ "$REFRESH" == 'yes' ] ; then
	dbus-send --system /default com.lab126.powerd.resuming int32:1
fi
startcopy.sh (Unix line endings):
Code:
#!/bin/sh

cat >>'/mnt/us/documents/My Clippings.txt' `dirname $0`/startcopy.txt
startcopy.txt (Windows line endings):
Code:
___BEGIN_COPY_AND_PASTE___
- Bookmark Loc. 1  | Added on Monday, November 19, 2007, 07:30 AM


==========
Possible Future Extensions - Ideas
  • Add an option to handle pasting into HTML files (including formatting URLS as links).
  • Implement an alternative method of pasting by simulating keypresses? (I want to be able to paste into the Kindle's browser.)
  • Write a Java program to enable "copying" from the browser's bookmarks file?
Elizabeth H is offline   Reply With Quote
Old 10-07-2012, 04:00 PM   #2
knc1
Embedded Cheerleader
knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.
 
knc1's Avatar
 
Posts: 6,218
Karma: 5830430
Join Date: Feb 2012
Device: Too many.
  • Eliminating spaces in file names.
knc1 is online now   Reply With Quote
Old 10-07-2012, 04:15 PM   #3
hippy dave
Zealot
hippy dave can program the VCR without an owner's manual.hippy dave can program the VCR without an owner's manual.hippy dave can program the VCR without an owner's manual.hippy dave can program the VCR without an owner's manual.hippy dave can program the VCR without an owner's manual.hippy dave can program the VCR without an owner's manual.hippy dave can program the VCR without an owner's manual.hippy dave can program the VCR without an owner's manual.hippy dave can program the VCR without an owner's manual.hippy dave can program the VCR without an owner's manual.hippy dave can program the VCR without an owner's manual.
 
Posts: 124
Karma: 178472
Join Date: Jul 2012
Device: Kindle 4
welcome thanks for sharing!
hippy dave is offline   Reply With Quote
Old 10-07-2012, 04:39 PM   #4
twobob
( ͡° ͜ʖ ͡°){ʇlnɐɟ ƃǝs}Tır
twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.
 
twobob's Avatar
 
Posts: 6,552
Karma: 6021142
Join Date: Jun 2012
Location: uti gratia usura (Yao ying da ying; Mo ying da yieng)
Device: PW-WIFI|K5-3G+WIFI| K4|K3-3G|DXG|K2| Rooted Nook Touch
top banana

Quote:
Originally Posted by knc1 View Post
  • Eliminating spaces in file names.
would be a good idea with the unix filesystem and all.

a real pain accessing files with spaces in, in the main. other than that. top banana Elizabeth

I personally Use Cntrl + C , Cntrl + v via vnc which works surprisingly in the main. Obviously that does not work for all cases : )

Appreciate you sharing your source.
twobob is offline   Reply With Quote
Old 10-07-2012, 04:41 PM   #5
qlob
Official Lurker
qlob ought to be getting tired of karma fortunes by now.qlob ought to be getting tired of karma fortunes by now.qlob ought to be getting tired of karma fortunes by now.qlob ought to be getting tired of karma fortunes by now.qlob ought to be getting tired of karma fortunes by now.qlob ought to be getting tired of karma fortunes by now.qlob ought to be getting tired of karma fortunes by now.qlob ought to be getting tired of karma fortunes by now.qlob ought to be getting tired of karma fortunes by now.qlob ought to be getting tired of karma fortunes by now.qlob ought to be getting tired of karma fortunes by now.
 
qlob's Avatar
 
Posts: 1,048
Karma: 7096675
Join Date: Apr 2012
Device: Kindle 3.4
Thanks! +3000 Karma for you!
qlob is offline   Reply With Quote
Old 10-08-2012, 01:23 AM   #6
fratermus
e-bookworm
fratermus ought to be getting tired of karma fortunes by now.fratermus ought to be getting tired of karma fortunes by now.fratermus ought to be getting tired of karma fortunes by now.fratermus ought to be getting tired of karma fortunes by now.fratermus ought to be getting tired of karma fortunes by now.fratermus ought to be getting tired of karma fortunes by now.fratermus ought to be getting tired of karma fortunes by now.fratermus ought to be getting tired of karma fortunes by now.fratermus ought to be getting tired of karma fortunes by now.fratermus ought to be getting tired of karma fortunes by now.fratermus ought to be getting tired of karma fortunes by now.
 
fratermus's Avatar
 
Posts: 76
Karma: 630090
Join Date: Sep 2012
Location: Point, Texas
Device: PW2, K3, KF2, Touch (dying)
Quote:
Originally Posted by twobob View Post
a real pain accessing files with spaces in, in the main.
For onlookers: quoting the space-containing string or \backslash-escaping the space will allow users to interact with space-containing files and dirs. Some shells make this with filename completion.
fratermus is offline   Reply With Quote
Old 10-08-2012, 07:00 AM   #7
twobob
( ͡° ͜ʖ ͡°){ʇlnɐɟ ƃǝs}Tır
twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.
 
twobob's Avatar
 
Posts: 6,552
Karma: 6021142
Join Date: Jun 2012
Location: uti gratia usura (Yao ying da ying; Mo ying da yieng)
Device: PW-WIFI|K5-3G+WIFI| K4|K3-3G|DXG|K2| Rooted Nook Touch
yep. TAB is your friend.
twobob is offline   Reply With Quote
Old 10-08-2012, 07:28 AM   #8
knc1
Embedded Cheerleader
knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.
 
knc1's Avatar
 
Posts: 6,218
Karma: 5830430
Join Date: Feb 2012
Device: Too many.
Quote:
Originally Posted by fratermus View Post
For onlookers: quoting the space-containing string or \backslash-escaping the space will allow users to interact with space-containing files and dirs. Some shells make this with filename completion.
If the user (or the utility) is aware of the requirement.

Any character, except the one having a byte value representation of 0 (zero) may be used, but (mis-)using the input field separator characters (space, tab, new-line) is consider at the very least "bad form".

The (mis-)using of characters that are assigned a special purpose in any language, natural or other, in the place of the general purpose characters should only be done when no alternative is available.

Last edited by knc1; 10-08-2012 at 08:02 AM.
knc1 is online now   Reply With Quote
Old 10-08-2012, 07:54 AM   #9
twobob
( ͡° ͜ʖ ͡°){ʇlnɐɟ ƃǝs}Tır
twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.
 
twobob's Avatar
 
Posts: 6,552
Karma: 6021142
Join Date: Jun 2012
Location: uti gratia usura (Yao ying da ying; Mo ying da yieng)
Device: PW-WIFI|K5-3G+WIFI| K4|K3-3G|DXG|K2| Rooted Nook Touch
spaces are bad. m'kay???
twobob is offline   Reply With Quote
Old 10-08-2012, 08:02 AM   #10
knc1
Embedded Cheerleader
knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.
 
knc1's Avatar
 
Posts: 6,218
Karma: 5830430
Join Date: Feb 2012
Device: Too many.
Quote:
Originally Posted by twobob View Post
spaces are bad. m'kay???
Fixed.
knc1 is online now   Reply With Quote
Old 10-08-2012, 08:36 AM   #11
twobob
( ͡° ͜ʖ ͡°){ʇlnɐɟ ƃǝs}Tır
twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.
 
twobob's Avatar
 
Posts: 6,552
Karma: 6021142
Join Date: Jun 2012
Location: uti gratia usura (Yao ying da ying; Mo ying da yieng)
Device: PW-WIFI|K5-3G+WIFI| K4|K3-3G|DXG|K2| Rooted Nook Touch
This took far too long to do... (I suck at unix image tools)

but I meant... enc...

(I'm particularly proud of the terrible text overlay, shameful!)
Attached Thumbnails
Click image for larger version

Name:	spaces_are_bad_mmkay.jpg
Views:	29
Size:	28.6 KB
ID:	93633  

Last edited by twobob; 10-08-2012 at 08:37 AM. Reason: the shame
twobob is offline   Reply With Quote
Old 10-08-2012, 10:09 AM   #12
qlob
Official Lurker
qlob ought to be getting tired of karma fortunes by now.qlob ought to be getting tired of karma fortunes by now.qlob ought to be getting tired of karma fortunes by now.qlob ought to be getting tired of karma fortunes by now.qlob ought to be getting tired of karma fortunes by now.qlob ought to be getting tired of karma fortunes by now.qlob ought to be getting tired of karma fortunes by now.qlob ought to be getting tired of karma fortunes by now.qlob ought to be getting tired of karma fortunes by now.qlob ought to be getting tired of karma fortunes by now.qlob ought to be getting tired of karma fortunes by now.
 
qlob's Avatar
 
Posts: 1,048
Karma: 7096675
Join Date: Apr 2012
Device: Kindle 3.4
Hahaha I love it! (its better than anything I could ever do, i have no artistic talent.)
qlob is offline   Reply With Quote
Old 10-09-2012, 01:00 AM   #13
fratermus
e-bookworm
fratermus ought to be getting tired of karma fortunes by now.fratermus ought to be getting tired of karma fortunes by now.fratermus ought to be getting tired of karma fortunes by now.fratermus ought to be getting tired of karma fortunes by now.fratermus ought to be getting tired of karma fortunes by now.fratermus ought to be getting tired of karma fortunes by now.fratermus ought to be getting tired of karma fortunes by now.fratermus ought to be getting tired of karma fortunes by now.fratermus ought to be getting tired of karma fortunes by now.fratermus ought to be getting tired of karma fortunes by now.fratermus ought to be getting tired of karma fortunes by now.
 
fratermus's Avatar
 
Posts: 76
Karma: 630090
Join Date: Sep 2012
Location: Point, Texas
Device: PW2, K3, KF2, Touch (dying)
Quote:
Originally Posted by knc1 View Post
I...(mis-)using the input field separator characters (space, tab, new-line) is consider at the very least "bad form".

Completely agreed.
fratermus is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy and Paste JDavid Sigil 4 08-23-2012 04:02 PM
Copy Paste giosa Sony Reader Dev Corner 0 03-24-2012 06:17 PM
iBooks: No Support for Selection & Copy/Paste Operations of SVG Texts on EPUB reuben ePub 2 09-22-2010 08:06 AM
Copy and Paste Gunnerp245 enTourage eDGe 1 04-03-2010 02:45 PM


All times are GMT -4. The time now is 04:33 PM.


MobileRead.com is a privately owned, operated and funded community.