History

plan9: sliding mode

Sigrid Haflínudóttir committed 6 years ago

Commit e97ec5a1 parent 91d13851 file · +49 −8Browse files

Unified · Split

plan9.c+49−8
@@ -40,6 +40,8 @@ static Mbuf_reusable mbuf; · 39 unmodified lines
4040 static Oevent_list events;
4141 static char filename[256];
4242 static Channel *cchan;
43+static Field copyfield;
44+static int altdown;
4345
4446 static char *menu3i[] = {
4547 "load",
@@ -241,7 +243,7 @@ redraw(void) · 195 unmodified lines
241243
242244 /* insert/append mode */
243245 p.y += font->height;
244− len = runesprint(linebuf, "%s", insert ? "insert" : "append");
246+ len = runesprint(linebuf, "%s", altdown ? "slide " : (insert ? "insert" : "append"));
245247 runestring(screen, p, display->white, ZP, font, linebuf);
246248
247249 /* bpm */
@@ -309,6 +311,34 @@ fieldset(Rune key) · 61 unmodified lines
309311 }
310312 }
311313
314+static void
315+selmove(int x, int y)
316+{
317+ int i;
318+
319+ field_resize_raw(&copyfield, selh, selw);
320+ gbuffer_copy_subrect(
321+ field.buffer,
322+ copyfield.buffer,
323+ field.height, field.width,
324+ copyfield.height, copyfield.width,
325+ cury, curx, 0, 0,
326+ selh, selw
327+ );
328+
329+ for (i = cury; i < cury+selh; i++)
330+ memset(&field.buffer[curx + field.width*i], '.', selw);
331+
332+ gbuffer_copy_subrect(
333+ copyfield.buffer,
334+ field.buffer,
335+ copyfield.height, copyfield.width,
336+ field.height, field.width,
337+ 0, 0, cury+y, curx+x,
338+ selh, selw
339+ );
340+}
341+
312342 static void
313343 screensize(int *w, int *h)
314344 {
@@ -391,13 +421,12 @@ void · 76 unmodified lines
391421 threadmain(int argc, char **argv)
392422 {
393423 Mousectl *mctl;
394− Field copyfield;
395424 Key key;
396425 Keyboardctl kctl;
397426 Mouse m;
398427 char tmp[256];
399428 Channel *kchan;
400− int oldw, oldh, w, h, n, shiftdown, altdown;
429+ int oldw, oldh, w, h, n, shiftdown;
401430 Alt a[] = {
402431 { nil, &m, CHANRCV },
403432 { nil, nil, CHANRCV },
@@ -427,7 +456,7 @@ threadmain(int argc, char **argv) · 23 unmodified lines
427456 a[0].c = mctl->c;
428457 a[1].c = mctl->resizec;
429458 a[2].c = kchan;
430− a[3].c = chancreate(sizeof(ulong), 0); /* FIXME should it be buffered instead? */
459+ a[3].c = chancreate(sizeof(ulong), 0);
431460 a[4].c = cchan;
432461
433462 curbg = allocimage(display, Rect(0, 0, 1, 1), RGBA32, 1, setalpha(DYellow, 128));
@@ -503,29 +532,41 @@ threadmain(int argc, char **argv) · 69 unmodified lines
503532 case Kup:
504533 if (shiftdown)
505534 selh = MAX(1, selh-1);
506− else if (!altdown)
535+ else {
536+ if (altdown)
537+ selmove(0, -1);
507538 cury = MAX(0, cury-1);
539+ }
508540 break;
509541 case '\n': /* C-j */
510542 case Kdown:
511543 if (shiftdown)
512544 selh++;
513− else if (!altdown)
545+ else {
546+ if (altdown)
547+ selmove(0, 1);
514548 cury = MIN(h-1, cury+1);
549+ }
515550 break;
516551 case Kbs: /* C-h */
517552 case Kleft:
518553 if (shiftdown)
519554 selw = MAX(1, selw-1);
520− else if (!altdown)
555+ else {
556+ if (altdown)
557+ selmove(-1, 0);
521558 curx = MAX(0, curx-1);
559+ }
522560 break;
523561 case 0x0c: /* C-l */
524562 case Kright:
525563 if (shiftdown)
526564 selw++;
527− else if (!altdown)
565+ else {
566+ if (altdown)
567+ selmove(1, 0);
528568 curx = MIN(w-1, curx+1);
569+ }
529570 break;
530571 case Khome:
531572 curx = 0;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t