diff options
Diffstat (limited to 'src/boxes/boxes.c')
-rw-r--r-- | src/boxes/boxes.c | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/src/boxes/boxes.c b/src/boxes/boxes.c index 4f542e1..b1c6e55 100644 --- a/src/boxes/boxes.c +++ b/src/boxes/boxes.c | |||
@@ -58,7 +58,7 @@ GLOBALS( | |||
58 | * The things it is targeting are - vi and more (part of the standards, so | 58 | * The things it is targeting are - vi and more (part of the standards, so |
59 | * part of the toybox TODO), less (also on the toybox TODO), joe and | 59 | * part of the toybox TODO), less (also on the toybox TODO), joe and |
60 | * wordstar (coz Rob said they would be good to include), nano (again Rob | 60 | * wordstar (coz Rob said they would be good to include), nano (again Rob |
61 | * thinks it would be good and I agree), microemacs (to avoid religous | 61 | * thinks it would be good and I agree), microemacs (to avoid religious |
62 | * wars), and mcedit (coz that's what I actually use). The ex editor comes | 62 | * wars), and mcedit (coz that's what I actually use). The ex editor comes |
63 | * along for the ride coz vi is basically a screen editor wrapper around | 63 | * along for the ride coz vi is basically a screen editor wrapper around |
64 | * the ex line editor. Sed might be supported coz I'll need to do basic | 64 | * the ex line editor. Sed might be supported coz I'll need to do basic |
@@ -117,7 +117,7 @@ GLOBALS( | |||
117 | * few examples. A context holds a list of command to C function mappings, | 117 | * few examples. A context holds a list of command to C function mappings, |
118 | * key to command mappings, and a list of modes. | 118 | * key to command mappings, and a list of modes. |
119 | * | 119 | * |
120 | * Most of the editors targetted include a command line where the user | 120 | * Most of the editors targeted include a command line where the user |
121 | * types in editor commands, and each of those editors has different | 121 | * types in editor commands, and each of those editors has different |
122 | * commands. They would mostly use the same editing C functions though, or | 122 | * commands. They would mostly use the same editing C functions though, or |
123 | * short wrappers around them. The vi context at the end of this file is a | 123 | * short wrappers around them. The vi context at the end of this file is a |
@@ -132,7 +132,7 @@ GLOBALS( | |||
132 | * menu to command mappings, and a list of displayed key/command pairs. | 132 | * menu to command mappings, and a list of displayed key/command pairs. |
133 | * Menu and key/command pair display is not written yet. Most editors have | 133 | * Menu and key/command pair display is not written yet. Most editors have |
134 | * a system for remapping key to command mappings, that's not supported | 134 | * a system for remapping key to command mappings, that's not supported |
135 | * yet. Emacs has a heirarchy of key to command mappings, that's not | 135 | * yet. Emacs has a hierarchy of key to command mappings, that's not |
136 | * supported yet. Some twiddling of the current design would be needed for | 136 | * supported yet. Some twiddling of the current design would be needed for |
137 | * those. | 137 | * those. |
138 | * | 138 | * |
@@ -159,7 +159,7 @@ GLOBALS( | |||
159 | * command" function. Using most of the system with not much special casing. | 159 | * command" function. Using most of the system with not much special casing. |
160 | * | 160 | * |
161 | * | 161 | * |
162 | * I assume that there wont be a terribly large number of boxes. | 162 | * I assume that there won't be a terribly large number of boxes. |
163 | * Things like minimum box sizes, current maximum screen sizes, and the fact | 163 | * Things like minimum box sizes, current maximum screen sizes, and the fact |
164 | * that they all have to be on the screen mean that this assumption should | 164 | * that they all have to be on the screen mean that this assumption should |
165 | * be safe. It's likely that most of the time there will be only a few at | 165 | * be safe. It's likely that most of the time there will be only a few at |
@@ -174,7 +174,7 @@ GLOBALS( | |||
174 | * My usual terminal is 104 x 380 characters. | 174 | * My usual terminal is 104 x 380 characters. |
175 | * There will be people with bigger monitors and smaller fonts. | 175 | * There will be people with bigger monitors and smaller fonts. |
176 | * So use sixteen bits for storing screen positions and the like. | 176 | * So use sixteen bits for storing screen positions and the like. |
177 | * Eight bits wont cut it. | 177 | * Eight bits won't cut it. |
178 | * | 178 | * |
179 | * | 179 | * |
180 | * These are the escape sequences we send - | 180 | * These are the escape sequences we send - |
@@ -222,7 +222,7 @@ editing the contents of those lines, one line at a time. For persistent | |||
222 | line history, they both have to save and load those lines to a file. | 222 | line history, they both have to save and load those lines to a file. |
223 | Other than that "readline" adds other behaviour, like moving the | 223 | Other than that "readline" adds other behaviour, like moving the |
224 | current line to the end when you hit return and presenting that line to | 224 | current line to the end when you hit return and presenting that line to |
225 | the caller (here's the command). So just making "readline" wont cut | 225 | the caller (here's the command). So just making "readline" won't cut |
226 | out much of the code. In fact, my "readline" is really just a thin | 226 | out much of the code. In fact, my "readline" is really just a thin |
227 | wrapper around the rest of the code. | 227 | wrapper around the rest of the code. |
228 | 228 | ||
@@ -257,7 +257,7 @@ On Thu, 27 Dec 2012 06:06:53 -0600 Rob Landley <rob@landley.net> wrote: | |||
257 | > On 12/27/2012 12:56:07 AM, David Seikel wrote: | 257 | > On 12/27/2012 12:56:07 AM, David Seikel wrote: |
258 | > > On Thu, 27 Dec 2012 00:37:46 -0600 Rob Landley <rob@landley.net> | 258 | > > On Thu, 27 Dec 2012 00:37:46 -0600 Rob Landley <rob@landley.net> |
259 | > > wrote: | 259 | > > wrote: |
260 | > > > Since ls isn't doiing any of that, probing would just be awkward | 260 | > > > Since ls isn't doing any of that, probing would just be awkward |
261 | > > > so toysh should set COLUMNS to a sane value. The problem is, | 261 | > > > so toysh should set COLUMNS to a sane value. The problem is, |
262 | > > > we're not using toysh yet because it's still just a stub... | 262 | > > > we're not using toysh yet because it's still just a stub... |
263 | > > | 263 | > > |
@@ -378,7 +378,7 @@ struct context // Defines a context for content. Text viewer, editor, file br | |||
378 | { | 378 | { |
379 | struct function *commands; // The master list, the ones pointed to by the menus etc should be in this list. | 379 | struct function *commands; // The master list, the ones pointed to by the menus etc should be in this list. |
380 | struct mode *modes; // A possible empty array of modes, indexed by the view. | 380 | struct mode *modes; // A possible empty array of modes, indexed by the view. |
381 | // OR might be better to have these as a linked list, so that things like Emacs can have it's mode keymap hierarcy. | 381 | // OR might be better to have these as a linked list, so that things like Emacs can have it's mode keymap hierarchy. |
382 | eventHandler handler; // TODO - Might be better to put this in the modes. I think vi will need that. | 382 | eventHandler handler; // TODO - Might be better to put this in the modes. I think vi will need that. |
383 | // Should set the damage list if it needs a redraw, and flags if border or status line needs updating. | 383 | // Should set the damage list if it needs a redraw, and flags if border or status line needs updating. |
384 | // Keyboard / mouse events if the box did not handle them itself. | 384 | // Keyboard / mouse events if the box did not handle them itself. |
@@ -412,7 +412,7 @@ struct damage | |||
412 | { | 412 | { |
413 | struct damage *next; // A list for faster draws? | 413 | struct damage *next; // A list for faster draws? |
414 | uint16_t X, Y, W, H; // The rectangle to be redrawn. | 414 | uint16_t X, Y, W, H; // The rectangle to be redrawn. |
415 | uint16_t offset; // Offest from the left for showing lines. | 415 | uint16_t offset; // Offset from the left for showing lines. |
416 | struct line *lines; // Pointer to a list of text lines, or NULL. | 416 | struct line *lines; // Pointer to a list of text lines, or NULL. |
417 | // Note - likely a pointer into the middle of the line list in a content. | 417 | // Note - likely a pointer into the middle of the line list in a content. |
418 | }; | 418 | }; |
@@ -462,7 +462,7 @@ struct _box | |||
462 | { | 462 | { |
463 | box *sub1, *sub2, *parent; | 463 | box *sub1, *sub2, *parent; |
464 | view *view; // This boxes view into it's content. For sharing contents, like a split pane editor for instance, there might be more than one box with this content, but a different view. | 464 | view *view; // This boxes view into it's content. For sharing contents, like a split pane editor for instance, there might be more than one box with this content, but a different view. |
465 | // If it's just a parent box, it wont have this, so just make it a damn pointer, that's the simplest thing. lol | 465 | // If it's just a parent box, it won't have this, so just make it a damn pointer, that's the simplest thing. lol |
466 | // TODO - Are parent boxes getting a view anyway? | 466 | // TODO - Are parent boxes getting a view anyway? |
467 | uint16_t X, Y, W, H; // Position and size of the box itself, not the content. Calculated, but cached coz that might be needed for speed. | 467 | uint16_t X, Y, W, H; // Position and size of the box itself, not the content. Calculated, but cached coz that might be needed for speed. |
468 | float split; // Ratio of sub1's part of the split, the sub2 box gets the rest. | 468 | float split; // Ratio of sub1's part of the split, the sub2 box gets the rest. |
@@ -475,7 +475,7 @@ void drawBox(box *box); | |||
475 | 475 | ||
476 | 476 | ||
477 | #define BOX_HSPLIT 1 // Marks if it's a horizontally or vertically split. | 477 | #define BOX_HSPLIT 1 // Marks if it's a horizontally or vertically split. |
478 | #define BOX_BORDER 2 // Mark if it has a border, often full screen boxes wont. | 478 | #define BOX_BORDER 2 // Mark if it has a border, often full screen boxes won't. |
479 | 479 | ||
480 | static int overWriteMode; | 480 | static int overWriteMode; |
481 | static box *rootBox; // Parent of the rest of the boxes, or the only box. Always a full screen. | 481 | static box *rootBox; // Parent of the rest of the boxes, or the only box. Always a full screen. |
@@ -543,7 +543,7 @@ void loadFile(struct content *content) | |||
543 | 543 | ||
544 | do | 544 | do |
545 | { | 545 | { |
546 | // TODO - get_line() is slow, and wont help much with DOS and Mac line endings. | 546 | // TODO - get_line() is slow, and won't help much with DOS and Mac line endings. |
547 | temp = get_line(fd); | 547 | temp = get_line(fd); |
548 | if (temp) | 548 | if (temp) |
549 | addLine(content, NULL, temp, len); | 549 | addLine(content, NULL, temp, len); |
@@ -691,7 +691,7 @@ void drawLine(int y, int start, int end, char *left, char *internal, char *conte | |||
691 | 691 | ||
692 | if (contents) | 692 | if (contents) |
693 | { | 693 | { |
694 | // strncpy wont add a null at the end if the source is longer, but will pad with nulls if source is shorter. | 694 | // strncpy won't add a null at the end if the source is longer, but will pad with nulls if source is shorter. |
695 | // So it's best to put a safety null in first. | 695 | // So it's best to put a safety null in first. |
696 | line[len] = '\0'; | 696 | line[len] = '\0'; |
697 | strncpy(line, contents, len); | 697 | strncpy(line, contents, len); |
@@ -955,7 +955,7 @@ int moveCursorAbsolute(view *view, long cX, long cY, long sX, long sY) | |||
955 | } | 955 | } |
956 | else if (lX < cX) // Trying to move beyond end of line. | 956 | else if (lX < cX) // Trying to move beyond end of line. |
957 | { | 957 | { |
958 | // See if we can move to the begining of the next line. | 958 | // See if we can move to the beginning of the next line. |
959 | if (view->line->next != &(view->content->lines)) | 959 | if (view->line->next != &(view->content->lines)) |
960 | { | 960 | { |
961 | cY++; | 961 | cY++; |
@@ -1147,7 +1147,7 @@ void drawBox(box *box) | |||
1147 | bchars = (toys.optflags & FLAG_a) ? borderCharsCurrent[0] : borderCharsCurrent[1]; | 1147 | bchars = (toys.optflags & FLAG_a) ? borderCharsCurrent[0] : borderCharsCurrent[1]; |
1148 | 1148 | ||
1149 | // Slow and laborious way to figure out where in the linked list of lines we start from. | 1149 | // Slow and laborious way to figure out where in the linked list of lines we start from. |
1150 | // Wont scale well, but is simple. | 1150 | // Won't scale well, but is simple. |
1151 | if (box->view && box->view->content) | 1151 | if (box->view && box->view->content) |
1152 | { | 1152 | { |
1153 | int i = box->view->offsetY; | 1153 | int i = box->view->offsetY; |
@@ -1352,7 +1352,7 @@ void splitBox(box *box, float split) | |||
1352 | } | 1352 | } |
1353 | 1353 | ||
1354 | // Note that a split box is actually three boxes. The parent, which is not drawn, and the two subs, which are. | 1354 | // Note that a split box is actually three boxes. The parent, which is not drawn, and the two subs, which are. |
1355 | // Based on the assumption that there wont be lots of boxes, this keeps things simple. | 1355 | // Based on the assumption that there won't be lots of boxes, this keeps things simple. |
1356 | // It's possible that the box has already been split, and this is called just to update the split. | 1356 | // It's possible that the box has already been split, and this is called just to update the split. |
1357 | box->split = split; | 1357 | box->split = split; |
1358 | if (NULL == box->sub1) // If not split already, do so. | 1358 | if (NULL == box->sub1) // If not split already, do so. |
@@ -2405,7 +2405,7 @@ void boxes_main(void) | |||
2405 | context = &simpleVi; | 2405 | context = &simpleVi; |
2406 | } | 2406 | } |
2407 | 2407 | ||
2408 | // TODO - Should do an isatty() here, though not sure about the usefullness of driving this from a script or redirected input, since it's supposed to be a UI for terminals. | 2408 | // TODO - Should do an isatty() here, though not sure about the usefulness of driving this from a script or redirected input, since it's supposed to be a UI for terminals. |
2409 | // It would STILL need the terminal size for output though. Perhaps just bitch and abort if it's not a tty? | 2409 | // It would STILL need the terminal size for output though. Perhaps just bitch and abort if it's not a tty? |
2410 | // On the other hand, sed don't need no stinkin' UI. And things like more or less should be usable on the end of a pipe. | 2410 | // On the other hand, sed don't need no stinkin' UI. And things like more or less should be usable on the end of a pipe. |
2411 | 2411 | ||
@@ -2440,7 +2440,7 @@ void boxes_main(void) | |||
2440 | 2440 | ||
2441 | IGNBRK ignore BREAK | 2441 | IGNBRK ignore BREAK |
2442 | BRKINT complicated, bet in this context, sends BREAK as '\x00' | 2442 | BRKINT complicated, bet in this context, sends BREAK as '\x00' |
2443 | PARMRK characters with parity or frame erors are sent as '\x00' | 2443 | PARMRK characters with parity or frame errors are sent as '\x00' |
2444 | ISTRIP strip 8th byte | 2444 | ISTRIP strip 8th byte |
2445 | INLCR translate LF to CR in input | 2445 | INLCR translate LF to CR in input |
2446 | IGLCR ignore CR | 2446 | IGLCR ignore CR |
@@ -2490,7 +2490,7 @@ void boxes_main(void) | |||
2490 | // http://leonerds-code.blogspot.co.uk/2012/04/wide-mouse-support-in-libvterm.html is helpful. | 2490 | // http://leonerds-code.blogspot.co.uk/2012/04/wide-mouse-support-in-libvterm.html is helpful. |
2491 | // Enable mouse (VT200 normal tracking mode, UTF8 encoding). The limit is 2015. Seems to only be in later xterms. | 2491 | // Enable mouse (VT200 normal tracking mode, UTF8 encoding). The limit is 2015. Seems to only be in later xterms. |
2492 | // fputs("\x1B[?1005h", stdout); | 2492 | // fputs("\x1B[?1005h", stdout); |
2493 | // Enable mouse (VT340 locator reporting mode). In theory has no limit. Wont actually work though. | 2493 | // Enable mouse (VT340 locator reporting mode). In theory has no limit. Won't actually work though. |
2494 | // On the other hand, only allows for four buttons, so only half a mouse wheel. | 2494 | // On the other hand, only allows for four buttons, so only half a mouse wheel. |
2495 | // Responds with "\1B[e;p;r;c;p&w" where e is event type, p is a bitmap of buttons pressed, r and c are the mouse coords in decimal, and p is the "page number". | 2495 | // Responds with "\1B[e;p;r;c;p&w" where e is event type, p is a bitmap of buttons pressed, r and c are the mouse coords in decimal, and p is the "page number". |
2496 | // fputs("\x1B[1;2'z\x1B[1;3'{", stdout); | 2496 | // fputs("\x1B[1;2'z\x1B[1;3'{", stdout); |