![]() ![]() PN source code and Scintilla documentation were also essential. I used the Python indenter that comes with PyPN as a some sort of a starting point (I must notify that there is a redundant piece of code in that one - there is no need to check if the character is EOL as that's already done in ''pypn.glue''). With the current lack of documentation and some bugs in PyPN creating scripts is often about learning from errors. IndentLine ( l_cur - 1, c_ind ) Final Words GetLineIndentation ( l_cur - 2 ) if c_ind = p_ind : c_ind -= tab sci. GetLineIndentation ( l_cur ) p_ind = sci. Note, the PEP8 style guide for Python recommends using 4 spaces for indentation instead of tabs. in Atom, the 'Whitespace: Convert Tabs to Spaces' command that you can find with Cmd+Shift+P works nicely. IndentLine ( l_cur, c_ind ) elif kw in u_kws : c_ind = sci. To fix, convert all tabs to 4 spaces in your text editor. GetLineIndentation ( l_cur - 1 ) if c_ind = p_ind or c_ind = 0 : c_ind += tab sci. ![]() PositionFromLine ( l_cur - 1 ) t_end = pos - 1 txt = sci. tab = 2 ( "tes" ) def tes_indent ( c, doc ): sci = scintilla. i_kws = # Keywords that cause unindentation. Import scintilla from corators import indenter # Keywords that cause indentation. Inside the Function: Functionalityįirst, let's figure out what we're trying to do. With this information at hand we can move on. First word on previous line in lowercase (''txt.split().lower()'').Contents of the previous line (''sci.GetText(t_start, t_end)'').Location of the end of previous line (''pos - 1'').Location of the start of previous line (''sci.PositionFromLine(l_cur - 1)'').Current line (''sci.LineFromPosition(pos)'').Current location of the caret (''sci.CurrentPos'').We need it to use Scintilla's functions through PyPN.įor our needs we need to know the following about our document: In almost every PyPN script we a have variable that is set to ''scintilla.Scintilla(doc)'' (or more often actually ''scintilla.Scintilla(pn.CurrentDoc())''). ( "tes" ) def tes_indent ( c, doc ): sci = scintilla. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |