ref: 370b8838b4b63a5621e5b4756dcb65f1c14542fe
parent: 01272ec75cde8d296d2749ecd377af1e3bd5a9df
author: Sigrid Haflínudóttir <ftrvxmtrx@gmail.com>
date: Sun Mar 8 19:41:32 EDT 2020
plan9: add "inject" cmd
--- a/orca.man
+++ b/orca.man
@@ -259,6 +259,9 @@
Injects a file at the cursor position or at
.I X,Y
if specified
+.TP
+.B select X Y [W] [H]
+Select the specified rectangle.
.PP
.I Orca
treats
--- a/plan9.c
+++ b/plan9.c
@@ -472,6 +472,25 @@
}
static void
+selext(int xdt, int ydt)
+{
+ if (sel.max.x > cur.x || (sel.min.x == cur.x && xdt > 0))
+ sel.max.x += xdt;
+ else
+ sel.min.x += xdt;
+
+ if (sel.max.y > cur.y || (sel.min.y == cur.y && ydt > 0))
+ sel.max.y += ydt;
+ else
+ sel.min.y += ydt;
+
+ sel.min.x = MAX(0, MIN((int)field.width-1, sel.min.x));
+ sel.max.x = MAX(0, MIN((int)field.width-1, sel.max.x));
+ sel.min.y = MAX(0, MIN((int)field.height-1, sel.min.y));
+ sel.max.y = MAX(0, MIN((int)field.height-1, sel.max.y));
+}
+
+static void
command(char *s, void (*snapshot)(void))
{
char tmp[256], *argv[8];
@@ -542,7 +561,14 @@
netdial(nil, argv[1]);
else if (s[0] == 'm' && s[1] == 'i') /* midi */
midiopen(argv[1]);
- else if (s[0] == 'i' && s[1] == 'n' && argc > 1) {
+ else if (s[0] == 's' && s[1] == 'e' && argc > 2) { /* select */
+ cur = ZP;
+ sel = ZR;
+ curmove(atoi(argv[1]), atoi(argv[2]));
+ x = argc > 3 ? atoi(argv[3]) : 0;
+ y = argc > 4 ? atoi(argv[4]) : 0;
+ selext(x, y);
+ } else if (s[0] == 'i' && s[1] == 'n') { /* inject */
snapshot();
if (argc > 2) {
cur.x = 0;
@@ -563,7 +589,7 @@
fieldset(x, y, *s);
}
- /* FIXME color, find, select, time */
+ /* FIXME color, find, time */
}
}
@@ -1166,25 +1192,6 @@
}
threadexits(nil);
-}
-
-static void
-selext(int xdt, int ydt)
-{
- if (sel.max.x > cur.x || (sel.min.x == cur.x && xdt > 0))
- sel.max.x += xdt;
- else
- sel.min.x += xdt;
-
- if (sel.max.y > cur.y || (sel.min.y == cur.y && ydt > 0))
- sel.max.y += ydt;
- else
- sel.min.y += ydt;
-
- sel.min.x = MAX(0, MIN((int)field.width-1, sel.min.x));
- sel.max.x = MAX(0, MIN((int)field.width-1, sel.max.x));
- sel.min.y = MAX(0, MIN((int)field.height-1, sel.min.y));
- sel.max.y = MAX(0, MIN((int)field.height-1, sel.max.y));
}
static Point