Open NonerKao opened 8 years ago
@NonerKao Thanks, I'll take a look at this within the next day or so!
Thanks for your consideration. Please let me explain this patch further.
The biggest change is the removal of local variable "currentLine" in function "wacceptch". Basically, the concept of "cursor location (a.k.a file pointer position)" and "current line" are equivilent to each other, as long as a variable for "bytes per line (variable BASE in this project)" is well maintained. When writing in this patch, I noticed that in acceptch.c, there was a almost non-functional global variable "currentLine", and a local variable with the same name in wacceptch(). I choose to delete the local one, such that the global one can be seen across these two files and most importantly, the convention of this project is to maintain many fundmental concepts of hex-editing using global variables.
If you are disagree with this, I will submit another PR with absolutely the same function, without deleting the "currentLine" variable in wacceptch().
This patch contains modifications to two source files, acceptch.c and screen.c.
In acceptch.c, there is a if-block on a global variable SIZE_CH, which is by default set to FALSE and only set to TRUE when handling the terminal resize signal. In previous versions, this block provided states initialization but no other functions, so resizable terminals was not supported. This patch fix these states, so that resize handler routine "checkScreenSize" in screen.c can update the states correctly.
In screen.c, this patch re-calculates key variables like "currentLine", remain the position after resizing a working terminal.
Known bugs:
I have try my best to keep the coding style consistent, but I think I will fire a corresponding issue recently, since the sources are so free-style.