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 01-14-2019, 03:05 PM   #421
KevinH
Wizard
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: 3,171
Karma: 1957622
Join Date: Nov 2009
Device: many
Hi Doitsu,
I am not sure I see the need to bundle this with Sigil for plugins. It could always be added and used with "Open With" inside Sigil itself if that is something a user might be interested in.

The plugin interface was designed to automate repetitive tasks that can not be easily done inside a gui based environment, not to extend Sigil's gui itself. So how exactly would this be useful for plugins? If possible, please provide examples of how plugins would need a full editor to perform its functions.

DiapDealer, what do you think?
KevinH is offline   Reply With Quote
Old 01-14-2019, 03:45 PM   #422
Doitsu
Wizard
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: 4,418
Karma: 14368669
Join Date: Dec 2010
Device: Kindle PW2
Quote:
Originally Posted by KevinH View Post
I am not sure I see the need to bundle this with Sigil for plugins. It could always be added and used with "Open With" inside Sigil itself if that is something a user might be interested in.
Of course, users could select their favorite editor with "Open With," however, it'd be very difficult to bundle QScintilla with a plugin, because it's a PyQt5 plugin.

Quote:
Originally Posted by KevinH View Post
The plugin interface was designed to automate repetitive tasks that can not be easily done inside a gui based environment, not to extend Sigil's gui itself.
IMHO, features such as code folding and auto-completion would make some edits easier moreover the QScintilla API is very user-friendly and requires hardly any code. I cobbled together a simple QScintilla edit plugin, which uses the following code:

Spoiler:
Code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys, os
from PyQt5 import Qsci
from PyQt5.QtGui import QFont, QFontMetrics, QColor
from PyQt5.QtWidgets import QApplication, QMessageBox

def run(bk):
    
    #=====================
    # save changes
    #=====================
    def SaveChanges():
        new_html = editor.text()
        if new_html != html:
            answer = QMessageBox.question(editor, "Save changes?", "Do you want to save the changes.")
            if answer == QMessageBox.Yes:
                bk.writefile(html_id, new_html)
                print('{} was updated.'.format(file_name))
        else:
            print('{} was NOT updated.'.format(file_name))

    #===================================
    # select a file
    #===================================
    
    # get all selected files
    file_names = list(bk.selected_iter())
    if file_names != []:
        # only use the first file
        html_id = file_names[0][1]
        file_name = os.path.basename(bk.id_to_href(html_id))
        # only load HTML files
        if bk.id_to_mime(html_id) == 'application/xhtml+xml':
            html = bk.readfile(html_id)
        else:
            print('No HTML file selected.')
            return
    else:
        print('You must select an HTML file.')
        return
    
    
    #=====================================
    # define QScintilla window
    #=====================================
    app = QApplication(sys.argv)
    editor = Qsci.QsciScintilla()
    lexer = Qsci.QsciLexerHTML(editor)
    editor.setLexer(lexer)

    # define autocompletion parameters
    editor.setAutoCompletionThreshold(1)
    editor.setAutoCompletionSource(Qsci.QsciScintilla.AcsAll)

    # define font
    font = QFont()
    font.setFamily('Courier')
    font.setFixedPitch(True)
    font.setPointSize(10)
    
    # editor code page
    editor.setUtf8(True)
    
    # editor font
    editor.setFont(font)
    editor.setMarginsFont(font)
    fontmetrics = QFontMetrics(font)
    editor.setMarginsFont(font)
    
    # margins & line numbers
    editor.setMarginWidth(0, fontmetrics.width("00000") + 6)
    editor.setMarginLineNumbers(0, True)
    editor.setMarginsBackgroundColor(QColor("#cccccc"))
    editor.setMarginWidth(2, 15)
    
    # line wrapping
    editor.setWrapMode(editor.WrapWord)
    
    # enable folding
    editor.setFolding(True)

    # window size
    editor.setMinimumSize(600, 450)
    editor.show()
    editor.setText(html)
    
    # save changes
    app.aboutToQuit.connect(SaveChanges)
    
    # display editor
    app.exec_()
    
    print('Done')
    
    return 0

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

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


(All the plugin does is load the HTML code of current file into the editor and when you close the editor it asks you whether you want to save the changes.)

If you want to test it, you'll need to install the QScintilla package from PyPi.

(This plugin will not work with the Windows version, unless sys.path is updated.)
Attached Files
File Type: zip QScintilla.zip (1.6 KB, 13 views)
Doitsu is offline   Reply With Quote
Advert
Old 01-14-2019, 03:55 PM   #423
KevinH
Wizard
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: 3,171
Karma: 1957622
Join Date: Nov 2009
Device: many
Code folding can be done in the Inspector under Preview to help you navigate. There are other editors that do code folding as well.

That said, I still don't understand why this makes any sense for a plugin? If you want to use an editor inside Sigil you can take the python code you wrote and tweak it only slightly to accept a filename or path in main and create standalone python code and launch it with "open with" from inside Sigil without every having to launch a plugin.

So I am confused, in what way does a plugin need a gui editor that can't be handled by "open with" inside of Sigil.
KevinH is offline   Reply With Quote
Old 01-14-2019, 05:10 PM   #424
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: 19,629
Karma: 100009224
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Need for it aside, I'm a little concerned with how difficult it might prove to incorporate it in Windows Sigil. We're already delivering a truncated and stripped-down version of PyQt5 that's held together and isolated with QProcess environment variable tweaking. Finding the minimum I need to add back in order to fully support QScintilla could prove time consuming.
DiapDealer is online now   Reply With Quote
Old 01-14-2019, 05:16 PM   #425
BetterRed
null operator
BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.
 
Posts: 12,186
Karma: 10633638
Join Date: Mar 2012
Location: Sydney Australia
Device: none
There's a boatload of Scintilla based text editors, many of which are free, on Windows I use Notepad++ and Bowpad via Sigil's Open With. My primary motivation to use them on xhtml and css is code folding. When I use them I often wonder: "If Sigil were starting development today, would it make sense to use Scintilla/ScIte as the basis of its code editor."

However, I can't see what advantage a Scintilla plugin would offer over Open With, unless one regards having something in the Plugins menu as being significantly superior UI-wise to right clicking the thing you want to edit in the Book Browser. In which case, wouldn't it be easier to add the Open With option to the Edit menu and button bar.

BR

Last edited by BetterRed; 01-15-2019 at 11:12 PM.
BetterRed is offline   Reply With Quote
Advert
Old 01-15-2019, 10:52 AM   #426
najgori
Connoisseur
najgori can read with one handnajgori can read with one handnajgori can read with one handnajgori can read with one handnajgori can read with one handnajgori can read with one handnajgori can read with one handnajgori can read with one handnajgori can read with one handnajgori can read with one handnajgori can read with one hand
 
Posts: 61
Karma: 79674
Join Date: Sep 2011
Location: Belgrade, Serbia
Device: many
wrong forum. sorry.

Last edited by najgori; 01-15-2019 at 11:42 AM.
najgori is offline   Reply With Quote
Old 01-15-2019, 11:04 AM   #427
KevinH
Wizard
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: 3,171
Karma: 1957622
Join Date: Nov 2009
Device: many
This is not a thread on suggestions for future releases. This thread is about plugin development and developers. Please keep on topic in this thread. Suggestions for new features unrelated to plugins should be done in the main Sigil forum thread.

Thank you.
KevinH is offline   Reply With Quote
Old 01-19-2019, 03:30 PM   #428
Doitsu
Wizard
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: 4,418
Karma: 14368669
Join Date: Dec 2010
Device: Kindle PW2
I'm working on a validation plugin for the French grammar/spell checker Grammalecte. If you want to test it with French books, PM me for the beta download link. (I'll release it once the Grammalecte developer releases Grammalecte 1.0.)

Please note that Grammalecte only supports French.
Doitsu 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
Loading Plugin in development Sladd Development 6 06-17-2014 07:57 PM
Question for plugin development gurus DiapDealer Plugins 2 02-05-2012 12:33 AM
DR800 Plugin development for DR800/DR1000 yuri_b iRex Developer's Corner 0 09-18-2010 10:46 AM
Device plugin development reader42 Plugins 10 03-29-2010 01:39 PM
Calibre plugin development - Newbie problems minstrel Plugins 5 04-12-2009 01:44 PM


All times are GMT -4. The time now is 05:28 PM.


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