summary refs log tree commit diff
path: root/bin/psfed.c
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2018-09-27 13:16:22 -0400
committerJune McEnroe <june@causal.agency>2018-09-27 13:16:22 -0400
commitfa9e80ea0307761dac0d06b0d7514f28db6e26e7 (patch)
treef9661ca652671895f625d4243e7b0b7bdfbca75f /bin/psfed.c
parentMove psfed paste to edit mode (diff)
downloadsrc-fa9e80ea0307761dac0d06b0d7514f28db6e26e7.tar.gz
src-fa9e80ea0307761dac0d06b0d7514f28db6e26e7.zip
Add HJKL for moving glyphs to psfed
Diffstat (limited to 'bin/psfed.c')
-rw-r--r--bin/psfed.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/bin/psfed.c b/bin/psfed.c
index db61c714..8cf792da 100644
--- a/bin/psfed.c
+++ b/bin/psfed.c
@@ -188,6 +188,10 @@ static uint8_t bitGet(uint32_t index, uint32_t x, uint32_t y) {
 static void bitFlip(uint32_t index, uint32_t x, uint32_t y) {
 	*bitByte(index, x, y) ^= 1 << (7 - x % 8);
 }
+static void bitSet(uint32_t index, uint32_t x, uint32_t y, uint8_t bit) {
+	*bitByte(index, x, y) &= ~(1 << (7 - x % 8));
+	*bitByte(index, x, y) |= bit << (7 - x % 8);
+}
 
 static void drawGlyph(
 	uint32_t destX, uint32_t destY, uint32_t scale,
@@ -344,6 +348,7 @@ static void inputEdit(char ch) {
 		break; case 'k': if (edit.y) edit.y--;
 		break; case 'j': if (edit.y + 1 < header.glyph.height) edit.y++;
 		break; case ' ': bitFlip(edit.index, edit.x, edit.y);
+
 		break; case 'r': {
 			for (uint32_t y = 0; y < header.glyph.height; ++y) {
 				for (uint32_t x = 0; x < header.glyph.width; ++x) {
@@ -351,6 +356,57 @@ static void inputEdit(char ch) {
 				}
 			}
 		}
+
+		break; case 'H': {
+			for (uint32_t x = 0; x < header.glyph.width; ++x) {
+				for (uint32_t y = 0; y < header.glyph.height; ++y) {
+					if (x + 1 < header.glyph.width) {
+						bitSet(edit.index, x, y, bitGet(edit.index, x + 1, y));
+					} else {
+						bitSet(edit.index, x, y, 0);
+					}
+				}
+			}
+		}
+
+		break; case 'L': {
+			uint32_t width = header.glyph.width;
+			for (uint32_t x = width - 1; x < width; --x) {
+				for (uint32_t y = 0; y < header.glyph.height; ++y) {
+					if (x - 1 < width) {
+						bitSet(edit.index, x, y, bitGet(edit.index, x - 1, y));
+					} else {
+						bitSet(edit.index, x, y, 0);
+					}
+				}
+			}
+		}
+
+		break; case 'K': {
+			for (uint32_t y = 0; y < header.glyph.height; ++y) {
+				for (uint32_t x = 0; x < header.glyph.width; ++x) {
+					if (y + 1 < header.glyph.height) {
+						bitSet(edit.index, x, y, bitGet(edit.index, x, y + 1));
+					} else {
+						bitSet(edit.index, x, y, 0);
+					}
+				}
+			}
+		}
+
+		break; case 'J': {
+			uint32_t height = header.glyph.height;
+			for (uint32_t y = height - 1; y < height; --y) {
+				for (uint32_t x = 0; x < header.glyph.width; ++x) {
+					if (y - 1 < height) {
+						bitSet(edit.index, x, y, bitGet(edit.index, x, y - 1));
+					} else {
+						bitSet(edit.index, x, y, 0);
+					}
+				}
+			}
+		}
+
 		break; case 'p': {
 			memcpy(glyph(edit.index), edit.copy, header.glyph.size);
 		}