Make lua selection boolean opers create a new selection

... instead of modifying one of the given selections.

Also add tests for the operations.
This commit is contained in:
Pasi Kallinen
2020-02-22 12:11:47 +02:00
parent e8ee044468
commit 42a05e9595
2 changed files with 129 additions and 20 deletions

View File

@@ -237,14 +237,16 @@ lua_State *L;
int x,y;
struct selectionvar *sela = l_selection_check(L, 1);
struct selectionvar *selb = l_selection_check(L, 2);
struct selectionvar *selr = l_selection_push(L);
for (x = 0; x < sela->wid; x++)
for (y = 0; y < sela->hei; y++) {
for (x = 0; x < selr->wid; x++)
for (y = 0; y < selr->hei; y++) {
int val = selection_getpoint(x, y, sela) & selection_getpoint(x, y, selb);
selection_setpoint(x, y, sela, val);
selection_setpoint(x, y, selr, val);
}
lua_settop(L, 1);
lua_remove(L, 1);
lua_remove(L, 1);
return 1;
}
@@ -256,14 +258,16 @@ lua_State *L;
int x,y;
struct selectionvar *sela = l_selection_check(L, 1);
struct selectionvar *selb = l_selection_check(L, 2);
struct selectionvar *selr = l_selection_push(L);
for (x = 0; x < sela->wid; x++)
for (y = 0; y < sela->hei; y++) {
for (x = 0; x < selr->wid; x++)
for (y = 0; y < selr->hei; y++) {
int val = selection_getpoint(x, y, sela) | selection_getpoint(x, y, selb);
selection_setpoint(x, y, sela, val);
selection_setpoint(x, y, selr, val);
}
lua_settop(L, 1);
lua_remove(L, 1);
lua_remove(L, 1);
return 1;
}
@@ -275,14 +279,16 @@ lua_State *L;
int x,y;
struct selectionvar *sela = l_selection_check(L, 1);
struct selectionvar *selb = l_selection_check(L, 2);
struct selectionvar *selr = l_selection_push(L);
for (x = 0; x < sela->wid; x++)
for (y = 0; y < sela->hei; y++) {
for (x = 0; x < selr->wid; x++)
for (y = 0; y < selr->hei; y++) {
int val = selection_getpoint(x, y, sela) ^ selection_getpoint(x, y, selb);
selection_setpoint(x, y, sela, val);
selection_setpoint(x, y, selr, val);
}
lua_settop(L, 1);
lua_remove(L, 1);
lua_remove(L, 1);
return 1;
}