summary refs log tree commit diff homepage
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2018-08-24 22:08:18 -0400
committerJune McEnroe <june@causal.agency>2018-08-24 22:08:18 -0400
commit2b5634094a6754b69f8bd90e21addbcd874d599e (patch)
tree7fe068d26ff8b115384abe83f934c536f3acbfbd
parentAdd copy and paste (diff)
downloadtorus-2b5634094a6754b69f8bd90e21addbcd874d599e.tar.gz
torus-2b5634094a6754b69f8bd90e21addbcd874d599e.zip
Separate 8, 9 and *, (
-rw-r--r--client.c30
1 files changed, 23 insertions, 7 deletions
diff --git a/client.c b/client.c
index 989c231..a4742b2 100644
--- a/client.c
+++ b/client.c
@@ -263,10 +263,11 @@ static void colorFg(uint8_t fg) {
 static void colorBg(uint8_t bg) {
 	input.color = (input.color & 0x0F) | (bg & 0x07) << 4;
 }
-static void colorInvert(void) {
-	input.color = (input.color & 0x08)
-		| (input.color & 0x70) >> 4
-		| (input.color & 0x07) << 4;
+
+static uint8_t colorInvert(uint8_t color) {
+	return (color & 0x08)
+		| (color & 0x70) >> 4
+		| (color & 0x07) << 4;
 }
 
 static void cellCopy(void) {
@@ -347,8 +348,8 @@ static void inputNormal(wchar_t ch) {
 		break; case '^': colorBg(COLOR_CYAN);
 		break; case '&': colorBg(COLOR_WHITE);
 
-		break; case '8': case '*': input.color ^= COLOR_BRIGHT;
-		break; case '9': case '(': colorInvert();
+		break; case '8': input.color ^= COLOR_BRIGHT;
+		break; case '9': input.color = colorInvert(input.color);
 		break; case '`': input.color = tile.colors[cellY][cellX];
 
 		break; case 'H': cellSwap(-1,  0);
@@ -361,13 +362,28 @@ static void inputNormal(wchar_t ch) {
 		break; case 'N': cellSwap( 1,  1);
 
 		break; case 's': cellCopy();
+		break; case 'x': cellCopy(); clientPut(copy.color, ' ');
 		break; case 'p': clientPut(copy.color, copy.cell);
 
-		break; case 'x': cellCopy(); clientPut(copy.color, ' ');
 		break; case '~': {
+			cellCopy();
 			clientPut(input.color, tile.cells[cellY][cellX]);
 			clientMove(1, 0);
 		}
+		break; case '*': {
+			clientPut(
+				tile.colors[cellY][cellX] ^ COLOR_BRIGHT,
+				tile.cells[cellY][cellX]
+			);
+			clientMove(1, 0);
+		}
+		break; case '(': {
+			clientPut(
+				colorInvert(tile.colors[cellY][cellX]),
+				tile.cells[cellY][cellX]
+			);
+			clientMove(1, 0);
+		}
 
 		break; case CTRL('A'): {
 			clientPut(tile.colors[cellY][cellX], tile.cells[cellY][cellX] + 1);