ExpandTabs = !ExpandTabs;
}
-static void indent(char* arg)
-{
- (void)arg;
- CopyIndent = !CopyIndent;
-}
-
-static void eol_mode(char* arg)
-{
- (void)arg;
- DosLineFeed = !DosLineFeed;
- View* view = win_view(EDIT);
- view_selectall(view);
- char* txt = view_getstr(view);
- view_putstr(view, txt);
- free(txt);
-}
-
static void new_win(char* arg)
{
(void)arg;
exec_cmdwarg(cmd, NULL);
}
-static void tag_kill(char* cmd)
-{
- (void)cmd;
- Job* job = job_list();
- if (job && job->fd != ConnectionNumber(X.display))
- job_kill(job);
-}
-
static void tag_line(char* cmd)
{
(void)cmd;
{ .tag = "Cut", .action = cut },
{ .tag = "Copy", .action = copy },
{ .tag = "Del", .action = quit },
- { .tag = "Eol", .action = eol_mode },
{ .tag = "Find", .action = find },
{ .tag = "GoTo", .action = jump_to },
{ .tag = "Get", .action = get },
- { .tag = "Indent", .action = indent },
{ .tag = "New", .action = new_win },
{ .tag = "Paste", .action = paste },
{ .tag = "Put", .action = put },
{ .tag = "Tabs", .action = tabs },
{ .tag = "Undo", .action = tag_undo },
{ .tag = "Font", .action = win_font },
- { .tag = "Kill", .action = tag_kill },
{ .tag = "Line", .action = tag_line },
{ .tag = "Scroll", .action = do_scroll },
{ .tag = NULL, .action = NULL }
};
#ifndef TEST
-static void usage(void)
-{
- printf(
- "Usage: %s [FLAGS] [FILE]\n"
- "\n -I 0,1 Enable/disable automatic indenting"
- "\n -W 0,1 Enable/disable trimming whitespace on save"
- "\n -E 0,1 Enable/disable expanding tabs to spaces"
- "\n -N 0,1 Enable/disable dos line ending style"
- "\n -T str String to use for the tags region"
- "\n -C str Set the shell to use for command execution\n"
- "\n -c cmd Runs command interactively in the window\n",
- ARGV0);
- exit(1);
-}
-
static void edit_file(char* file, int line_num)
{
+ printf("%s\n", file);
file = File_AbsolutePath(file);
+ printf("%s\n", file);
if (!strcmp("-", file))
{
job_readfd(STDIN_FILENO, win_view(EDIT));
free(file);
}
-int main(int argc, char** argv)
+/* Main Routine
+ ***************************************************************************/
+
+char* termcmd = NULL;
+long int line_num = 0;
+
+Option_T Options[] = {
+ { .s = 'h', .l = "help", .a = 0, .d = "print this help message" },
+ { .s = 'T', .l = "tags", .a = 1, .d = "set tag region contents" },
+ { .s = 'S', .l = "shell", .a = 1, .d = "command interpreter to use" },
+ { .s = 'c', .l = "cmd", .a = 1, .d = "execute given command" },
+ { .s = 'l', .l = "line", .a = 1, .d = "jump to specified line" },
+ {0}
+};
+
+void set_option(Int s, char* l, char* arg)
{
- char* termcmd = NULL;
- long int line_num = 0;
- #define BOOLARG() (EOPTARG(usage()), optarg_[0] == '0' ? 0 : 1)
- #define STRARG() (EOPTARG(usage()))
- #define NUMARG() (strtoul(EOPTARG(usage()),0,0))
- OPTBEGIN
+ switch(s)
{
- case 'I': CopyIndent = BOOLARG(); break;
- case 'W': TrimOnSave = BOOLARG(); break;
- case 'E': ExpandTabs = BOOLARG(); break;
- case 'N': DosLineFeed = BOOLARG(); break;
- case 'T': TagString = STRARG(); break;
- case 'S': ShellCmd[0] = STRARG(); break;
- case 'c': termcmd = STRARG(); break;
- case 'l': line_num = NUMARG(); break;
- default: usage(); break;
+ case 'T': TagString = arg; break;
+ case 'S': ShellCmd[0] = arg; break;
+ case 'c': termcmd = arg; break;
+ case 'l': line_num = strtoul(arg,0,0); break;
}
- OPTEND;
+}
+int usermain(int argc, char** argv)
+{
/* Initialize the window and views */
exec_init(Builtins);
win_init();
win_prop_set("TIDE", "", "tide");
dbc_init(NULL, dumpdata);
+ printf("%s\n", *argv);
+
/* if we still have args left we're going to open it in this instance */
if (*argv)
{