I've started using this great plugin quite a lot now. It's my first foray into Python, too. Seems to be a very powerful tool indeed.
Anyway, I don't think there's a method for getting the filename of a particular view at the moment. There's notepad.getCurrentFilename(), but you can't pass the view as a parameter. The workarounds available would seem to me to be either temporarily switch to the other view and use the aforementioned method (quick 'n' dirty) or walk the list returned by notepad.getFiles() until you match the doc index returned by notepad.getCurrentDocIndex(view) for the view in question.
So one solution seems a little hacky, and the other a little long-winded. Is there a better way?
If not, perhaps this could be an addition to the API for a future release?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I guess at some point the API designer has to decide when to stop. Perhaps this is one of those cases. I don't sweat this type of thing as I like to write code; so I can wrap this in my own function. In fact, I have supplemental "notepad" and "editor" classes that add in functionality. For example, I don't think there is a direct function to get the number of the line the caret is on in the currently active view and document, thus I have written:
I just pulled a simple case, sometimes it gets more complex. Unfortunately, I don't have a function written right now that implements your desired functionality, but it could easily be written! Fun!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks for that. I'd just figured on overloading the notepad object myself today, too. That way, I can add in functions I use a lot. Unfortunately, due to the bug in notepad.getFiles() (discussed here: https://sourceforge.net/p/npppythonscript/discussion/1188886/thread/bc28b0dd/), only the hacky-switch-temporarily-to-the-other-view method above can work reliably at the moment.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I've started using this great plugin quite a lot now. It's my first foray into Python, too. Seems to be a very powerful tool indeed.
Anyway, I don't think there's a method for getting the filename of a particular view at the moment. There's notepad.getCurrentFilename(), but you can't pass the view as a parameter. The workarounds available would seem to me to be either temporarily switch to the other view and use the aforementioned method (quick 'n' dirty) or walk the list returned by notepad.getFiles() until you match the doc index returned by notepad.getCurrentDocIndex(view) for the view in question.
So one solution seems a little hacky, and the other a little long-winded. Is there a better way?
If not, perhaps this could be an addition to the API for a future release?
I guess at some point the API designer has to decide when to stop. Perhaps this is one of those cases. I don't sweat this type of thing as I like to write code; so I can wrap this in my own function. In fact, I have supplemental "notepad" and "editor" classes that add in functionality. For example, I don't think there is a direct function to get the number of the line the caret is on in the currently active view and document, thus I have written:
I just pulled a simple case, sometimes it gets more complex. Unfortunately, I don't have a function written right now that implements your desired functionality, but it could easily be written! Fun!
Thanks for that. I'd just figured on overloading the notepad object myself today, too. That way, I can add in functions I use a lot. Unfortunately, due to the bug in notepad.getFiles() (discussed here: https://sourceforge.net/p/npppythonscript/discussion/1188886/thread/bc28b0dd/), only the hacky-switch-temporarily-to-the-other-view method above can work reliably at the moment.