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
40static Oevent_list events;40static Oevent_list events;
41static char filename[256];41static char filename[256];
42static Channel *cchan;42static Channel *cchan;
43static Field copyfield;
44static int altdown;
43 45
44static char *menu3i[] = {46static char *menu3i[] = {
45 "load",47 "load",
@@ -241,7 +243,7 @@ redraw(void) · 195 unmodified lines
241 243
242 /* insert/append mode */244 /* insert/append mode */
243 p.y += font->height;245 p.y += font->height;
244 len = runesprint(linebuf, "%s", insert ? "insert" : "append");246 len = runesprint(linebuf, "%s", altdown ? "slide " : (insert ? "insert" : "append"));
245 runestring(screen, p, display->white, ZP, font, linebuf);247 runestring(screen, p, display->white, ZP, font, linebuf);
246 248
247 /* bpm */249 /* bpm */
@@ -309,6 +311,34 @@ fieldset(Rune key) · 61 unmodified lines
309 }311 }
310}312}
311 313
314static void
315selmove(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
312static void342static void
313screensize(int *w, int *h)343screensize(int *w, int *h)
314{344{
@@ -391,13 +421,12 @@ void · 76 unmodified lines
391threadmain(int argc, char **argv)421threadmain(int argc, char **argv)
392{422{
393 Mousectl *mctl;423 Mousectl *mctl;
394 Field copyfield;
395 Key key;424 Key key;
396 Keyboardctl kctl;425 Keyboardctl kctl;
397 Mouse m;426 Mouse m;
398 char tmp[256];427 char tmp[256];
399 Channel *kchan;428 Channel *kchan;
400 int oldw, oldh, w, h, n, shiftdown, altdown;429 int oldw, oldh, w, h, n, shiftdown;
401 Alt a[] = {430 Alt a[] = {
402 { nil, &m, CHANRCV },431 { nil, &m, CHANRCV },
403 { nil, nil, CHANRCV },432 { nil, nil, CHANRCV },
@@ -427,7 +456,7 @@ threadmain(int argc, char **argv) · 23 unmodified lines
427 a[0].c = mctl->c;456 a[0].c = mctl->c;
428 a[1].c = mctl->resizec;457 a[1].c = mctl->resizec;
429 a[2].c = kchan;458 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);
431 a[4].c = cchan;460 a[4].c = cchan;
432 461
433 curbg = allocimage(display, Rect(0, 0, 1, 1), RGBA32, 1, setalpha(DYellow, 128));462 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
503 case Kup:532 case Kup:
504 if (shiftdown)533 if (shiftdown)
505 selh = MAX(1, selh-1);534 selh = MAX(1, selh-1);
506 else if (!altdown)535 else {
536 if (altdown)
537 selmove(0, -1);
507 cury = MAX(0, cury-1);538 cury = MAX(0, cury-1);
539 }
508 break;540 break;
509 case '\n': /* C-j */541 case '\n': /* C-j */
510 case Kdown:542 case Kdown:
511 if (shiftdown)543 if (shiftdown)
512 selh++;544 selh++;
513 else if (!altdown)545 else {
546 if (altdown)
547 selmove(0, 1);
514 cury = MIN(h-1, cury+1);548 cury = MIN(h-1, cury+1);
549 }
515 break;550 break;
516 case Kbs: /* C-h */551 case Kbs: /* C-h */
517 case Kleft:552 case Kleft:
518 if (shiftdown)553 if (shiftdown)
519 selw = MAX(1, selw-1);554 selw = MAX(1, selw-1);
520 else if (!altdown)555 else {
556 if (altdown)
557 selmove(-1, 0);
521 curx = MAX(0, curx-1);558 curx = MAX(0, curx-1);
559 }
522 break;560 break;
523 case 0x0c: /* C-l */561 case 0x0c: /* C-l */
524 case Kright:562 case Kright:
525 if (shiftdown)563 if (shiftdown)
526 selw++;564 selw++;
527 else if (!altdown)565 else {
566 if (altdown)
567 selmove(1, 0);
528 curx = MIN(w-1, curx+1);568 curx = MIN(w-1, curx+1);
569 }
529 break;570 break;
530 case Khome:571 case Khome:
531 curx = 0;572 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