-
Notifications
You must be signed in to change notification settings - Fork 192
adds cursor control ANSI escape codes #887
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
Conversation
... the stdlib_ansi module
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.
Thank you @wassup05 for this PR. It sounds like a good start. I left a few comments.
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.
Could this be considered as a submodule of the module stdlib_ansi
?
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.
Thank you for reviewing!
It could be, but I thought separating it would be better since stdlib_ansi
revolves around it's own derived type whereas this doesn't... I'm open to either way though
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.
Is this the same for all OS?
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.
Yes, It's more of a terminal thing than an OS thing.. But almost all of the modern terminals support these ansi codes
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.
Could some of these functions be elemental
?
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.
They could be made so, But I don't think it's worth it since I don't see anyone using it like that
...essages to tests, small fixes
Nice work @wassup05, thank you. I'm no expert on ANSI terminal handling so I will add some of my thoughts here.
- The
stdlib_ansi
module has a derived type for ANSI escape codes:
Lines 23 to 31 in 7511064
If the terminal handling codes provided here match the same pattern, I believe it would be better to uniform their handling with that of the module, and make them type(ansi_code)
as well.
- Testing and examples are hard with console handling. However, I think it would be very useful to have examples that show some console interaction with these functions (for example, draw a box on the terminal, or something like that).
Thanks for replying, @perazz !
When I started working on this, I thought of ways to integrate the two but couldn't really find any such way... As these are more action oriented whereas those of ansi_type were more of like changing the properties of the text being printed
Regarding examples... I added an example in the recent commit which basically draws a blue box on the screen using a subroutine draw_box
, whose width, height and the position (line, column) were it is drawn can be changed.. I added the link to it in the spec as well
Please let me know what you think about it
Uh oh!
There was an error while loading. Please reload this page.
The PR adds cursor control ANSI escape codes as a separate module
stdlib_ansi_cursor
This was brought up scarcely in #229 but was not really discussed.
Functions added are
move_to(x,y)
move_to_column(x)
move_<direction>
where<direction>
is any one of up, down, left, rightMotivation
There is already a module
stdlib_ansi
for ANSI escape codes of foreground, background colors and the different styles... If a person finds the use for such module it is very probable that he will also at some point want to control the cursor position too, to let's say, implement a custom loading animation or for elegant management of terminal outputSide note
I chose to make it a different module because of the difference in approach between the two, the functions in this module talk in terms of strings whereas
stdlib_ansi
has a whole type surrounding it and also because you won't need to add the cursor_ to all the functions to make it more readable... But I don't really see a problem in merging the two too...Edit: This is my first attempt at contributing here and I am not sure about who I am supposed to ask for feedback.. Could you guide me regarding this @perazz @jalvesz (I figured as you were the most active right now, hence pinging you would be appropriate)