| 
			
			 | 
		#1 | 
| 
			
			
			
			 Junior Member 
			
			![]() 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.  | 
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#2 | 
| 
			
			
			
			 Grand Sorcerer 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 28,891 
				Karma: 207182180 
				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.
		 
		
	
		
		
		
		
		
		
		
		
		
		
	
	 | 
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#3 | 
| 
			
			
			
			 Junior Member 
			
			![]() Posts: 3 
				Karma: 10 
				Join Date: Apr 2021 
				
				
				
				Device: iPad 
				
				
				 | 
	
	
	
		
		
		
		
		 
			
			Well, that's that idea scuppered, then! Thank you for your help, though.
		 
		
	
		
		
		
		
		
		
		
		
		
		
	
	 | 
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#4 | 
| 
			
			
			
			 Sigil Developer 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 9,072 
				Karma: 6361556 
				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.  | 
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#5 | |
| 
			
			
			
			 Grand Sorcerer 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 5,763 
				Karma: 24088559 
				Join Date: Dec 2010 
				
				
				
				Device: Kindle PW2 
				
				
				 | 
	
	
	
		
		
		
		
		 Quote: 
	
 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 05:52 PM.  | 
|
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#6 | 
| 
			
			
			
			 Junior Member 
			
			![]() Posts: 3 
				Karma: 10 
				Join Date: Apr 2021 
				
				
				
				Device: iPad 
				
				
				 | 
	
	
	
		
		
		
		
		 
			
			Oh, thank you—that's great. I'll have a play around. 
		
	
		
		
		
		
		
		
		
		
		
		
	
	Thanks!  | 
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#7 | 
| 
			
			
			
			 Grand Sorcerer 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 28,891 
				Karma: 207182180 
				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.  | 
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#8 | 
| 
			
			
			
			 Addict 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 262 
				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)  | 
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#9 | 
| 
			
			
			
			 A Hairy Wizard 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,397 
				Karma: 20212733 
				Join Date: Dec 2012 
				Location: Charleston, SC today 
				
				
				Device: iPhone 15/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??
		 
		
	
		
		
		
		
		
		
		
		
		
		
	
	 | 
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#10 | |
| 
			
			
			
			 Sigil Developer 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 9,072 
				Karma: 6361556 
				Join Date: Nov 2009 
				
				
				
				Device: many 
				
				
				 | 
	
	
	
		
		
		
		
		 Quote: 
	
 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.  | 
|
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#11 | 
| 
			
			
			
			 Grand Sorcerer 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 28,891 
				Karma: 207182180 
				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 10:08 AM.  | 
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#12 | 
| 
			
			
			
			 Sigil Developer 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 9,072 
				Karma: 6361556 
				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.  | 
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#13 | 
| 
			
			
			
			 Grand Sorcerer 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 28,891 
				Karma: 207182180 
				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.
		 
		
	
		
		
		
		
		
		
		
		
		
		
	
	 | 
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#14 | 
| 
			
			
			
			 A Hairy Wizard 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,397 
				Karma: 20212733 
				Join Date: Dec 2012 
				Location: Charleston, SC today 
				
				
				Device: iPhone 15/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.  | 
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#15 | |
| 
			
			
			
			 Grand Sorcerer 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 28,891 
				Karma: 207182180 
				Join Date: Jan 2010 
				
				
				
				Device: Nexus 7, Kindle Fire HD 
				
				
				 | 
	
	
	
		
		
		
		
		 Quote: 
	
  
		 | 
|
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
![]()  | 
            
        
            
            
  | 
    
			 
			Similar Threads
		 | 
	||||
| Thread | Thread Starter | Forum | Replies | Last Post | 
| Get cursor position or highlighted text inside plugin | otherpasserby | Plugins | 10 | 12-16-2018 06:40 AM | 
| How to send cursor to the home position by code ? | reinsley | Library Management | 4 | 02-25-2017 03:08 PM | 
| Reopening CC loses position, and reader app doesn't reopen at current position | iatheia | Calibre Companion | 9 | 11-13-2015 09:20 PM | 
| Glo Sleep with cover mess the current position | ploum | Kobo Reader | 10 | 05-06-2013 08:49 AM | 
| your current position regarding the 505 | hello | Sony Reader | 1 | 10-06-2007 06:37 AM |