![]() |
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. |
The Sigil plugin framework doesn't currently provide any way to make the current cursor position available to third-party plugins.
|
Well, that's that idea scuppered, then! Thank you for your help, though.
|
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. |
Quote:
Code:
#!/usr/bin/env python |
Oh, thank you—that's great. I'll have a play around.
Thanks! |
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. |
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) |
If it is already in the clipboard, then why doesn’t ctrl-v work??
|
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. |
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.
|
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. |
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.
|
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. |
Quote:
|
Quote:
Wait....Wut??? :eek: Please don't tell me I missed another function that Sigil does so well already..... :rofl: |
On a Windows computer, pressing windows-V give you a history to paste from. This works in Sigil and most other programs.
|
Or as DiapDealer said use Sigil's Edit/Paste From Clipboard History... menu item or key shortcut on any platform. You can highlight any clipboard history item to paste or use the delete key to remove it from the history.
|
It also saves the history between Sigil sessions (the preference setting determines how many are saved between sessions)
|
Pasting
Hi all,
Maybe far from the original post title, but as the conversation was on the pasting topic I continue here. The process is:
Here is what I meant... in images: https://www.youtube.com/watch?v=NAXWuLJN3lI Hope this helps Cheers |
Just use PageEdit with Sigil. It will do exactly what you want.
Quote:
|
Quote:
I hoped more for an addition of ten lines of code: javascript Code:
document.addEventListener('paste', function (evt) {Code:
#!/usr/bin/env pythonqt Code:
void DropArea::paste() |
Huh? That code exists in PageEdit and it can easily be launched and run. It is meant to be integrated into Sigil which has an easy way to launch it.
Sigil's CodeView editor is not a browser window and always pastes html/text as its base property since it is an xhtml code editor where copy and paste of code snippets are always done. Almost all copies made in CodeView typically includes html tags or partial html as text. You can not paste into a CodeView formatted rich text or images. You are confusing the target (a pure text code editor vs a browser like dom editor (Old BookView and PageEdit). PageEdit is exactly like old Sigil's BookView and pasting formatted text into the PageEdit browser window is handled as you would expect. |
1 Attachment(s)
@fxp33
If the feature is that important to you, why not use a plugin? The following code should do the trick: Spoiler:
Just assign it one of the 10 plugin shortcuts and a corresponding keyboard shortcut, and you're good to go. However, you might want to consider using PageEdit instead, because it'll significantly clean up the messy HTML code that some apps will copy to the clipboard. |
Quote:
Yep, the plugin was my intention... and this is precisely why I was hoping I could get a hint on "how to insert text at cursor position" in this thread. I opened a lot of plugins to try and understand how to do that... 😉 Thanks a lot for packaging and rewriting the code into a plugin... And of course, I will indeed, check with pageEdit 👍 Best regards François |
Quote:
What I can't figure out is why all the buttons from pageEdit have been added to Sigil (bald, italic, images, special caracters and even cut, paste) except this pasting option. PageEdit seems therefor very redundant to Sigil, and I find it to be a very big "plugin" for "just pasting". But as you and Doitsu mentioned: it does not just paste, it cleans the code too when choosing "plain text" by adding "p" and "br". Which I understand is not just 10 lines of code. Thanks for your reply, this helped me try new things with pageEdit. 👍 Regards François |
PageEdit is not a plugin. It is separate editing program app that allows limited WYSIWYG editing similar to what the old BookView did in some ways. It can be easily launched from within Sigil by setting PageEdit as the External XHTML editor in Sigil's Preferences.
|
| All times are GMT -4. The time now is 08:32 PM. |
Powered by: vBulletin
Copyright ©2000 - 3.8.5, Jelsoft Enterprises Ltd.
MobileRead.com is a privately owned, operated and funded community.