diff options
author | Juan Manuel Tomás <jtomas1815@gmail.com> | 2020-07-16 21:17:16 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-16 21:17:16 -0300 |
commit | e3d20a08ffb3037beb63deea6c99490e2a24aa89 (patch) | |
tree | 05643f0a82db0a1f622dac6030b7d4bbc50e21c7 /jet2.cpp | |
parent | 2397212c306c63a5887ff67cc56ffae68d055d2f (diff) | |
parent | 905ae13aa12abc3fbbafc646a722b2d38bbeef8f (diff) | |
download | jet-e3d20a08ffb3037beb63deea6c99490e2a24aa89.tar.gz jet-e3d20a08ffb3037beb63deea6c99490e2a24aa89.zip |
Merge pull request #17 from jmtomas/5
Diffstat (limited to 'jet2.cpp')
-rw-r--r-- | jet2.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
@@ -33,6 +33,8 @@ int main(int argc, char *argv[]) { connect(s, (sockaddr *) &addr, sizeof(sockaddr_in)); int mode = NORMAL_MODE; + int cursor_x = 0; + int cursor_y = 0; int quit = 0; while (!quit) { @@ -47,6 +49,7 @@ int main(int argc, char *argv[]) { for (int i = 0; i < window_width * window_height; i++) { printw("%c", view[i]); } + move(cursor_y, cursor_x); int8_t mov[2]; int8_t del[1]; @@ -64,11 +67,33 @@ int main(int argc, char *argv[]) { mov[0] = OP_MOVE1; mov[1] = -1; write(s, mov, 2); + do { + if (cursor_x <= 0) { + if (cursor_y > 0) { + cursor_x = window_width - 1; + cursor_y--; + } + } else { + cursor_x--; + } + } while (view[pos(cursor_x, cursor_y)] == 0); break; case 'l': mov[0] = OP_MOVE1; mov[1] = 1; write(s, mov, 2); + do { + if (cursor_x >= window_width - 1) { + if (cursor_y < window_height - 1) { + cursor_x = 0; + cursor_y++; + } else { + break; + } + } else { + cursor_x++; + } + } while (view[pos(cursor_x, cursor_y)] == 0); break; } } else { |