-
Notifications
You must be signed in to change notification settings - Fork 63
simplified for loop #82
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 fix in 4bb0f82 was due to a misstake in the old pull-request #68, I made the misstake there. I'll have to resolve that conflict in git, but will do that, after #81 was merged of closed. Like I said both is absolutely fine! I just did brain dead copy paste here, sorry for that! |
|
#87 is merged, you can go ahead and finish the PR now. |
|
done! |
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.
I think it looks good. It seems it is equivalent. I left some minor formatting suggestions.
cpp-terminal/terminal.h
Outdated
| } | ||
|
|
||
| void get_cursor_position(int& rows, int& cols) const | ||
| void get_cursor_position(int& rows, int& cols) const |
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.
| void get_cursor_position(int& rows, int& cols) const | |
| void get_cursor_position(int& rows, int& cols) const |
cpp-terminal/terminal.h
Outdated
| while (i < sizeof(buf) - 1) { | ||
| while (!read_raw(&buf[i])) { | ||
| }; | ||
| for (unsigned int i = 0; i < sizeof(buf) -1; i++) { |
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.
| for (unsigned int i = 0; i < sizeof(buf) -1; i++) { | |
| for (unsigned int i = 0; i < sizeof(buf) - 1; i++) { |
cpp-terminal/terminal.h
Outdated
| if (buf[i] == 'R') | ||
| { |
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.
| if (buf[i] == 'R') | |
| { | |
| if (buf[i] == 'R') { |
cpp-terminal/terminal.h
Outdated
| if (i < 5) | ||
| throw std::runtime_error("get_cursor_position(): too short response"); | ||
| else | ||
| buf[i] = '\0'; |
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.
| if (i < 5) | |
| throw std::runtime_error("get_cursor_position(): too short response"); | |
| else | |
| buf[i] = '\0'; | |
| if (i < 5) { | |
| throw std::runtime_error("get_cursor_position(): too short response"); | |
| } else { | |
| buf[i] = '\0'; | |
| } |
cpp-terminal/terminal.h
Outdated
| if (buf[i] == '\0') | ||
| break; |
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.
When you have multineline if / while statements, use {} to prevent a mistake in the future:
| if (buf[i] == '\0') | |
| break; | |
| if (buf[i] == '\0') { | |
| break; | |
| } |
Or put them on the same line:
| if (buf[i] == '\0') | |
| break; | |
| if (buf[i] == '\0') break; |
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.
about the {}, that's true, i sometimes forget that. There is a compiler waning on that btw.
|
about the formating: the code base has no real coding style. Sometimes I have seen 2 spaces, sometimes 4 spaces, sometimes a new line after curly brackets, sometimes there is none. We should really use clang format for that. Then there wont be such things to check anymore. |
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.
I think this looks good.
As introduced in #64 and implemented in #68: This pull-request tries to simplify the get_cursor_position() function. The code should be checked of logic mistakes. I have tried to just change the code, but don't touch the logic at all. I hope it's still intakt!