From 925c039fe2e871681de3379d46233a185bc3822d Mon Sep 17 00:00:00 2001 From: June McEnroe Date: Fri, 24 Aug 2018 20:43:09 -0400 Subject: Add copy and paste --- client.c | 89 +++++++++++++++++++++++++++++++++++++--------------------------- 1 file changed, 51 insertions(+), 38 deletions(-) diff --git a/client.c b/client.c index ba94410..989c231 100644 --- a/client.c +++ b/client.c @@ -219,6 +219,11 @@ static struct { .color = COLOR_WHITE, }; +static struct { + uint8_t color; + uint8_t cell; +} copy; + static struct { int8_t dx; int8_t dy; @@ -226,18 +231,18 @@ static struct { } insert; static void modeHelp(void) { - input.mode = MODE_HELP; - drawTile(HELP); curs_set(0); + drawTile(HELP); + input.mode = MODE_HELP; } static void modeNormal(void) { - input.mode = MODE_NORMAL; - move(cellY, cellX); curs_set(1); + move(cellY, cellX); + input.mode = MODE_NORMAL; } static void modeDraw(void) { - input.mode = MODE_DRAW; input.draw = 0; + input.mode = MODE_DRAW; } static void modeReplace(void) { input.mode = MODE_REPLACE; @@ -246,25 +251,30 @@ static void modeDirection(void) { input.mode = MODE_DIRECTION; } static void modeInsert(int8_t dx, int8_t dy) { - input.mode = MODE_INSERT; insert.dx = dx; insert.dy = dy; insert.len = 0; + input.mode = MODE_INSERT; } -static void inputFg(uint8_t fg) { +static void colorFg(uint8_t fg) { input.color = (input.color & 0x78) | (fg & 0x07); } -static void inputBg(uint8_t bg) { +static void colorBg(uint8_t bg) { input.color = (input.color & 0x0F) | (bg & 0x07) << 4; } -static void inputInvert(void) { +static void colorInvert(void) { input.color = (input.color & 0x08) | (input.color & 0x70) >> 4 | (input.color & 0x07) << 4; } -static void inputSwap(int8_t dx, int8_t dy) { +static void cellCopy(void) { + copy.color = tile.colors[cellY][cellX]; + copy.cell = tile.cells[cellY][cellX]; +} + +static void cellSwap(int8_t dx, int8_t dy) { if ((uint8_t)(cellX + dx) >= CELL_COLS) return; if ((uint8_t)(cellY + dy) >= CELL_ROWS) return; @@ -319,38 +329,41 @@ static void inputNormal(wchar_t ch) { break; case 'b': clientMove(-1, 1); break; case 'n': clientMove( 1, 1); - break; case '0': inputFg(COLOR_BLACK); - break; case '1': inputFg(COLOR_RED); - break; case '2': inputFg(COLOR_GREEN); - break; case '3': inputFg(COLOR_YELLOW); - break; case '4': inputFg(COLOR_BLUE); - break; case '5': inputFg(COLOR_MAGENTA); - break; case '6': inputFg(COLOR_CYAN); - break; case '7': inputFg(COLOR_WHITE); - - break; case ')': inputBg(COLOR_BLACK); - break; case '!': inputBg(COLOR_RED); - break; case '@': inputBg(COLOR_GREEN); - break; case '#': inputBg(COLOR_YELLOW); - break; case '$': inputBg(COLOR_BLUE); - break; case '%': inputBg(COLOR_MAGENTA); - break; case '^': inputBg(COLOR_CYAN); - break; case '&': inputBg(COLOR_WHITE); + break; case '0': colorFg(COLOR_BLACK); + break; case '1': colorFg(COLOR_RED); + break; case '2': colorFg(COLOR_GREEN); + break; case '3': colorFg(COLOR_YELLOW); + break; case '4': colorFg(COLOR_BLUE); + break; case '5': colorFg(COLOR_MAGENTA); + break; case '6': colorFg(COLOR_CYAN); + break; case '7': colorFg(COLOR_WHITE); + + break; case ')': colorBg(COLOR_BLACK); + break; case '!': colorBg(COLOR_RED); + break; case '@': colorBg(COLOR_GREEN); + break; case '#': colorBg(COLOR_YELLOW); + break; case '$': colorBg(COLOR_BLUE); + break; case '%': colorBg(COLOR_MAGENTA); + break; case '^': colorBg(COLOR_CYAN); + break; case '&': colorBg(COLOR_WHITE); break; case '8': case '*': input.color ^= COLOR_BRIGHT; - break; case '9': case '(': inputInvert(); + break; case '9': case '(': colorInvert(); break; case '`': input.color = tile.colors[cellY][cellX]; - break; case 'H': inputSwap(-1, 0); - break; case 'L': inputSwap( 1, 0); - break; case 'K': inputSwap( 0, -1); - break; case 'J': inputSwap( 0, 1); - break; case 'Y': inputSwap(-1, -1); - break; case 'U': inputSwap( 1, -1); - break; case 'B': inputSwap(-1, 1); - break; case 'N': inputSwap( 1, 1); + break; case 'H': cellSwap(-1, 0); + break; case 'L': cellSwap( 1, 0); + break; case 'K': cellSwap( 0, -1); + break; case 'J': cellSwap( 0, 1); + break; case 'Y': cellSwap(-1, -1); + break; case 'U': cellSwap( 1, -1); + break; case 'B': cellSwap(-1, 1); + break; case 'N': cellSwap( 1, 1); + + break; case 's': cellCopy(); + break; case 'p': clientPut(copy.color, copy.cell); - break; case 'x': clientPut(tile.colors[cellY][cellX], ' '); + break; case 'x': cellCopy(); clientPut(copy.color, ' '); break; case '~': { clientPut(input.color, tile.cells[cellY][cellX]); clientMove(1, 0); @@ -365,7 +378,7 @@ static void inputNormal(wchar_t ch) { break; case '?': modeHelp(); break; case 'R': modeDraw(); - break; case 'r': modeReplace(); + break; case 'r': modeReplace(); cellCopy(); break; case 'I': modeDirection(); break; case 'i': modeInsert(1, 0); break; case 'a': modeInsert(1, 0); clientMove(1, 0); -- cgit 1.4.1 298143f24c952941601183bbb616ae86b9ab&follow=1'>Allow setting exposures when loading filmJune McEnroe 2025-04-08Those were supposed to be en-dashes...June McEnroe 2025-04-08Generate pages per rollJune McEnroe 2025-04-08Add metadata from many rolls of filmJune McEnroe 2025-03-25Add emoji for lens, replace all f/'sJune McEnroe 2024-12-29Add photos from December 28June McEnroe 2024-12-29Fancify the manual lens textJune McEnroe 2024-12-28Update film preset list with what I expect to keep shootingJune McEnroe 2024-12-28Add the past few months of rolls of filmJune McEnroe 2024-11-13Add Tea with the Black DragonJune McEnroe I found this in a box on the side of the road being thrown own. It's decent pulp but nothing special. Not even as racist as I expected it to be. Also as one might guess, the author using their initials is a woman, so I only broke one of my rules when it comes to book selection. 2024-11-05Add a bunch of photosJune McEnroe 2024-10-12Publish "film review"June McEnroe 2024-10-12Add photos from October 6June McEnroe 2024-10-12Add photos from October 5June McEnroe 2024-10-09Add photos from October 1June McEnroe Ok the first 3 are from September 29 but I didn't want to spoil the black and white roll. 2024-10-07Add photos from September 29June McEnroe 2024-10-07Add photos from September 28June McEnroe 2024-10-07Add photos from September 22June McEnroe 2024-09-25Add photos from September 15June McEnroe 2024-09-24Add photos from September 14June McEnroe 2024-09-24Add photos from September 12June McEnroe 2024-09-24Add photos from September 7June McEnroe 2024-09-24Allow not having descriptionsJune McEnroe I'm sorry, I can't keep writing descriptions. It makes posting photos take too long, I often don't know the words for what I'm looking at, and a good description is an entirely different work of art than the photo I took, and I'm just a photographer. It's visual art. 2024-09-23Automatically select the last used lens for a bodyJune McEnroe 2024-09-19Add photos from September 5June McEnroe Had to prefix the folder number onto these file names manually because they must have come out of a different scanner or something. 2024-09-15Add some more film stocks to the listJune McEnroe 2024-09-13Add photos from September 2June McEnroe 2024-09-13Add Fomapan 200 to films listJune McEnroe 2024-09-10Add August 29 picnic photosJune McEnroe 2024-09-08Apply some bold to trips renderingJune McEnroe This seems easier to visually scan. The only other thing I'd like is a nicer date rendering but JavaScript is useless for that. 2024-09-08Render trips hopefully more efficientlyJune McEnroe 2024-09-08Allow removing bodies and lensesJune McEnroe 2024-09-08Limit body width so it looks less silly on desktopJune McEnroe 2024-09-07Handle no film being loadedJune McEnroe 2024-09-07Fancy up the text a littleJune McEnroe