• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* vi.c - You can't spell "evil" without "vi".
2  *
3  * Copyright 2015 Rob Landley <rob@landley.net>
4  *
5  * See http://pubs.opengroup.org/onlinepubs/9699919799/utilities/vi.html
6 
7 USE_VI(NEWTOY(vi, "<1>1", TOYFLAG_USR|TOYFLAG_BIN))
8 
9 config VI
10   bool "vi"
11   default n
12   help
13     usage: vi FILE
14 
15     Visual text editor. Predates the existence of standardized cursor keys,
16     so the controls are weird and historical.
17 */
18 
19 #define FOR_vi
20 #include "toys.h"
21 
22 GLOBALS(
23   struct linestack *ls;
24   char *statline;
25 )
26 
27 struct linestack_show {
28   struct linestack_show *next;
29   long top, left;
30   int x, width, y, height;
31 };
32 
33 // linestack, what to show, where to show it
linestack_show(struct linestack * ls,struct linestack_show * lss)34 void linestack_show(struct linestack *ls, struct linestack_show *lss)
35 {
36   return;
37 }
38 
vi_main(void)39 void vi_main(void)
40 {
41   int i;
42 
43   if (!(TT.ls = linestack_load(*toys.optargs)))
44     TT.ls = xzalloc(sizeof(struct linestack));
45 
46   for (i=0; i<TT.ls->len; i++)
47     printf("%.*s\n", (int)TT.ls->idx[i].len, (char *)TT.ls->idx[i].ptr);
48 }
49