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

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: 24,248
Karma: 163636384
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
Advert
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: 5,514
Karma: 3513158
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,214
Karma: 18779449
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
Advert
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: 24,248
Karma: 163636384
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
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 09:32 PM.


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