mathtext poc: enable scrolling

This commit is contained in:
nick black 2020-04-07 16:20:08 -04:00
parent 2852ff736c
commit 312d15d0f9
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC
3 changed files with 14 additions and 5 deletions

View File

@ -63,6 +63,7 @@ int main(void){
std::unique_ptr<Plane> nstd(nc.get_stdplane());
int y, dimy, dimx;
nc.get_term_dim(&dimy, &dimx);
nstd->set_scrolling(true);
do{
nstd->putstr(c);
nstd->get_cursor_yx(&y, nullptr);

View File

@ -54,8 +54,7 @@ public:
#include "stain.h"
#include "lock.h"
#include "movedown.h"
#include "moveleft.h"
#include "moveright.h"
#include "movelateral.h"
#include "rotate.h"
private:

View File

@ -1,8 +1,9 @@
void MoveLeft() {
void MoveLateral(int direction) { // pass in -1 for left, 1 for right
int shift = 2 * direction;
const std::lock_guard<std::mutex> lock(mtx_);
int y, x;
if(PrepForMove(&y, &x)){
if(!curpiece_->move(y, x - 2)){
if(!curpiece_->move(y, x + shift)){
throw TetrisNotcursesErr("move()");
}
if(InvalidMove()){
@ -10,10 +11,18 @@ void MoveLeft() {
throw TetrisNotcursesErr("move()");
}
}else{
x -= 2;
x += shift;
if(!nc_.render()){
throw TetrisNotcursesErr("render()");
}
}
}
}
inline void MoveLeft() {
MoveLateral(-1);
}
inline void MoveRight() {
MoveLateral(1);
}