Merge branch 'dieter/experimental' into experimental
authorBarrucadu <mike@barrucadu.co.uk>
Sun, 17 May 2009 10:22:09 +0000 (11:22 +0100)
committerBarrucadu <mike@barrucadu.co.uk>
Sun, 17 May 2009 10:22:09 +0000 (11:22 +0100)
Conflicts:
uzbl.c

README
docs/CHECKLIST [deleted file]
docs/TODO
examples/configs/sampleconfig-dev
examples/scripts/load_url_from_bookmarks.sh
examples/scripts/load_url_from_history.sh
uzbl.c
uzbl.h

diff --git a/README b/README
index bc5baca..a43e0cd 100644 (file)
--- a/README
+++ b/README
@@ -66,10 +66,16 @@ There are several interfaces to interact with uzbl:
   insert mode: keystrokes are not interpreted so you can enter text into html forms
   Press ESC/i to toggle command/insert mode
   But if you don't like modal interfaces, you can set `always_insert_mode` and configure a modkey to execute the commands. (emacs style).
-* FIFO & socket file: if enabled by setting their paths through one of the above means, you can have socket and fifo files available which are very useful to programatically (from scripts etc) to uzbl.
+  There is also support for "chained" commands (multiple characters long) (with backspace/esc shortcuts), and keyworded commands.
+  Also you can have incremental matching on commands or match after pressing return.  (see sampleconfig for more info)
+  Also, copy paste works when typing commands:
+  * insert (paste X cliboard)
+  * shift insert (paste primary selection buffer)
+* FIFO & socket file: if enabled by setting their paths through one of the above means, you can have socket and fifo files available which are very useful to programatically control uzbl (from scripts etc).
   The advantage of the fifo is you can write plaintxt commands to it, but it's half duplex only (uzbl cannot send a response to you).
   The socket is full duplex but you need a socket-compatible wrapper such as netcat to work with it, or uzblctrl of course,
-   an utitly we include with uzbl made especially for writing commnands to the socket (and at some point, it will be able to tell you the response too)
+  an utitly we include with uzbl made especially for writing commnands to the socket (and at some point, it will be able to tell you the response
+  too):  `uzblctrl -s <socketfile> -c <command>`
 
 ### COMMAND SYNTAX
 TODO
@@ -77,7 +83,7 @@ TODO
 ### VARIABLE REPLACEMENT
 Some of the variables are interpreted:
 
-* title bar: variable replacement (not yet actually)
+* title bar: variable replacement (long and short version, depending if statusbar is visible or not)
 * user agent: variable replacement
 * statusbar: variable replacement + pango markup
 
@@ -129,6 +135,16 @@ The script specific arguments are this:
     $11 cookie (only with PUT requests)
 
 
+### COMMAND LINE ARGUMENTS
+
+    -u, --uri=URI            Uri to load (equivalent to 'set uri = URI')
+    -v, --verbose            Whether to print all messages or just errors.
+    -n, --name=NAME          Name of the current instance (defaults to Xorg window id)
+    -c, --config=FILE        Config file (this is pretty much equivalent to uzbl < FILE )
+    --display=DISPLAY        X display to use
+    --help                   Help
+
+
 ### BUGS
 known bugs:
 
diff --git a/docs/CHECKLIST b/docs/CHECKLIST
deleted file mode 100644 (file)
index 6c4a4f7..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-THIS FILE IS DEPRECATED.
-TODO: make sure that all this gets merged into the documentation
-
-This file contains all things that are/should be working.
-When you have been working on something, use this list to verify that you did not cause any regressions (things that worked before, but got broken).
-Also, when you finish a new feature, add it to this list so that everyone knows about it, can play with it, and can test it.
-
-Also testers and interested people can use this list to see what uzbl is about, and report problems if they find items listed here that do not work.
-
-* commandline switches --uri "http://.." and --config behave as expected
-* --help and -? should show help
-* config loading: loading of settings, bindings and all behavior settings (including handlers) from config file
-* fifo: type this in your shell after starting uzbl:
-  echo 'uri http://www...' > <fifo path here>'
-  where <fifo path> is printed on stdout during program startup.  Also "back" , "forward", "refresh" (basically all actions defined in `static Command commands` should behave as expected)
-  On one of Dieter's pc's, using the fifo only works once.  Please report issues with the fifo if you find any.
-* socket: uzblctrl -s <socketname> -c <command> (same commands as with fifo)
-* history logging: the script as defined in sample config should write history entries (date,time, url) into the file defined in the script (by default ./extra/history.sh and /tmp/uzbl.history)
-* invocations of external commands: you'll see it on stdout everytime uzbl calls an external script/program. the invocations should work and none of the arguments passed should be null/garbage/.. .
-  all should be valid strings and contain things like the pid, fifo file, config file,.. (see README for details).
-* XDG_CONFIG_HOME and XDG_CONFIG_DIRS (+ default values) fully supported and working (looks for a config file called 'uzbl/config').
-* --uri can be specified without http:// -- if missing will be prepended.
-* Downloading of files with handler script
-* Open in new window. all (valid) args passed to your uzbl instance are passed also to the new instance, with the obvious exception of --uri.
-* internal keybinds to change things work (as loaded by config)
-* vimlike command and insert modes behave as expected
-* always_insert_mode and modkey work too
-* status bar can be toggled on and off, if off, some info (mode) will be put in title bar. position of statusbar (top/bottom) also works
-* backspace erases last edit character. esc erases entire command buffer (if in comand mode)
-* commands with parameters (keywords): any key sequence that ends with underscore _ expects parameter. Undersore marks exact location where parameter begins. Command part can have %s that will be replaced with parameter.
-  This only works for internal commands. not when spawning external scripts.
-        :o _ = uri %s - user needs to type :o www.google.com
-        :O_ = uri %s - user needs to type :Owww.google.com
-* when typing command, press insert (paste X cliboard) or shift insert (paste primary selection buffer)
-* proxy, user agent and other network settings can be set in config
-* scrolling works, with configurable keys (vi-like in sample config)
-* searching:
-  /_ = search %s <-- hilight all
-  ; = search <-- jump over all hits
-* run javascript on curent page through "script" command.
-* variable replacement in user agent.
-* basic keyboard link hilighting (numbering) and following. will be improved more
-* support overriding background color of statusbar and pango markup format to customize the statusbar in terms of which variables, separators, colors, fonts, etc
index 6258432..d501643 100644 (file)
--- a/docs/TODO
+++ b/docs/TODO
@@ -14,6 +14,7 @@ More or less in order of importance/urgency
 * implement getting feedback from socket
 * scrolling: make page up and page down configurable.
 * show % of location in statusbar/title if page doesn't fit entirely on view.
+* conditionals in format strings: eg if(SELECTED_URI) { "-> SELECTED_URI" } or another smart way to achieve the same.
 * make default window size configurable, and optional
 * on uzbl.org commits overview: add date+time and repository
 * how to handle different content types? (text-plain, image/png, application/pdf,... maybe a map of content-type to uzbl/command
@@ -34,7 +35,6 @@ More or less in order of importance/urgency
 * improve DCOMMIT macro.  what if WC is dirty? what if user downloaded tarball without .git?
 * DARCH is not correct (should be at runtime)
 * keybinds to open "next" or "previous" by looking for next/prev links and/or looking for numbers in the uri we can inc/decrement
-* variable replacing for title bar in "statusbar_visible" and statusbar_invisible states
 * settings iterating "state generator" so we can "open in new window" again.
 * handler for (broken) ssl certs.
 * handlers for mailto: and maybe other thingies?
index 7653407..9196f4c 100644 (file)
@@ -25,8 +25,11 @@ set shell_cmd         = sh -c %s ''
 set show_status       = 1
 # you can optionally use this setting to override the background color of the statusbar from your GTK theme.
 set status_background = #303030
-set status_format     = <span font_family="monospace"><span background="khaki" foreground="black">MODE</span> [<span weight="bold" foreground="red">KEYCMD</span>] <span foreground="#606060"> LOAD_PROGRESSBAR </span><span foreground="#99FF66">URI</span> <span foreground="khaki">NAME</span> <span foreground="orange">MSG</span></span>
+set status_format     = <span font_family="monospace"><span background="khaki" foreground="black">MODE</span> [<span weight="bold" foreground="red">KEYCMD</span>] <span foreground="#606060"> LOAD_PROGRESSBAR </span><span foreground="#99FF66">URI</span> <span foreground="khaki">NAME</span> <span foreground="orange">MSG</span><span foreground="#606060">SELECTED_URI</span></span>
 set status_top = 0
+# define how your titlebar should look like. (short = statusbar is also shown, long = show everything you must see if statusbar is off)
+set title_format_short = TITLE - Uzbl browser <NAME>
+set title_format_long = KEYCMD MODE TITLE - Uzbl browser <NAME> > SELECTED_URI
 
 set modkey = Mod1
 # reset to command mode when new page is loaded
@@ -87,3 +90,6 @@ bind    XS        = sh 'echo "act script alert (\"This is sent by the shell via
 bind    F= script for (var i=0; i < document.links.length; i++) {var uzblid = 'uzbl_link_hint_';var li = document.links[i];var pre = document.getElementById(uzblid+i);if (pre) {li.removeChild(pre);} else {var hint = document.createElement('div');hint.setAttribute('id',uzblid+i);hint.innerHTML = i;hint.style.display='inline';hint.style.lineHeight='90%';hint.style.backgroundColor='red';hint.style.color='white';hint.style.fontSize='small-xx';hint.style.fontWeight='light';hint.style.margin='0px';hint.style.padding='2px';hint.style.position='absolute';hint.style.textDecoration='none';hint.style.left=li.style.left;hint.style.top=li.style.top;li.insertAdjacentElement('afterBegin',hint);}}
 #hit f followed by linknumber and ENTER to follow that link
 bind    f_        = script window.location = document.links[%s].href;
+
+# "home" page if you will
+set uri = uzbl.org
index 821b136..21ea33d 100755 (executable)
@@ -6,16 +6,16 @@
 [ -f $XDG_DATA_HOME/uzbl/bookmarks           ] && file=$XDG_DATA_HOME/uzbl/bookmarks
 [ -f ./examples/data/bookmarks               ] && file=./examples/data/bookmarks #useful when developing
 [ -z "$file" ] && exit 1
-
+COLORS=" -nb #303030 -nf khaki -sb #CCFFAA -sf #303030"
 if dmenu --help 2>&1 | grep -q '\[-rs\] \[-ni\] \[-nl\] \[-xs\]'
 then
        DMENU="dmenu -i -xs -rs -l 10" # vertical patch
        # show tags as well
-       goto=`$DMENU < $file | awk '{print $1}'`
+       goto=`$DMENU $COLORS < $file | awk '{print $1}'`
 else
        DMENU="dmenu -i"
        # because they are all after each other, just show the url, not their tags.
-       goto=`awk '{print $1}' $file | $DMENU`
+       goto=`awk '{print $1}' $file | $DMENU $COLORS`
 fi
 
 #[ -n "$goto" ] && echo "act uri $goto" > $4
index ec54631..ea6e7aa 100755 (executable)
@@ -4,18 +4,17 @@ history_file=/tmp/uzbl.history
 
 # choose from all entries, sorted and uniqued
 # goto=`awk '{print $3}' $history_file | sort -u | dmenu -i`
-
-
+COLORS=" -nb #303030 -nf khaki -sb #CCFFAA -sf #303030"
 if dmenu --help 2>&1 | grep -q '\[-rs\] \[-ni\] \[-nl\] \[-xs\]'
 then
         DMENU="dmenu -i -xs -rs -l 10" # vertical patch
         # choose an item in reverse order, showing also the date and page titles
         # pick the last field from the first 3 fields. this way you can pick a url (prefixed with date & time) or type just a new url.
-        goto=`tac $history_file | $DMENU | cut -d ' ' -f -3  | awk '{print $NF}'`
+        goto=`tac $history_file | $DMENU $COLORS | cut -d ' ' -f -3  | awk '{print $NF}'`
 else    
         DMENU="dmenu -i"
        # choose from all entries (no date or title), the first one being current url, and after that all others, sorted and uniqued, in ascending order
-       current=`tail -n 1 $history_file | awk '{print $3}'`; goto=`(echo $current; awk '{print $3}' $history_file | grep -v "^$current\$" | sort -u) | $DMENU`
+       current=`tail -n 1 $history_file | awk '{print $3}'`; goto=`(echo $current; awk '{print $3}' $history_file | grep -v "^$current\$" | sort -u) | $DMENU $COLORS`
 fi 
 
 #[ -n "$goto" ] && echo "act uri $goto" > $4
diff --git a/uzbl.c b/uzbl.c
index 3a6e178..3fac242 100644 (file)
--- a/uzbl.c
+++ b/uzbl.c
@@ -69,6 +69,8 @@ const struct {
     { "status_top",         (void *)&uzbl.behave.status_top         },
     { "status_format",      (void *)&uzbl.behave.status_format      },
     { "status_background",  (void *)&uzbl.behave.status_background  },
+    { "title_format_long",  (void *)&uzbl.behave.title_format_long  },
+    { "title_format_short", (void *)&uzbl.behave.title_format_short },
     { "insert_mode",        (void *)&uzbl.behave.insert_mode        },
     { "always_insert_mode", (void *)&uzbl.behave.always_insert_mode },
     { "reset_command_mode", (void *)&uzbl.behave.reset_command_mode },
@@ -126,10 +128,10 @@ make_var_to_name_hash() {
 /* commandline arguments (set initial values for the state variables) */
 static GOptionEntry entries[] =
 {
-    { "uri",     'u', 0, G_OPTION_ARG_STRING, &uzbl.state.uri,           "Uri to load", "URI" },
+    { "uri",     'u', 0, G_OPTION_ARG_STRING, &uzbl.state.uri,           "Uri to load at startup (equivalent to 'set uri = URI')", "URI" },
     { "verbose", 'v', 0, G_OPTION_ARG_NONE,   &uzbl.state.verbose,       "Whether to print all messages or just errors.", NULL },
     { "name",    'n', 0, G_OPTION_ARG_STRING, &uzbl.state.instance_name, "Name of the current instance (defaults to Xorg window id)", "NAME" },
-    { "config",  'c', 0, G_OPTION_ARG_STRING, &uzbl.state.config_file,   "Config file", "FILE" },
+    { "config",  'c', 0, G_OPTION_ARG_STRING, &uzbl.state.config_file,   "Config file (this is pretty much equivalent to uzbl < FILE )", "FILE" },
     { NULL,      0, 0, 0, NULL, NULL, NULL }
 };
 
@@ -301,7 +303,7 @@ link_hover_cb (WebKitWebView* page, const gchar* title, const gchar* link, gpoin
     (void) page;
     (void) title;
     (void) data;
-    //ADD HOVER URL TO WINDOW TITLE
+    //Set selected_url state variable
     uzbl.state.selected_url[0] = '\0';
     if (link) {
         strcpy (uzbl.state.selected_url, link);
@@ -632,6 +634,11 @@ expand_template(const char *template) {
                          uzbl.gui.main_title?
                          g_markup_printf_escaped("%s", uzbl.gui.main_title):"");
                      break;
+                 case SYM_SELECTED_URI:
+                     g_string_append(ret,
+                         uzbl.state.selected_url?
+                         g_markup_printf_escaped("%s", uzbl.state.selected_url):"");
+                    break;
                  case SYM_NAME:
                      buf = itos(uzbl.xwin);
                      g_string_append(ret,
@@ -795,7 +802,9 @@ get_var_value(gchar *name) {
 
     if( (p = g_hash_table_lookup(uzbl.comm.proto_var, name)) ) {
         if(var_is("status_format", name)
-           || var_is("useragent", name)) {
+           || var_is("useragent", name)
+           || var_is("title_format_short", name)
+           || var_is("title_format_long", name)) {
             printf("VAR: %s VALUE: %s\n", name, (char *)*p);
         } else printf("VAR: %s VALUE: %d\n", name, (int)*p);
     }
@@ -856,6 +865,8 @@ set_var_value(gchar *name, gchar *val) {
         if(var_is("status_message", name)
            || var_is("status_background", name)
            || var_is("status_format", name)
+           || var_is("title_format_long", name)
+           || var_is("title_format_short", name)
            || var_is("load_finish_handler", name)
            || var_is("history_handler", name)
            || var_is("download_handler", name)
@@ -1249,42 +1260,11 @@ init_socket(gchar *dir) { /* return dir or, on error, free dir and return NULL *
 
 static void
 update_title (void) {
-    GString* string_long = g_string_new ("");
-    GString* string_short = g_string_new ("");
-    char* iname = NULL;
-    gchar *statln;
-    int iname_len;
-    State *s = &uzbl.state;
     Behaviour *b = &uzbl.behave;
 
-    if(s->instance_name) {
-            iname_len = strlen(s->instance_name)+4;
-            iname = malloc(iname_len);
-            snprintf(iname, iname_len, "<%s> ", s->instance_name);
-
-            g_string_prepend(string_long, iname);
-            g_string_prepend(string_short, iname);
-            free(iname);
-    }
-
-    g_string_append_printf(string_long, "%s ", s->keycmd->str);
-    if (!b->always_insert_mode)
-        g_string_append (string_long, (b->insert_mode ? "[I] " : "[C] "));
-    if (uzbl.gui.main_title) {
-        g_string_append (string_long, uzbl.gui.main_title);
-        g_string_append (string_short, uzbl.gui.main_title);
-    }
-    g_string_append (string_long, " - Uzbl browser");
-    g_string_append (string_short, " - Uzbl browser");
-    if (s->selected_url[0]!=0) {
-        g_string_append_printf (string_long, " -> (%s)", s->selected_url);
-    }
-
-    gchar* title_long = g_string_free (string_long, FALSE);
-    gchar* title_short = g_string_free (string_short, FALSE);
-
     if (b->show_status) {
-        gtk_window_set_title (GTK_WINDOW(uzbl.gui.main_window), title_short);
+        gchar *statln;
+        gtk_window_set_title (GTK_WINDOW(uzbl.gui.main_window), expand_template(b->title_format_short));
         // TODO: we should probably not do this every time we want to update the title..?
         statln = expand_template(uzbl.behave.status_format);
         gtk_label_set_markup(GTK_LABEL(uzbl.gui.mainbar_label), statln);
@@ -1296,11 +1276,8 @@ update_title (void) {
         }
         g_free(statln);
     } else {
-        gtk_window_set_title (GTK_WINDOW(uzbl.gui.main_window), title_long);
+        gtk_window_set_title (GTK_WINDOW(uzbl.gui.main_window), expand_template(b->title_format_long));
     }
-
-    g_free (title_long);
-    g_free (title_short);
 }
 
 static gboolean
@@ -1575,6 +1552,11 @@ settings_init () {
     }
     if (!uzbl.behave.status_format)
         uzbl.behave.status_format = g_strdup(STATUS_DEFAULT);
+    if (!uzbl.behave.title_format_long)
+        uzbl.behave.title_format_long = g_strdup(TITLE_LONG_DEFAULT);
+    if (!uzbl.behave.title_format_short)
+        uzbl.behave.title_format_short = g_strdup(TITLE_SHORT_DEFAULT);
+
 
     g_signal_connect(n->soup_session, "request-queued", G_CALLBACK(handle_cookies), NULL);
 }
diff --git a/uzbl.h b/uzbl.h
index 506f1d3..368ad46 100644 (file)
--- a/uzbl.h
+++ b/uzbl.h
  */
 
 #define STATUS_DEFAULT "<span background=\"darkblue\" foreground=\"white\"> MODE </span> <span background=\"red\" foreground=\"white\">KEYCMD</span> (LOAD_PROGRESS%)  <b>TITLE</b>  - Uzbl browser"
+#define TITLE_LONG_DEFAULT "KEYCMD MODE TITLE - Uzbl browser <NAME> > SELECTED_URI"
+#define TITLE_SHORT_DEFAULT "TITLE - Uzbl browser <NAME>"
+
 
 enum {
   /* statusbar symbols */
   SYM_TITLE, SYM_URI, SYM_NAME,
   SYM_LOADPRGS, SYM_LOADPRGSBAR,
   SYM_KEYCMD, SYM_MODE, SYM_MSG,
+  SYM_SELECTED_URI,
   /* useragent symbols */
   SYM_WK_MAJ, SYM_WK_MIN, SYM_WK_MIC,
   SYM_SYSNAME, SYM_NODENAME,
@@ -33,6 +37,7 @@ const struct {
     {"NAME",                 SYM_NAME},
     {"URI",                  SYM_URI},
     {"TITLE",                SYM_TITLE},
+    {"SELECTED_URI",         SYM_SELECTED_URI},
     {"KEYCMD",               SYM_KEYCMD},
     {"MODE",                 SYM_MODE},
     {"MSG",                  SYM_MSG},
@@ -124,6 +129,8 @@ typedef struct {
 typedef struct {
     gchar*   load_finish_handler;
     gchar*   status_format;
+    gchar*   title_format_short;
+    gchar*   title_format_long;
     gchar*   status_background;
     gchar*   history_handler;
     gchar*   fifo_dir;