Backspace sends DEL instead of ^H.
[spft.git] / main.cpp
blob78b55e3a8b2a84912c66bf17bb5c72aa61bb174a
1 #include "TermWindow.h"
2 #include "Settings.h"
3 #include <string>
4 #include <list>
5 #include <stdio.h>
8 static const char* prog_name = "spft";
9 static int usage()
11 fprintf(stderr, "Usage: %s [-T <title> | title: <title>] [working-directory: <dir>]\n", prog_name);
12 fprintf(stderr, " Keyword-style arguments also accept the traditional double-dash syntax\n");
13 fprintf(stderr, " (eg. \"--title\" instead of \"title:\").\n");
14 return 1;
18 int main(int argc, char* argv[])
20 // Read settings.
21 settings.read_settings_files();
23 // Read the arguments.
24 prog_name = argv[0];
25 std::list<std::string> args(&argv[1], &argv[argc]);
26 while (!args.empty()) {
27 std::string arg = args.front();
28 args.pop_front();
29 if (arg.substr(0, 2) == "--")
30 arg = arg.substr(2) + ":";
31 if (arg == "-T" || arg == "title:") {
32 if (args.empty())
33 return usage();
34 settings.window_title = args.front();
35 args.pop_front();
37 else if (arg == "working-directory:") {
38 if (args.empty())
39 return usage();
40 settings.working_directory = args.front();
41 args.pop_front();
43 else if (arg == "-g" || arg == "geometry:") {
44 if (args.empty())
45 return usage();
46 settings.geometry = args.front();
47 args.pop_front();
49 else
50 return usage();
53 // Create the window.
54 TermWindow* window = new TermWindow();
55 while (!window->is_done())
56 window->tick();
57 delete window;
58 return 0;