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 04-24-2021, 02:25 PM   #1
MandyBrigwell
Junior Member
MandyBrigwell began at the beginning.
 
Posts: 3
Karma: 10
Join Date: Apr 2021
Device: iPad
Plugin to insert text at current cursor position

Is it possible to simply insert text at the current cursor position?

I'd like to insert the current date and time and a few other bits and pieces, essentially using Sigil as a fancy journal system. I can handle formatting the inserted text myself, but if someone can clue me in as to how I can simply insert 'Hello World!' at the cursor position, I'd be very grateful.

I have tried with the documentation, but I'm struggling somewhat… the learning curve is a little steep, and although I've downloaded a number of example plug-ins for tips, I've come up short.
MandyBrigwell is offline   Reply With Quote
Old 04-24-2021, 02:32 PM   #2
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 27,546
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
The Sigil plugin framework doesn't currently provide any way to make the current cursor position available to third-party plugins.
DiapDealer is offline   Reply With Quote
Old 04-24-2021, 02:55 PM   #3
MandyBrigwell
Junior Member
MandyBrigwell began at the beginning.
 
Posts: 3
Karma: 10
Join Date: Apr 2021
Device: iPad
Well, that's that idea scuppered, then! Thank you for your help, though.
MandyBrigwell is offline   Reply With Quote
Old 04-24-2021, 04:14 PM   #4
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,630
Karma: 5433388
Join Date: Nov 2009
Device: many
Simply have the plugin copy whatever you want to insert at the cursor to your system clipboard and once there you can paste it at the cursor or anywhere else.

Should work.
KevinH is offline   Reply With Quote
Old 04-24-2021, 04:47 PM   #5
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,583
Karma: 22735033
Join Date: Dec 2010
Device: Kindle PW2
Quote:
Originally Posted by MandyBrigwell View Post
I'd like to insert the current date and time and a few other bits and pieces, essentially using Sigil as a fancy journal system.
As KevinH has already suggested, having the plugin copy text to the clipboard would be the easiest solution and takes only 3 lines of code. Here's a proof of concept plugin:

Code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
from datetime import datetime
from PyQt5.Qt import QApplication

# main routine    
def run(bk):
    app = QApplication(sys.argv)
    date_time = str(datetime.now())
    app.clipboard().setText(date_time)
    print('{} copied to the clipboard.'.format(date_time))
    return 0

def main():
    print('I reached main when I should not have\n')
    return -1

if __name__ == "__main__":
    sys.exit(main())

Last edited by Doitsu; 04-24-2021 at 04:52 PM.
Doitsu is offline   Reply With Quote
Old 04-25-2021, 07:33 AM   #6
MandyBrigwell
Junior Member
MandyBrigwell began at the beginning.
 
Posts: 3
Karma: 10
Join Date: Apr 2021
Device: iPad
Oh, thank you—that's great. I'll have a play around.

Thanks!
MandyBrigwell is offline   Reply With Quote
Old 04-25-2021, 08:09 AM   #7
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 27,546
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Sorry. I assumed the insertion would need to be done by the plugin.

Another possibility that occurs to me (that would allow a plugin to do the actual insertion) would be using a clip to insert something in the html that is (or includes) an extremely unique placeholder; which can then be replaced by a plugin with a simple text replacement.
DiapDealer is offline   Reply With Quote
Old 08-16-2021, 05:32 AM   #8
fxp33
Addict
fxp33 figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.fxp33 figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.fxp33 figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.fxp33 figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.fxp33 figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.fxp33 figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.fxp33 figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.fxp33 figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.fxp33 figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.fxp33 figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.fxp33 figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.
 
Posts: 261
Karma: 110864
Join Date: Mar 2013
Location: Bordeaux, France
Device: Kobo Glo, Aura HD, kindle paperwhite
Could we have a plugin that paste the html from the clipboard at the cursor position ?

(really useful when pasting theater and poetry: keeping the li or br are a necessity. I really miss that option from the first versions of Sigil)
fxp33 is offline   Reply With Quote
Old 08-16-2021, 07:39 AM   #9
Turtle91
A Hairy Wizard
Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.
 
Turtle91's Avatar
 
Posts: 3,093
Karma: 18727053
Join Date: Dec 2012
Location: Charleston, SC today
Device: iPhone 11/X/6/iPad 1,2,Air & Air Pro/Surface Pro/Kindle PW & Fire
If it is already in the clipboard, then why doesn’t ctrl-v work??
Turtle91 is offline   Reply With Quote
Old 08-16-2021, 08:12 AM   #10
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,630
Karma: 5433388
Join Date: Nov 2009
Device: many
Quote:
Originally Posted by fxp33 View Post
Could we have a plugin that paste the html from the clipboard at the cursor position ?

(really useful when pasting theater and poetry: keeping the li or br are a necessity. I really miss that option from the first versions of Sigil)
But that is the default for pasting in CodeView. I copy and paste snippets of html code all of the time.

Where are you trying to paste your html and how exactly as you trying to paste it (what menu or keyboard shortcut). Where did you copy your html from?

If you copy it from a different app, that app may not be properly copying the text to your clipboard as it may try to interpret the html as rich text.
KevinH is offline   Reply With Quote
Old 08-16-2021, 09:05 AM   #11
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 27,546
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
I think they're talking about the option you got to paste rich text or plain text when pasting into Book View from something like Word. Like you now do when pasting into PageEdit from Word.

Last edited by DiapDealer; 08-16-2021 at 09:08 AM.
DiapDealer is offline   Reply With Quote
Old 08-16-2021, 09:33 AM   #12
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,630
Karma: 5433388
Join Date: Nov 2009
Device: many
So instead of converting the Word doc to html using one of the existing plugins and importing it they instead want to copy the Word screen and somehow convert just it into html and paste that into Sigil?

As you said, they can paste it into PageEdit and get some semblance of html back, but using a Word import plugin or convert their doc into html and load that and use copy and paste.
KevinH is offline   Reply With Quote
Old 08-16-2021, 10:59 AM   #13
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 27,546
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Oh, I agree. For quick snippets of rich text in the clipboard, there's PageEdit (which was intended to replace Book View functionality anyway), for full documents, there's conversion and/or plugins.
DiapDealer is offline   Reply With Quote
Old 08-16-2021, 12:58 PM   #14
Turtle91
A Hairy Wizard
Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.
 
Turtle91's Avatar
 
Posts: 3,093
Karma: 18727053
Join Date: Dec 2012
Location: Charleston, SC today
Device: iPhone 11/X/6/iPad 1,2,Air & Air Pro/Surface Pro/Kindle PW & Fire
The only “paste” plug-in function I could see me needing, would be the ability to keep the last x number of items in the clipboard and then choose which one I wanted to paste.

I regularly have 2-3 different items that I wish I could switch between when copy/pasting as I’m going through a book.
Turtle91 is offline   Reply With Quote
Old 08-16-2021, 01:10 PM   #15
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 27,546
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Quote:
Originally Posted by Turtle91 View Post
The only “paste” plug-in function I could see me needing, would be the ability to keep the last x number of items in the clipboard and then choose which one I wanted to paste.

I regularly have 2-3 different items that I wish I could switch between when copy/pasting as I’m going through a book.
That sounds an awful lot like the built-in clipboard history feature.
DiapDealer is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Get cursor position or highlighted text inside plugin otherpasserby Plugins 10 12-16-2018 05:40 AM
How to send cursor to the home position by code ? reinsley Library Management 4 02-25-2017 02:08 PM
Reopening CC loses position, and reader app doesn't reopen at current position iatheia Calibre Companion 9 11-13-2015 08:20 PM
Glo Sleep with cover mess the current position ploum Kobo Reader 10 05-06-2013 07:49 AM
your current position regarding the 505 hello Sony Reader 1 10-06-2007 05:37 AM


All times are GMT -4. The time now is 06:20 AM.


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