-
Notifications
You must be signed in to change notification settings - Fork 109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add getCharCoordinates() and getMark() functions to the Scripter API. #127
base: master
Are you sure you want to change the base?
Conversation
hi @xavidotron , nice idea! i've put some comments inline. here is some more general feedback from my side:
|
Fix positionToPoint() to work with text frames that aren't the first in a chain.
Thanks for the review! The only other API function I see that operates on character positions is insertText(), though maybe I'm missing something, so I didn't come up with a better name than your suggestion. I'm happy to add a getMarks() in addition if you want, but for my use case, since I need to go through the frame text with a regular expression to find places to link anyways, it seems more convenient to be able to get specific marks rather than getting all of them and then filtering out the ones I don't want. I'm also not sure how I'd implement getMarks() without iterating over the each position in the StoryText object in the C++, which doesn't seem like a significant win over doing it in python. |
thanks for the further commits. as far as i know, iterating with c++ is by orders of magnitudes faster than doing so with python (that's one of the selling points of numpy...). anyway, i would love to see how you're managing the links through python! |
At the scale I'm operating at, iterating in python is plently fast enough and it's a lot quicker for me to write and test weird regexp code in python than in C++. I could see some version of this being reasonable for a Scribus built-in but my use is sufficiently idiosyncratic that I think doing it in python is pretty reasonable. The messy python script I'm currently using is attached; it's a quick script for my particular book rather than trying to be anything general. |
please take into consideration what jean wrote in the official scribus bug tracker. personally, i don't spot big issues anymore but i have two more comments:
i also had a look at your script and i understand that your defining automatic links for page references. |
Fixed the error message, and added some documentation about layout. Yes, this is to automatically add links for page references. The challenges I see with a built-in feature include:
If that first bug gets fixed and someone added some sort of configuration to address the second, a built-in version of this could work pretty well. |
nice did you also test the case when parts of the text is overflowing and is hidden? (of course, it's a bad idea to have overflowing text, but thing happen...) |
Thanks for the reminder, added an additional check to raise an exception in this case (previously it would crash, oops). |
hi, i guess it's time to submit a new diff to the official bug tracker... i have not seen a definitive one in there... |
Is there a standard format of diff I should be putting there, or instructions I should be following? |
i do them by adding in this case, the diff can be created with: (or you can of course do a |
… the character is not on the current page.
…ment menu item. Make getMark() return a dictionary. Add a setMarkText() function.
Add two new functions to the Scripter API.
positionToPoint() lets you get information about where a given character in a text frame is located.
getMark() lets you get information about a mark in a text frame.
These two additions make it possible to write python scripts to add PDF links based on the content of a text frame.