-
-
Notifications
You must be signed in to change notification settings - Fork 99
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
Landscape option added to base class #1892
Conversation
An orientation option was declared in the base class. When it is "landscape", the values of x and y in papersize are swapped. Just to explain what maybe could look redundant in classes/base.lua:92: While testing this feature, it worked well for several times, but sometimes - without touching the code - it suddenly stopped to work! The problem is that the option.orientation must be passed as parameter in SILE.papersize and in those times when it didn't work, its value was nil even though it actually worked many times before without any modification. After some time I found out why: since there is no order in a loop using pairs(), sometimes the loop in class:setOptions() was getting orientation as the last element, so when SILE.papersize was called, the value of options.orientation was indeed nil, so the solution should be just set the orientation value to class.options before papersize. modified: classes/base.lua modified: core/papersize.lua new file: tests/landscape.sil
Hello, that's something I considered too. If it get accepted, it would need to be documented in the manual too. Not that we already have a PR on similar areas (#1853), so things will have to be done orderly. Two small remarks in passing
|
- modified: classes/base.lua Unnecessary spaces and indentation changes removed; - modified: documentation/c03-input.sil Feature added to the documentation as a subsection of "Defining the paper size" - modified: core/papersize.lua Now landscape argument is boolean. - modified: tests/landscape.sil - new file: tests/landscape.expected The tests files as requested
Hello @Omikhleia , thanks for your reviewing and I appreciate your tips.
I have a habit to always use automatic formatting, so some of these indentation changes were made so. I'll pay attention to this detail next times.
Right, I'll remember that. |
This will conflict with #1853 which introduces a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As already noted, the unrelated style changes need to be removed from this PR. I can barely make out what is going on, much less give it a good review. I'm actually quite happy to accept code style fixes, but only on their own not as part of other changes. Also many of these changes go against our usual coding styles and won't fly anyway.
Adding a landscape option is fine but we do need it to be clean.
Also have we thought about whether an enum option like this (two named options) is best or whether an orientation option that could allow more rotations (e.g. 4) would be more robust? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working with us to get this cleaned up. It's a simple option but it's worth implementing right so it is robust for future users.
Just a few nitpicks at this point mostly about boolean handling but there is one other logic issue I see.
self.landscape is only passed to document state if there is an landscape input. Now this variable is using the SU.boolean helper...
SU.boolean not used to check 'landscape' anymore Co-authored-by: Caleb Maclennan <[email protected]>
@Omikhleia I'm pretty sure we can make a small adjustment and make this play nice with your PR for full bleed printing, but thinking about that does bring up a concern here. Are we going to have a problem with race conditions and the order (or Lua's non-deterministic order) of handling options? |
My remark #1892 (comment) got closed, and the current implementation uses some workaround do avoid it. It does have code smell (or adds up to the existing one, regarding how class options are implemented). What else can I say? |
I just rewrote this and even changed the way the existing papersize class option is handled. This should avoid the race condition, but also reduces the code smell rather than adding too it. Reduces not eliminates. Again we all know the crop marks package here needs replacing entirely. I did fix the landscape option so it can be set on custom papersizes not just presets, added a unit test for it, etc. @jodros You might look over the contents of my commits for future reference. Some of the changes (like not handling the papersize option twice!) are fixes to bugs that existed before your PR, but others are fixes for things you didn't handle or not setting random variables you don't use, etc. No worries, just some pointers for the next go-round... |
* Avoid possible race conditions * Only set defaults once * Handle landscape mode on custom paper sizes * Pass option value to cropmarks package and allow override there * Avoid setting usused variables * Add code comments for the benefit of other coders and future self
Co-authored-by: Caleb Maclennan <[email protected]>
I missed an option for a landscape mode so here it is.