Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Sigil > Plugins

Notices

Reply
 
Thread Tools Search this Thread
Old 10-10-2015, 06:44 AM   #1
otherpasserby
Junior Member
otherpasserby began at the beginning.
 
Posts: 2
Karma: 10
Join Date: Oct 2015
Device: none
Get cursor position or highlighted text inside plugin

Hi there,

From with a plugin, is there any way to get the current position of the cursor, or the hightlighted text (start/end position) in a HTML file?

Thanks.
otherpasserby is offline   Reply With Quote
Old 10-10-2015, 12:55 PM   #2
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 7,644
Karma: 5433388
Join Date: Nov 2009
Device: many
Hi,
No, there isn't. The plugin can see which file was highlighted in the book browser, but can not see where the cursor is in the file.

What exactly do you need to do at that point that you can't do with a regex or a search/replace?

Thanks,

KevinH
KevinH is offline   Reply With Quote
Advert
Old 10-10-2015, 12:59 PM   #3
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 7,644
Karma: 5433388
Join Date: Nov 2009
Device: many
Hi,
One way around this is to add a known id to the closest tag or wrap a piece of text in a span with a known id attribute, and then invoke the plugin on the currently selected file and have it look for that id in the plugin. That might work.

KevinH
KevinH is offline   Reply With Quote
Old 10-11-2015, 02:34 AM   #4
otherpasserby
Junior Member
otherpasserby began at the beginning.
 
Posts: 2
Karma: 10
Join Date: Oct 2015
Device: none
Hi Kevin,

Thanks for your reply, I appreciate it.

When converting pdf's into html a lot of the semantics get lost and oftentimes one (or I at least) cannot discriminate between different semantics by means of a regex. Only by comparing the original pdf and the resulting epub can one see what the original semantics was.

For example, my latest conversion was a pdf with verses. At he end of a verse their could be a little note in italic. And between verses there can be commentary in italic. Each note/commentary could contain multiple </i>xyz<i> when words need to be in normal case. So far, I have not been able to write the perfect regex to handle these situations.

After the crude regex work I always find myself comparing the pdf and epub page by page and fix any differences only the eye could detect. And mostly, different solutions are needed for the different scenario's.

So, I was thinking about a plugin which could remain open and showing a list of 'solutions' that could be applied after selecting text in the "Book View" or "Code View". This would very much ease the flow of manually correcting 400 pages.

Regards.
otherpasserby is offline   Reply With Quote
Old 11-23-2018, 04:41 AM   #5
nirosan
Member
nirosan began at the beginning.
 
Posts: 17
Karma: 10
Join Date: Jul 2017
Device: epub
Is there now a way to get cursor position?

Hi,
It was a long time ago. So I want to know if there now a way to get cursor position or to add some html-codes at cursor position. For example I want that the user add some info to generate Table (this part is ok) and then I generate a HTML-Table (this part is ok too). Generated Table should added at cursor position (for this part I need a way). Can somebody help me with it? or does somebody has any ideas?

Thank you
nirosan is offline   Reply With Quote
Advert
Old 11-23-2018, 10:50 AM   #6
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 7,644
Karma: 5433388
Join Date: Nov 2009
Device: many
No. And there are no plans to add that feature as you can simply use Sigil's clips feature to insert a "marker" at the current cursor position and then have your plugin look for that marker and replace it with anything you want.
KevinH is offline   Reply With Quote
Old 11-23-2018, 11:55 AM   #7
Doitsu
Grand Sorcerer
Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.
 
Doitsu's Avatar
 
Posts: 5,584
Karma: 22735033
Join Date: Dec 2010
Device: Kindle PW2
Quote:
Originally Posted by nirosan View Post
It was a long time ago. So I want to know if there now a way to get cursor position or to add some html-codes at cursor position.
In addition to KevinH's suggestion, you could also have the plugin copy the table code to the clipboard with pyperclip.
Doitsu is offline   Reply With Quote
Old 11-25-2018, 05:37 AM   #8
nirosan
Member
nirosan began at the beginning.
 
Posts: 17
Karma: 10
Join Date: Jul 2017
Device: epub
Ok. Thank you I will try it :-).
nirosan is offline   Reply With Quote
Old 12-11-2018, 07:00 AM   #9
nirosan
Member
nirosan began at the beginning.
 
Posts: 17
Karma: 10
Join Date: Jul 2017
Device: epub
Hi,
I have tried with pyperclip and it works thanks again.
But if I use the bundled python interpreter I got
this error:

ImportError: No module named 'pyperclip'
Error: No module named 'pyperclip'


How can I use the bundled python interpreter and my plugin with pyperclip or some other packages?

Thank you
nirosan is offline   Reply With Quote
Old 12-11-2018, 07:56 AM   #10
Doitsu
Grand Sorcerer
Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.
 
Doitsu's Avatar
 
Posts: 5,584
Karma: 22735033
Join Date: Dec 2010
Device: Kindle PW2
Quote:
Originally Posted by nirosan View Post
How can I use the bundled python interpreter and my plugin with pyperclip or some other packages?
Simply copy the whole pyperclip folder from
Code:
C:\Python3X\Lib\site-packages\pyperclip
to the plugin folder. I.e., the same folder that contains plugin.py.
Doitsu is offline   Reply With Quote
Old 12-16-2018, 05:40 AM   #11
nirosan
Member
nirosan began at the beginning.
 
Posts: 17
Karma: 10
Join Date: Jul 2017
Device: epub
Quote:
Originally Posted by Doitsu View Post
Simply copy the whole pyperclip folder from
Code:
C:\Python3X\Lib\site-packages\pyperclip
to the plugin folder. I.e., the same folder that contains plugin.py.
Thank you
nirosan is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
highlighted text exaltedwombat Sigil 0 12-07-2012 07:28 PM
highlighted text in kindle book flhden Amazon Kindle 9 10-24-2010 08:21 AM
Unhighlighting highlighted text SaifAllah1978 enTourage Archive 4 05-09-2010 05:20 PM
PRS-600 Exporting Highlighted Text to the PC FaisalLoco Sony Reader 5 12-03-2009 03:44 AM
PRS-600 HELP: How to export highlighted text to the PC? FaisalLoco Sony Reader 0 10-21-2009 05:12 AM


All times are GMT -4. The time now is 11:34 AM.


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