Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

Silly question

Help
2011-03-22
2013-01-25
  • How can I get the current line number?
    I know its a basic question, but I really can't find the aswer. I've tried "editor.getCurLine()" and "editor.getLine()" with no luck.

    Anyone?

     
  • It's a 2 step process:

    currentLine = editor.lineFromPosition(editor.getCurrentPos())
    
     
  • Thank you, Dave.

     
  • Jari Pennanen
    Jari Pennanen
    2011-05-06

    I spent ~20mins to figure out how to set the current line for something.

    Question is not silly, the API is! (Can you change the topic to "Get current line number?")

    And I really mean it e.g. getter setter symmetry is messed up. Consider this:

    editor.getCurLine() gets current line but there is no setCurLine()! There is term "Current" and abbrev "Cur", please choose one.

    Besides these kind of oddities the documentation seems to be in no particular order, so finding this current line number seemed impossible.

     
  • Jari Pennanen
    Jari Pennanen
    2011-05-06

    Apologizes the API and naming conventions are messed up in the Scintilla API, this is just Pytohn wrapper that does not try to sort those out.

    Writing high level wrapper is not probably worth the time since someone (Scintilla API) is pulling the rope to wrong direction on each iteration.

     
  • Quite!  I agree the lack of symmetry and naming in Scintilla is all over the place.  The author is very against changing things like that, as it would cause work for downstream projects (e.g. Notepad++), which could mean projects don't update.  I can kind of see his point, but then there's the Python 3.x attitude of "we got some things wrong, and we're going to change them, even though that will break backward (and forward) compatibility".  Python's obviously a much bigger project than Scintilla though. 

    Also, 90% of the wrapper is generated code - I have no desire to write 200+ functions and decide a naming scheme that works.  You'd also *never* find anything, as atleast Scintilla is reasonably well documented.  I'm thinking of adding autocomplete / function tips declarations, which would certainly help.

    Incidentally, just if you didn't find it, there's a editor.replaceLine(lineNumber, text) function, which is an extra function as replacing a line in scintilla is a multi-step operation.

    The documentation for the Scintilla functions is also auto-generated, but if anyone has any ideas on how to improve it I'd be happy to hear them!

    Cheers,
    Dave.

     

  • Anonymous
    2011-06-15

    editor.lineFromPosition(editor.getCurrentPos())