From 6608f8fc19ef4b587596c9ed3cb3b3fcc37c1eb6 Mon Sep 17 00:00:00 2001
From: Daniel Carl
Date: Sat, 19 Sep 2015 20:47:37 +0200
Subject: [PATCH 001/201] Startup webkit2 branch from the scratch.
---
.gitignore | 10 +-
CHANGELOG.md | 8 +
Makefile | 54 +-
README.md | 200 +-
config.mk | 88 +-
doc/vimb.1 | 1617 ------------
examples/formfiller/formfiller | 78 -
examples/formfiller/scripts.js | 50 -
src/.gitignore | 2 +
src/Makefile | 58 +-
src/arh.c | 199 --
src/ascii.h | 7 +-
src/autocmd.c | 488 ----
src/autocmd.h | 50 -
src/bookmark.c | 326 ---
src/bookmark.h | 34 -
src/command.c | 180 +-
src/command.h | 11 +-
src/completion.c | 217 +-
src/completion.h | 16 +-
src/config.def.h | 102 +-
src/cookiejar.c | 105 -
src/cookiejar.h | 43 -
src/dom.c | 330 ---
src/dom.h | 46 -
src/ex.c | 632 ++---
src/ex.h | 11 +-
src/ext-proxy.c | 214 ++
src/{arh.h => ext-proxy.h} | 17 +-
src/handlers.c | 96 -
src/hints.c | 398 ---
src/hints.js | 611 -----
src/hints.js.h | 1 +
src/history.c | 172 +-
src/history.h | 6 +-
src/hsts.c | 458 ----
src/hsts.h | 52 -
src/input.c | 138 +-
src/input.h | 8 +-
src/io.c | 170 --
src/js.c | 179 +-
src/js.h | 14 +-
src/js2h.sh | 15 -
src/main.c | 2342 ++++++-----------
src/main.h | 477 ++--
src/map.c | 610 ++---
src/map.h | 14 +-
src/normal.c | 489 ++--
src/normal.h | 12 +-
src/scripts/.gitignore | 1 +
src/scripts/Makefile | 19 +
src/scripts/increment_uri_number.js | 16 +
src/scripts/js2h.sh | 38 +
src/setting.c | 793 ++----
src/setting.h | 10 +-
src/shortcut.c | 56 +-
src/shortcut.h | 15 +-
src/util.c | 758 ++----
src/util.h | 35 +-
src/webextension/Makefile | 19 +
src/webextension/ext-dom.c | 179 ++
src/{handlers.h => webextension/ext-dom.h} | 18 +-
src/webextension/ext-main.c | 360 +++
src/{hints.h => webextension/ext-main.h} | 20 +-
src/webextension/ext-util.c | 60 +
src/{io.h => webextension/ext-util.h} | 13 +-
tests/Makefile | 19 -
tests/manual/112-editable-focus.html | 39 -
tests/manual/146-hsts-iframe.html | 14 -
.../manual/201-editable-focus-in-iframes.html | 9 -
tests/test-handlers.c | 80 -
tests/test-map.c | 176 --
tests/test-shortcut.c | 142 -
tests/test-util.c | 285 --
74 files changed, 3766 insertions(+), 10863 deletions(-)
delete mode 100644 doc/vimb.1
delete mode 100755 examples/formfiller/formfiller
delete mode 100644 examples/formfiller/scripts.js
create mode 100644 src/.gitignore
delete mode 100644 src/arh.c
delete mode 100644 src/autocmd.c
delete mode 100644 src/autocmd.h
delete mode 100644 src/bookmark.c
delete mode 100644 src/bookmark.h
delete mode 100644 src/cookiejar.c
delete mode 100644 src/cookiejar.h
delete mode 100644 src/dom.c
delete mode 100644 src/dom.h
create mode 100644 src/ext-proxy.c
rename src/{arh.h => ext-proxy.h} (72%)
delete mode 100644 src/handlers.c
delete mode 100644 src/hints.c
delete mode 100644 src/hints.js
create mode 100644 src/hints.js.h
delete mode 100644 src/hsts.c
delete mode 100644 src/hsts.h
delete mode 100644 src/io.c
delete mode 100755 src/js2h.sh
create mode 100644 src/scripts/.gitignore
create mode 100644 src/scripts/Makefile
create mode 100644 src/scripts/increment_uri_number.js
create mode 100755 src/scripts/js2h.sh
create mode 100644 src/webextension/Makefile
create mode 100644 src/webextension/ext-dom.c
rename src/{handlers.h => webextension/ext-dom.h} (67%)
create mode 100644 src/webextension/ext-main.c
rename src/{hints.h => webextension/ext-main.h} (60%)
create mode 100644 src/webextension/ext-util.c
rename src/{io.h => webextension/ext-util.h} (80%)
delete mode 100644 tests/Makefile
delete mode 100644 tests/manual/112-editable-focus.html
delete mode 100644 tests/manual/146-hsts-iframe.html
delete mode 100644 tests/manual/201-editable-focus-in-iframes.html
delete mode 100644 tests/test-handlers.c
delete mode 100644 tests/test-map.c
delete mode 100644 tests/test-shortcut.c
delete mode 100644 tests/test-util.c
diff --git a/.gitignore b/.gitignore
index 00a41de6..711ddb0e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,11 +1,5 @@
*.[oad]
*.lo
+*.so
*.tar.gz
-src/hints.js.h
-src/config.h
-src/vimb
-src/libvimb.so
-tests/*
-!tests/Makefile
-!tests/*.c
-!tests/manual/
+sandbox
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 77da6f65..9fb2ea46 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,12 @@
# Changes in vimb
+## [unreleased]
+
+### Removed
+
+* `FEATURE_COOKIE` precompiler flag was removed bcause compiling without cookie
+ support does not bring any real benefit
+
## [2.11] - 2015-12-17
### Added
@@ -37,4 +44,5 @@
cookie file
* Fixed none POSIX `echo -n` call
+[unreleased]: https://github.com/fanglingsu/vimb/compare/2.11...HEAD
[2.11]: https://github.com/fanglingsu/vimb/compare/2.10...2.11
diff --git a/Makefile b/Makefile
index e21743ec..b7abcfd9 100644
--- a/Makefile
+++ b/Makefile
@@ -1,49 +1,39 @@
include config.mk
-SRCDIR=src
-DOCDIR=doc
+all: vimb
-all: $(TARGET)
options:
- @echo "$(PROJECT) build options:"
+ @echo "vimb build options:"
@echo "LIBS = $(LIBS)"
@echo "CFLAGS = $(CFLAGS)"
@echo "LDFLAGS = $(LDFLAGS)"
@echo "CC = $(CC)"
-test: $(LIBTARGET)
- @$(MAKE) $(MFLAGS) -s -C tests
+install: vimb
+ @# binary
+ install -d $(BINPREFIX)
+ install -m 755 $(SRCDIR)/vimb $(BINPREFIX)/vimb
+ @# extension
+ install -d $(EXTPREFIX)
+ install -m 644 $(SRCDIR)/webextension/$(EXTTARGET) $(EXTPREFIX)/$(EXTTARGET)
-clean:
- @$(MAKE) $(MFLAGS) -C src clean
- @$(MAKE) $(MFLAGS) -C tests clean
+uninstall:
+ $(RM) $(BINPREFIX)/vimb $(EXTPREFIX)/$(EXTTARGET)
-install: $(TARGET) $(DOCDIR)/$(MAN1)
- install -d $(DESTDIR)$(BINDIR)
- install -m 755 $(SRCDIR)/$(TARGET) $(DESTDIR)$(BINDIR)/$(TARGET)
- install -d $(DESTDIR)$(EXAMPLEDIR)
- cp -r examples/* $(DESTDIR)$(EXAMPLEDIR)
- install -d $(DESTDIR)$(MANDIR)/man1
- @sed -e "s!VERSION!$(VERSION)!g" \
- -e "s!PREFIX!$(PREFIX)!g" \
- -e "s!DATE!`date +'%m %Y'`!g" $(DOCDIR)/$(MAN1) > $(DESTDIR)$(MANDIR)/man1/$(MAN1)
+vimb: $(SUBDIRS:%=%.subdir-all)
-uninstall:
- $(RM) $(DESTDIR)$(BINDIR)/$(TARGET)
- $(RM) $(DESTDIR)$(MANDIR)/man1/$(MAN1)
- $(RM) -r $(DESTDIR)$(EXAMPLEDIR)
+%.subdir-all:
+ $(MAKE) $(MFLAGS) -C $*
-dist: dist-clean
- @echo "Creating tarball."
- @git archive --format tar -o $(DIST_FILE) HEAD
+%.subdir-clean:
+ $(MAKE) $(MFLAGS) -C $* clean
-dist-clean:
- $(RM) $(DIST_FILE)
+clean: $(SUBDIRS:%=%.subdir-clean)
-$(TARGET):
- @$(MAKE) $(MFLAGS) -C src $(TARGET)
+runsandbox: sandbox
+ sandbox/usr/bin/vimb
-$(LIBTARGET):
- @$(MAKE) $(MFLAGS) -C src $(LIBTARGET)
+sandbox:
+ make RUNPREFIX=$(CURDIR)/sandbox/usr PREFIX=/usr DESTDIR=./sandbox install
-.PHONY: clean all install uninstall options dist dist-clean test
+.PHONY: all options clean install uninstall sandbox
diff --git a/README.md b/README.md
index 09441004..b2e03318 100644
--- a/README.md
+++ b/README.md
@@ -1,89 +1,111 @@
-# Vimb - the Vim-like browser
-
-Vimb is a Vim-like web browser that is inspired by Pentadactyl and Vimprobable.
-The goal of Vimb is to build a completely keyboard-driven, efficient and
-pleasurable browsing-experience with low memory and CPU usage that is
-intuitive to use for Vim users.
-
-More information and some screenshots of Vimb browser in action can be found on
-the project page of [Vimb][].
-
-## Features
-
-- it's modal like Vim
-- Vim like [keybindings][] - assignable for each browser mode
-- nearly every configuration can be changed at runtime with Vim like [set syntax][set]
-- [history][] for `ex` commands, search queries, URLs
-- completions for: commands, URLs, bookmarked URLs, variable names of settings, search-queries
-- [hinting][hints] - marks links, form fields and other clickable elements to
- be clicked, opened or inspected
-- SSL validation against ca-certificate file
-- HTTP Strict Transport Security (HSTS)
-- open input or textarea with configurable external editor
-- user defined URL-shortcuts with placeholders
-- custom [protocol handlers][handlers]
-- read it later [queue][] to collect URIs for later use
-- multiple yank/paste [registers][]
-- Vim like [autocmd][]
-
-## Packages
-
-- Arch Linux [vimb-git][arch-git], [vimb][arch]
-- [NetBSD][]
-- [FreeBSD][]
-- [Void Linux][]
-
-## Dependencies
-
-- libwebkit >=1.5.0
-- libgtk+-2.0
-- libsoup >=2.38
-
-On Ubuntu these dependencies can be installed by
-`sudo apt-get install libsoup2.4-dev libwebkit-dev libgtk-3-dev libwebkitgtk-3.0-dev`.
-
-## Install
-
-Edit `config.mk` to match your local setup.
-
-Edit src/config.h to match your personal preferences.
-Edit `src/config.h` to match your personal preferences.
-
-The default `Makefile` will not overwrite your customised `config.h` with the
-contents of `config.def.h`, even if it was updated in the latest git pull.
-Therefore, you should always compare your customised `config.h` with
-`config.def.h` and make sure you include any changes to the latter in your
-`config.h`.
-
-Run the following commands to compile and install Vimb (if necessary, the last one as
-root).
-
- make clean
- make // or make GTK=3 to compile against gtk3
- make install
-
-To build Vimb against GTK3 you can use `make GTK=3`.
-
-# License
-
-Information about the license is found in the file: LICENSE.
-
-# Mailing list
-
-- feature requests, issues and patches can be discussed on the [mailing list][mail]
-
-[vimb]: http://fanglingsu.github.io/vimb/ "Vimb - Vim like browser project page"
-[keybindings]: http://fanglingsu.github.io/vimb/keybindings.html "vimb keybindings"
-[hints]: http://fanglingsu.github.io/vimb/keybindings.html#hinting "vimb hinting"
-[queue]: http://fanglingsu.github.io/vimb/commands.html#queue "vimb read it later queue feature"
-[history]: http://fanglingsu.github.io/vimb/keybindings.html#history "vimb keybindings to access history"
-[handlers]: http://fanglingsu.github.io/vimb/commands.html#handlers "vimb custom protocol handlers"
-[registers]: http://fanglingsu.github.io/vimb/keybindings.html#registers "vimb yank/paste registers"
-[mail]: https://lists.sourceforge.net/lists/listinfo/vimb-users "vimb - mailing list"
-[NetBSD]: http://pkgsrc.se/wip/vimb "vimb - NetBSD package"
-[autocmd]: http://fanglingsu.github.io/vimb/commands.html#autocmd "Vim like autocmd and augroup feature"
-[set]: http://fanglingsu.github.io/vimb/commands.html#settings "Vim like set syntax"
-[Arch-git]: https://aur.archlinux.org/packages/vimb-git/ "vimb - archlinux package"
-[Arch]: https://aur.archlinux.org/packages/vimb/ "vimb - archlinux package"
-[FreeBSD]: http://www.freshports.org/www/vimb/ "vimb - FreeBSD port"
-[Void Linux]: https://github.com/voidlinux/void-packages/blob/master/srcpkgs/vimb/template "vimb - Void Linux package"
+# vimb - the vim like browser
+
+This is the development branch for the new webkit2 port of vimb. This branch
+does not work and lags a lot of features of the webkit1 version of vimb. So
+this is only meant to be the playground for the developers at the moment.
+
+If you like to have a working vimb, please use the master branch.
+
+## Patching and Coding style
+
+- the code is indented by 4 spaces - if you use vim to code you can set
+ `:set expandtab ts=4 sts=4 sw=4`
+- the functions are sorted alphabetically within the c files
+- it's a good advice to orientate on the already available code
+- if you are using `indent`, following options describe best the code style
+ - `--k-and-r-style`
+ - `--case-indentation4`
+ - `--dont-break-function-decl-args`
+ - `--dont-break-procedure-type`
+ - `--dont-line-up-parentheses`
+ - `--no-tabs`
+
+## directories
+
+ ├── doc documentation like manual page
+ └── src all sources to build vimb
+ ├── scripts JavaScripts that are compiled in to various purposes
+ └── webextension Source files for the webextension
+
+## dependencies
+
+- webkit2gtk-4.0 >= 2.3.5
+
+## compile and run
+
+To inform vimb during compile time where the webextension should be loaded
+from, the `RUNPREFIX` option can be set to a full qualified path to the
+directory where the extension should be sotred in.
+
+To run vimb wihtout installation you could run as a sandbox like this
+
+ make runsandbox
+
+This will compile and install vimb into the local _sandbox_ folder in the
+project directory.
+
+## Tasks
+
+1. general infrastructure and built
+ - [x] write make file
+ - [x] allow to built as sandbox for local testing
+ - [x] add a way to specify the target of the webextension shared objects
+ this is now available with the `RUNPREFIX` oprion for the make
+ - [x] establish communication channel between the vimb instance and the now
+ required webextension (dbus)
+2. migrate as many of the features of the webkit1 vimb
+ - [ ] starting with custom config file `--config,-c` option
+ - [ ] running multiple ex-commands during startup `--cmd,-C` options
+ - [ ] starting with a named profile `--profile,-p` option
+ - [ ] xembed `--embed,-e` option
+ - [ ] socket support `--socket,-s` and `--dump,-d` option to print the actual
+ used socket path to stdout
+ - [ ] kiosk-mode `--kiosk,-k`
+ - [ ] allow to start vimb reading html from `stdin` by `vimb -`
+ - [ ] browser modes normal, input, command, pass-through and hintmode
+ - [ ] download support
+ - [ ] editor command
+ - [ ] external downloader
+ - [ ] hinting
+ - [ ] searching and matching of search results
+ - [ ] navigation j, k, h, l, ...
+ - [ ] history and history lookup
+ - [ ] completion
+ - [ ] HSTS
+ - [ ] auto-response-header
+ - [ ] cookies support
+ - [ ] register support and `:register` command
+ - [ ] read it later queue
+ - [ ] show scroll indicator in statusbar as top, x%, bttom or all
+ how can we get this information from webview easily?
+ - [ ] find a way to disable the scrollbars on the main frame
+ - [ ] page marks - maybe we change make them global (shared between
+ instances and to work also if the page was reloaded or changed like
+ the marks in vim)
+ - [x] zooming
+ - [ ] yanking
+ - [x] keymapping
+ - [ ] URL handler
+ - [x] shortcuts
+ - [ ] autocommands and augroups
+3. documentation
+4. testing
+ - [ ] write automatic test to the essential main features
+ - [ ] adapt the manual test cases and add some more to avoid regressions
+ before a release
+ - [ ] write new test cases for essential things like mode switching of vimb
+ when clicking form fields or tabbing over them.
+5. new features and changed behaviour
+ - [ ] try to use the webkit2 feature of running multiple pages with related
+ view instance `webkit_web_view_new_with_related_view`
+ - [ ] allow setting of different scopes, global and instance (new feature)
+ - [ ] remove the settings related to the gui like `status-color-bg` this was
+ only a hack and is not recommended for new gtk3 applications. the
+ color and font settings should be setup by css instead.
+ - [ ] webkit2 does not provide the view mode `source` so maybe this is going
+ to be removed together with the `gf` keybinding or we find a simple
+ workaround for this
+
+# license
+
+Information about the license are found in the file LICENSE.
diff --git a/config.mk b/config.mk
index 38093361..e3f18005 100644
--- a/config.mk
+++ b/config.mk
@@ -1,63 +1,37 @@
-#----------------user/install options----------------
-VERSION = 2.11
-
-PROJECT = vimb
-PREFIX ?= /usr/local
-BINDIR ?= $(PREFIX)/bin
-MANDIR ?= $(PREFIX)/share/man
-EXAMPLEDIR ?= $(PREFIX)/share/$(PROJECT)/examples
-
-#----------------compile options---------------------
-
-VERBOSE ?= 0
-
-LIBS = libsoup-2.4
-
-GTK3LIBS=gtk+-3.0 webkitgtk-3.0
-GTK2LIBS=gtk+-2.0 webkit-1.0
-
-ifeq (${GTK}, 3)
-ifeq ($(shell pkg-config --exists $(GTK3LIBS) && echo 1), 1) #has gtk3 libs
-LIBS += $(GTK3LIBS)
-USEGTK3 = 1
-else
-LIBS += $(GTK2LIBS)
-$(warning Cannot find gtk3-libs, falling back to gtk2)
-endif
-else
-LIBS += $(GTK2LIBS)
-endif
-
-# generate a first char upper case project name
-PROJECT_UCFIRST = $(shell echo '${PROJECT}' | awk '{for(i=1;i<=NF;i++){$$i=toupper(substr($$i,1,1))substr($$i,2)}}1')
-
-CPPFLAGS = -DVERSION=\"${VERSION}\"
-CPPFLAGS += -DPROJECT=\"${PROJECT}\" -DPROJECT_UCFIRST=\"${PROJECT_UCFIRST}\"
+VERSION = dev-3.0
+
+PREFIX ?= /usr/local
+BINPREFIX := $(DESTDIR)$(PREFIX)/bin
+MANPREFIX := $(DESTDIR)$(PREFIX)/share/man
+EXAMPLEPREFIX := $(DESTDIR)$(PREFIX)/share/vimb/example
+RUNPREFIX := $(PREFIX)
+EXTPREFIX := $(RUNPREFIX)/lib/vimb
+
+# define some directories
+SRCDIR = src
+DOCDIR = doc
+SUBDIRS = $(SRCDIR)/scripts $(SRCDIR)/webextension $(SRCDIR)
+
+# used libs
+LIBS = gtk+-3.0 webkit2gtk-4.0
+
+# setup general used CFLAGS
+CFLAGS += -std=c99 -pipe -Wall
+#CPPFLAGS += -pedantic
+CPPFLAGS += -DVERSION=\"${VERSION}\" -DEXTPREFIX=\"${EXTPREFIX}\"
+CPPFLAGS += -DPROJECT=\"vimb\" -DPROJECT_UCFIRST=\"Vimb\"
CPPFLAGS += -D_XOPEN_SOURCE=500
-CPPFLAGS += -D_POSIX_SOURCE
-ifeq ($(USEGTK3), 1)
-CPPFLAGS += -DHAS_GTK3
CPPFLAGS += -DGSEAL_ENABLE
CPPFLAGS += -DGTK_DISABLE_SINGLE_INCLUDES
-CPPFLAGS += -DGTK_DISABLE_DEPRECATED
CPPFLAGS += -DGDK_DISABLE_DEPRECATED
-endif
-
-# prepare the lib flags used for the linker
-LIBFLAGS = $(shell pkg-config --libs $(LIBS))
-
-# some compiler flags in case CFLAGS is not set by user
-# -Wno-typedef-redefinition to avoid redifinition warnings caused by glib
-CFLAGS ?= -Wall -pipe -Wno-overlength-strings -Werror=format-security -Wno-typedef-redefinition
-# normal compiler flags
-CFLAGS += $(shell pkg-config --cflags $(LIBS))
-CFLAGS += -std=c99
-CFLAGS += ${CPPFLAGS}
-LDFLAGS += ${LIBFLAGS}
-TARGET = $(PROJECT)
-LIBTARGET = lib$(PROJECT).so
-DIST_FILE = $(PROJECT)_$(VERSION).tar.gz
-MAN1 = $(PROJECT).1
+# flags used to build webextension
+EXTTARGET = webext_main.so
+EXTCFLAGS = ${CFLAGS} -fPIC $(shell pkg-config --cflags webkit2gtk-4.0)
+EXTCFLAGS += $(CPPFLAGS)
+EXTLDFLAGS = $(shell pkg-config --libs webkit2gtk-4.0) -shared
-MFLAGS ?= --no-print-directory
+# flags used for the main application
+CFLAGS += $(shell pkg-config --cflags $(LIBS))
+CFLAGS += ${CPPFLAGS}
+LDFLAGS += $(shell pkg-config --libs $(LIBS))
diff --git a/doc/vimb.1 b/doc/vimb.1
deleted file mode 100644
index 7c0e2ea8..00000000
--- a/doc/vimb.1
+++ /dev/null
@@ -1,1617 +0,0 @@
-.\" vim: ft=groff
-.ad l
-.TH VIMB 1 "DATE" "vimb/VERSION" "Vimb Manual"
-.de EX
-.nf
-.ft CW
-..
-.de EE
-.ft R
-.fi
-..
-.SH NAME
-Vimb - Vim Browser - A modal web browser based on WebKit, inspired by Vim: the
-great editor.
-.SH SYNOPSIS
-.B vimb
-.OP OPTIONS
-.RI [ URI "|" file "|" - ]
-.SH DESCRIPTION
-Vimb is a WebKit based web browser that behaves like the Vimperator
-plugin for Firefox and has usage paradigms from the great editor, Vim.
-The goal of Vimb is to build a completely keyboard-driven, efficient
-and pleasurable browsing-experience.
-.SH OPTIONS
-If no \fIURI\fP or \fIfile\fP is given, Vimb will open the configured
-home-page.
-If \fIURI\fP is '-', Vimb reads the HTML to display from stdin.
-.PP
-Mandatory arguments to long options are mandatory for short options too.
-.TP
-.BI "\-C, \-\-cmd " "CMD"
-Run \fICMD\fP as ex command line right before the first page is loaded.
-If the flag is used more than one time, the ordering is preserved when
-\fICMD\fP are executed.
-You could also pass several ex commands in one \fICMD\fP,
-if they are separated by "|".
-.sp
-Example:
-.EX
-vimb --cmd "set cookie-accept=origin|set header=Referer,DNT=1"
-.EE
-.TP
-.BI "\-c, \-\-config " "CONFIG-FILE"
-Use custom configuration given as \fICONFIG-FILE\fP.
-This will also be applied on new spawned instances.
-.TP
-.BI "\-p, \-\-profile " "PROFILE-NAME"
-Create or open specified configuration profile. Configuration data for the profile is stored in a directory named \fIPROFILE-NAME\fP under default directory for configuration data.
-.TP
-.BI "\-e, \-\-embed " "WINID"
-.I WINID
-of an XEmbed-aware application, that Vimb will use as its parent.
-.TP
-.B \-d, \-\-dump
-Dump the current used socket path to stdout in case Vimb is started with \-s
-option.
-.sp
-Example:
-.EX
-sh -c "./vimb -s -d > ~/vimb.socket" &
-echo ":o github.com" | socat - unix-connect:$(< ~/vimb.socket)
-.EE
-.TP
-.B "\-h, \-\-help"
-Show help options.
-.TP
-.B \-k, \-\-kiosk
-Run Vimb in kiosk mode with nearly no keybindings, not inputbox and no context
-menu.
-.TP
-.B \-s, \-\-socket
-If given Vimb will create a control socket in the user runtime directory.
-.TP
-.B "\-v, \-\-version"
-Print build and version information.
-.SH MODES
-Vimb is modal and has the following main modes:
-.TP
-.B Normal Mode
-The default mode.
-Pressing Escape always enter normal mode.
-.TP
-.B Input Mode
-Used for editing text elements in a webpage.
-.TP
-.B Command Mode
-Execute `ex` commands from the builtin inputbox (commandline).
-.TP
-.B Pass-Through Mode
-In Pass-Through mode only the `` and `` keybindings are interpreted
-by Vimb, all other keystrokes are given to the webview to handle them.
-This allows the use of a website's configured keybindings, that might otherwise
-be swallowed by Vimb.
-.SH NORMAL MODE COMMANDS
-Some of the Normal Model Commands can have a numeric count to multiply the
-effect of the command.
-If a command supports the count this is shown as \fB[N]\fP.
-.SS General
-.TP
-.B :
-Start Command Mode and print `:' to the input box.
-.TP
-.B gi
-Set cursor to the first editable element in the page and switch to Input
-Mode.
-.TP
-.B CTRL\-Z
-Switch Vimb into Pass-Through Mode.
-.TP
-.B gf
-Toggle show HTML source of the current page.
-.TP
-.B gF
-Open the Web Inspector for the current page.
-.TP
-.B CTRL\-V
-Pass the next key press directly to GTK.
-.TP
-.B CTRL\-Q
-Quit the browser if there are no running downloads.
-.SS Navigation
-.TP
-.B o
-Start Command Mode and print `:open ' to the input box.
-.TP
-.B O
-Start Command Mode and print `:open URI' to the input box.
-.TP
-.B t
-Start Command Mode and print `:tabopen ' to the input box.
-.TP
-.B T
-Start Command Mode and print `:tabopen URI' to the input box.
-.TP
-.B gh
-Open the configured home-page.
-.TP
-.B gH
-Open the configured home-page in a new window.
-.TP
-.B u
-Open the last closed page.
-.TP
-.B U
-Open the last closed page in a new window.
-.TP
-.B CTRL\-P
-Open the oldest entry from the Read It Later queue in the current browser window (only if
-Vimb has been compiled with QUEUE feature).
-.TP
-.BI [ \(dqx ]p
-Open the URI out of the register \fIx\fP or, if not given, from the clipboard.
-.TP
-.BI [ \(dqx ]P
-Open the URI out of the register \fIx\fP or, if not given, from the clipboard in a
-new window.
-.TP
-.BI [ N ]CTRL\-O
-Go back \fIN\fP steps in the browser history.
-.TP
-.BI [ N ]CTRL\-I
-Go forward \fIN\fP steps in the browser history.
-.TP
-.BI [ N ]gu
-Go to the \fIN\fPth descendent directory of the current opened URI.
-.TP
-.B gU
-Go to the domain of the current opened page.
-.TP
-.BI [ N ]CTRL\-A
-Increments the last number in URL by 1, or by \fIN\fP if given.
-.TP
-.BI [ N ]CTRL\-X
-Decrements the last number in URL by 1, or by \fIN\fP if given.
-Negative numbers are not supported as trailing numbers in URLs
-are often preceded by hyphens.
-.TP
-.B r
-Reload the website.
-.TP
-.B R
-Reload the website without using caches.
-.TP
-.B CTRL\-C
-Stop loading the current page.
-.SS Motion
-.TP
-.BI [ N ]CTRL\-F
-Scroll \fIN\fP pages down.
-.TP
-.BI [ N ]CTRL\-B
-Scroll \fIN\fP pages up.
-.TP
-.BI [ N ]CTRL\-D
-Scroll \fIN\fP half pages down.
-.TP
-.BI [ N ]CTRL\-U
-Scroll \fIN\fP half pages up.
-.TP
-.BI [ N ]gg
-Scroll to the top of the current page.
-Or if \fIN\fP is given to \fIN\fP% of the page.
-.TP
-.BI [ N ]G
-Scroll to the bottom of the current page.
-Or if \fIN\fP is given to \fIN\fP% of the page.
-.TP
-.B 0, ^
-Scroll to the absolute left of the document.
-Unlike in Vim, 0 and ^ work exactly the same way.
-.TP
-.B $
-Scroll to the absolute right of the document.
-.TP
-.BI [ N ]h
-Scroll \fIN\fP steps to the left of page.
-.TP
-.BI [ N ]l
-Scroll \fIN\fP steps to the right of page.
-.TP
-.BI [ N ]j
-Scroll page \fIN\fP steps down.
-.TP
-.BI [ N ]k
-Scroll page \fIN\fP steps up.
-.TP
-.BI [ N ]]]
-Follow the last \fIN\fPth link matching `nextpattern'.
-.TP
-.BI [ N ][[
-Follow the last \fIN\fPth link matching `previouspattern'.
-.TP
-.BI m{ a-z }
-Set a page mark {\fIa-z\fP} at the current position on the page.
-Such set marks are only available on the current page;
-if the page is left, all marks will be removed.
-.TP
-.BI '{ a-z }
-Jump to the mark {\fIa-z\fP} on the current page.
-.TP
-.B ''
-Jumps to the position before the latest jump, or where the last "m'" command
-was given.
-.SS Hinting
-Hinting in Vimb is how you accomplish the tasks that you would do with the
-mouse in common mouse-driven browsers: open a URI, yank a URI, save a page and
-so on. When hinting is started, the relevant elements on the page will
-be marked by labels generated from configured `hintkeys'.
-Hints can be selected by using , or , ,
-by typing the chars of the label, or filtering the elements by some text
-that is part of the hinted element (like URI, link text, button label)
-or any combination of these methods.
-If is pressed, the current active hint will be fired.
-If only one possible hint remains, this will be fired automatically.
-.PP
-.BI Syntax: " ;{mode}{hint}"
-.PP
-Start Hints mode.
-Different elements depending on \fImode\fP are highlighted and `numbered'.
-Elements can be selected either by typing their label, or by typing part
-of their text (\fIhint\fP) to narrow down the result.
-When an element has been selected, it is automatically clicked
-or used (depending on \fImode\fP) and hint mode ends.
-.PP
-The filtering of hints by text splits the query at ' ' and use the single parts
-as separate queries to filter the hints.
-This is useful for hints that have a lot of filterable chars in common
-and many chars are required to make a distinct selection.
-For example ';over tw' will easily select the second hint out of
-{'very long link text one', 'very long link text two'}.
-.PP
-The following keys have special meanings in Hints modes:
-.PD 0
-.IP \fB\fP
-Selects the first highlighted element, or the current focused.
-.IP "\fB\fP"
-Moves the focus to the next hint element.
-.IP "\fB\fP"
-Moves the focus to the previous hint element.
-.IP "\fB, CTRL\-C, CTRL\-[\fP"
-Exits Hints mode without selecting an element.
-.PD
-.TP
-.B Hint modes:
-.RS
-.PD 0
-.TP
-.B f
-Is an alias for the \fB;o\fP hint mode.
-.TP
-.B F
-Is an alias for the \fB;t\fP hint mode.
-.TP
-.B ;o
-Open hint's location in the current window.
-.TP
-.B ;t
-Open hint's location in a new window.
-.TP
-.B ;s
-Saves the hint's destination under the configured `download-path'.
-.TP
-.B ;O
-Generate an `:open' prompt with hint's URI.
-.TP
-.B ;T
-Generate an `:tabopen' prompt with hint's URI.
-.TP
-.B ;e
-Open the configured $EDITOR (`editor-command') with the hinted form element's
-content.
-If the file in $EDITOR is saved and the $EDITOR is closed, the file
-content will be put back in the form field.
-.TP
-.B ;i
-Open hinted image in the current window.
-.TP
-.B ;I
-Open hinted image in a new window.
-.TP
-.B ;p
-Push the hint's URI to the end of the Read It Later queue like the `:qpush'
-command.
-This is only available if Vimb was compiled with the QUEUE feature.
-.TP
-.B ;P
-Push the hint's URI to the beginning of the Read It Later queue like the
-`:qunshift' command.
-This is only available if Vimb was compiled with the QUEUE feature.
-.TP
-.B ;x
-Hints like ;o, but instead of opening the hinted URI, the
-`x-hint-command' is run in Vimb.
-.TP
-.BI [ \(dqx ];y
-Yank hint's destination location into primary and secondary clipboard and into
-the register \fIx\fP.
-.TP
-.BI [ \(dqx ];Y
-Yank hint's text description or form text into primary and secondary clipboard
-and into the register \fIx\fP.
-.PD
-.RE
-.TP
-.BI Syntax: " g;{mode}{hint}"
-Start an extended hints mode and stay there until is pressed.
-Like normal hinting, except that after a hint is selected, hints
-remain visible so that another one can be selected with the same action
-as the first.
-Note that the extended hint mode can only be combined with the following
-hint modes \fII p P s t y Y\fP.
-.SS Searching
-.TP
-.BI / QUERY ", ?" QUERY
-Start searching for \fIQUERY\fP in the current page.
-\fI/\fP start search forward, \fI?\fP in backward direction.
-.TP
-.B *, #
-Start searching for the current selected text, or if no text is selected for
-the content of the primary or secondary clipboard.
-\fI*\fP start the search in forward direction and \fI#\fP in backward
-direction.
-.sp
-Note that these commands will yank the text selection into the clipboard and
-may remove other content from there!
-.TP
-.BI [ N ]n
-Search for \fIN\fPnth next search result depending on current search
-direction.
-.TP
-.BI [ N ]N
-Search for \fIN\fPnth previous search result depending on current search
-direction.
-.SS Zooming
-.TP
-.BI [ N ]zi
-Zoom-In the text of the page by \fIN\fP steps.
-.TP
-.BI [ N ]zo
-Zoom-Out the text of the page by \fIN\fP steps.
-.TP
-.BI [ N ]zI
-Full-Content Zoom-In the page by \fIN\fP steps.
-.TP
-.BI [ N ]zO
-Full-Content Zoom-Out the page by \fIN\fP steps.
-.TP
-.B zz
-Reset Zoom.
-.SS Yank
-.TP
-.BI [ \(dqx ]y
-Yank the URI or current page into register \fIx\fP and clipboard.
-.TP
-.BI [ \(dqx ]Y
-Yank the current selection into register \fIx\fP and clipboard.
-.SH COMMAND MODE
-Commands that are listed below are ex-commands like in Vim, that are typed
-into the inputbox (the command line of vimb).
-The commands may vary in their syntax or in the parts they allow,
-but in general they follow a simple syntax.
-.PP
-.BI Syntax: " :[:| ][N]cmd[name][!][ lhs][ rhs]"
-.sp
-Where \fIlhs\fP (left hand side) must not contain any unescaped space.
-The syntax of the rhs (right hand side) if this is available depends on the
-command.
-At the moment the count parts [N] of commands is parsed, but currently there is
-no command that uses the count.
-.sp
-Commands that are typed interactivly (from the inputbox or from socket) are
-normally recorded into command history and register.
-To avoid this, the commands can be prefixed by one or more additional `:' or
-whitespace.
-.PP
-Multiple commands, separated by a `|' can be given in a single command line
-and will be executed consecutively.
-The pipe can be included as an argument to a command by escaping it with a
-backslash.
-.br
-Following commands process the entire command-line string literally.
-These commands will include any `|' as part of their argument string and so
-cannot be followed by another command.
-.PP
-.PD 0
-.IP - 2
-autocmd
-.IP -
-cmap, cnoremap, imap, inoremap, nmap, nnoremap
-.IP -
-eval
-.IP -
-normal
-.IP -
-open, tabopen
-.IP -
-shellcmd
-.PD
-.SS Command Line Editing
-.TP
-.B , CTRL\-[, CTRL-C
-Ignore all typed content and switch back to normal mode.
-.TP
-.B
-Submit the entered `ex` command or search query to run it.
-.TP
-.B CTRL\-H
-Deletes the char before the cursor.
-.TP
-.B CTRL\-W
-Deletes the last word before the cursor.
-.TP
-.B CTRL\-U
-Remove everything between cursor and prompt.
-.TP
-.B CTRL\-B
-Moves the cursor directly behind the prompt `:'.
-.TP
-.B CTRL\-E
-Moves the cursor after the char in inputbox.
-.TP
-.B CTRL\-V
-Pass the next key press directly to GTK.
-.TP
-.B CTRL\-R {a-z"%:/;}
-Insert the content of given register at cursor position.
-See also section about `:reg[ister]' command.
-.SS Command Line History
-.TP
-.B
-Start completion of the content in the inputbox in forward direction.
-.TP
-.B
-Start completion of the content in the inputbox in backward direction.
-.TP
-.B
-Step backward in the command history.
-.TP
-.B
-Step forward in the command history.
-.SS Open
-.TP
-.BI ":o[pen] [" URI ]
-Open the give \fIURI\fP in the current window.
-If \fIURI\fP is empty, the configured 'home-page' is opened.
-.TP
-.BI ":t[abopen] [" URI ]
-Open the give \fIURI\fP in a new window.
-If \fIURI\fP is empty, the configured 'home-page' is opened.
-.SS Key Mapping
-Key mappings allow users to alter the actions of key presses.
-Each key mapping is associated with a mode and only has effect
-when the mode is active.
-The following commands allow the user to substitute one sequence
-of key presses by another.
-.PP
-.BI Syntax: " :{m}map {lhs} {rhs}"
-.PP
-Note that the \fIlhs\fP ends with the first found space.
-If you want to use space also in the {lhs} you have to escape this
-with a single `\\', as shown in the examples.
-.sp
-The \fIrhs\fP starts with the first non-space char. If you want a \fIrhs\fP
-that starts with a space, you have to use "".
-.PP
-Standard key mapping commands are provided for these modes \fIm\fP:
-.PD 0
-.IP \fBn\fP
-Normal mode: when browsing normally.
-.IP \fBi\fP
-Insert mode: when interacting with text fields on a website.
-.IP \fBc\fP
-Command Line mode: when typing into Vimb's command line.
-.PD
-.PP
-Most keys in key sequences are represented simply by the character that you
-see on the screen when you type them.
-However, as a number of these characters have special meanings, and a
-number of keys have no visual representation, a special notation is required.
-.PP
-As special key names have the format \fI<...>\fP.
-The following special keys can be used: , , ,
-for the cursor keys, , , , , , - and -.
-.TP
-.BI ":nm[ap] {" lhs "} {" rhs }
-.TP
-.BI ":im[ap] {" lhs "} {" rhs }
-.TP
-.BI ":cm[ap] {" lhs "} {" rhs }
-Map the key sequence \fIlhs\fP to \fIrhs\fP for the modes where the map
-command applies.
-The result, including \fIrhs\fP, is then further scanned for mappings.
-This allows for nested and recursive use of mappings.
-.RS
-.P
-Examples:
-.PD 0
-.IP ":cmap h /home/user/downloads/"
-Adds a keybind to insert a file path into the input box.
-This could be useful for the `:save' command
-that could be used as ":save ^Gh".
-.IP ":nmap :set scripts=on:open !glib"
-This will enable scripts and lookup the first bookmarked URI with the tag
-`glib' and open it immediately if F1 key is pressed.
-.IP ":nmap \\\\\ \\\\\ 50G;o"
-Example which maps two spaces to go to 50% of the page, and start hinting mode.
-.PD
-.RE
-.TP
-.BI ":nn[oremap] {" lhs "} {" rhs }
-.TP
-.BI ":ino[remap] {" lhs "} {" rhs }
-.TP
-.BI ":cno[remap] {" lhs "} {" rhs }
-Map the key sequence \fIlhs\fP to \fIrhs\fP for the mode where the map command
-applies.
-Disallow mapping of \fIrhs\fP, to avoid nested and recursive mappings.
-Often used to redefine a command.
-.TP
-.BI ":nu[nmap] {" lhs }
-.TP
-.BI ":iu[nmap] {" lhs }
-.TP
-.BI ":cu[nmap] {" lhs }
-Remove the mapping of \fIlhs\fP for the applicable mode.
-.SS Bookmarks
-.TP
-.BI ":bma [" tags ]
-Save the current opened URI with \fItags\fP to the bookmark file.
-.TP
-.BI ":bmr [" URI ]
-Removes all bookmarks for given \fIURI\fP or, if not given, the current opened
-page.
-.SS Handlers
-Handlers allow specifying external scripts to handle alternative URI methods.
-.TP
-.BI ":handler-add " "handler" "=" "cmd"
-Adds a handler to direct \fIhandler\fP links to the external \fIcmd\fP.
-The \fIcmd\fP can contain one placeholder `%s` that will be filled by the
-full URI given when the command is called.
-.RS
-.P
-Examples:
-.PD 0
-.IP ":handler-add magnet=xdg-open %s"
-to open magnet links with xdg-open.
-.IP ":handler-add magnet=transmission-gtk %s"
-to open magnet links directly with Transmission.
-.IP ":handler-add irc=irc-handler.sh %s"
-to direct irc://:/ links to a wrapper for your IRC client.
-.PD
-.RE
-.TP
-.BI ":handler-remove " "handler"
-Remove the handler for the given URI \fIhandler\fP.
-.SS Shortcuts
-Shortcuts allow the opening of an URI built up from a named template with additional
-parameters.
-If a shortcut named 'dd' is defined, you can use it with `:open dd
-list of parameters' to open the generated URI.
-.PP
-Shortcuts are convenient to use with search engines where the URI is standardised
-and a single parameter is user defined.
-.TP
-.BI ":shortcut-add " "shortcut" "=" "URI"
-Adds a shortcut with the \fIshortcut\fP and \fIURI\fP template.
-The \fIURI\fP can contain multiple placeholders $0-$9 that will be
-filled by the parameters given when the shortcut is called.
-The parameters given when the shortcut is called will be split
-into as many parameters like the highest used placeholder.
-.sp
-To use spaces within the parameters, the parameters can be grouped by
-surrounding them with single-or double quotes-as shown in example shortcut
-`map'.
-.RS
-.P
-Examples:
-.PD 0
-.IP ":shortcut-add dl=https://duckduckgo.com/lite/?q=$0"
-to setup a search engine.
-Can be called by `:open dl my search phrase'.
-.IP ":shortcut-add gh=https://github.com/$0/$1"
-to build URIs from given parameters.
-Can be called `:open gh fanglingsu vimb'.
-.IP ":shortcut-add map=https://maps.google.com/maps?saddr=$0&daddr=$1"
-to search for a route, all but the last parameter must be quoted if they
-contain spaces like `:open map "city hall, London" railway station, London'
-.PD
-.RE
-.TP
-.BI ":shortcut-remove " "shortcut"
-Remove the search engine to the given \fIshortcut\fP.
-.TP
-.BI ":shortcut-default " "shortcut"
-Set the shortcut for given \fIshortcut\fP as the default.
-It doesn't matter if the \fIshortcut\fP is already in use or not
-to be able to set it.
-.SS Settings
-.TP
-.BI ":se[t] " var = value
-Set configuration values named by \fIvar\fP.
-To set boolean variable you should use 'on', 'off' or 'true' and 'false'.
-Colors are given as hexadecimal value like '#f57700'.
-.TP
-.BI ":se[t] " var += value
-Add the \fIvalue\fP to a number option, or append the \fIvalue\fP to a string
-option.
-When the option is a comma separated list, a comma is added, unless
-the value was empty.
-.TP
-.BI ":se[t] " var ^= value
-Multiply the \fIvalue\fP to a number option, or prepend the \fIvalue\fP to a
-string option.
-When the option is a comma separated list, a comma is added,
-unless the value was empty.
-.TP
-.BI ":se[t] " var -= value
-Subtract the \fIvalue\fP from a number option, or remove the \fIvalue\fP from
-a string option, if it is there.
-When the option is a comma separated list, a
-comma is deleted, unless the option becomes empty.
-.TP
-.BI ":se[t] " var ?
-Show the current set value of variable.
-.IR VAR .
-.TP
-.BI ":se[t] " var !
-Toggle the value of boolean variable \fIvar\fP and display the new set value.
-.SS Queue
-The queue allows the marking of URIs for later reading (something like a Read It Later
-list).
-This list is shared between the single instances of Vimb.
-Only available if Vimb has been compiled with the QUEUE feature.
-.TP
-.BI ":qpu[sh] [" URI ]
-Push \fIURI\fP or, if not given, the current URI to the end of the queue.
-.TP
-.BI ":qun[shift] [" URI ]
-Push \fIURI\fP or, if not given, the current URI to the beginning of the queue.
-.TP
-.B :qp[op]
-Open the oldest queue entry in the current browser window and remove it from the
-queue.
-.TP
-.B :qc[lear]
-Removes all entries from queue.
-.SS Automatic commands
-An autocommand is a command that is executed automatically in response to some
-event, such as a URI being opened.
-Autocommands are very powerful.
-Use them with care and they will help you avoid typing many commands.
-.PP
-Autocommands are built with following properties.
-.TP
-.I group
-When the [\fIgroup\fP] argument is not given, Vimb uses the current group as
-defined with ':augroup', otherwise, Vimb uses the group defined with
-[\fIgroup\fP].
-Groups are useful to remove multiple grouped autocommands.
-.TP
-.I event
-You can specify a comma separated list of event names.
-No white space can be used in this list.
-.RS
-.PP
-.PD 0
-Events:
-.TP
-.B LoadProvisional
-Fired if a new page is going to be opened.
-No data has been received yet, the load may still fail for transport issues.
-.TP
-.B LoadCommited
-Fired if first data chunk has arrived, meaning that the necessary transport
-requirements are established, and the load is being performed.
-This is the right event to toggle content related setting
-like 'scripts', 'plugins' and such things.
-.TP
-.B LoadFirstLayout
-fired if the first layout with actual visible content is shown.
-.TP
-.B LoadFinished
-Fires when everything that was required to display on the page has been loaded.
-.TP
-.B LoadFailed
-Fired when some error occurred during the page load that prevented it from
-being completed.
-.TP
-.B DownloadStart
-Fired right before a download is started.
-This is fired for Vimb downloads as well as external downloads
-if 'download-use-external' is enabled.
-.TP
-.B DownloadFinished
-Fired if a Vimb managed download is finished.
-For external download this event is not available.
-.TP
-.B DownloadFailed
-Fired if a Vimb managed download failed.
-For external download this event is not available.
-.PD
-.RE
-.TP
-.I pat
-Comma separated list of patterns, matches in order to check if a autocommand
-applies to the URI associated to an event.
-To use ',' within the single patterns this must be escaped as '\e,'.
-.RS
-.PP
-.PD 0
-Patterns:
-.IP "\fB*\fP"
-Matches any sequence of characters.
-This includes also '/' in contrast to shell patterns.
-.IP "\fB?\fP"
-Matches any single character except of '/'.
-.IP "\fB{one,two}\fP"
-Matches 'one' or 'two'.
-Any '{', ',' and '}' within this pattern must be escaped by a '\\'.
-\&'*' and '?' have no special meaning within the curly braces.
-.IP "\fB\e\fP"
-Use backslash to escape the special meaning of '?*{},' in the pattern or
-pattern list.
-.PD
-.RE
-.TP
-.I cmd
-Any `ex` command vimb understands.
-The leading ':' is not required.
-Multiple commands can be separated by '|'.
-.TP
-.BI ":au[tocmd] [" group "] {" event "} {" pat "} {" cmd "}"
-Add \fIcmd\fP to the list of commands that Vimb will execute automatically on
-\fIevent\fP for a URI matching \fIpat\fP autocmd-patterns.
-Vimb always adds the \fIcmd\fP after existing autocommands, so that the
-autocommands are executed in the order in which they were given.
-.TP
-.BI ":au[tocmd]! [" group "] {" event "} {" pat "} {" cmd "}"
-Remove all autocommands associated with \fIevent\fP and which pattern match
-\fIpat\fP, and add the command \fIcmd\fP.
-Note that the pattern is not matches literally to find autocommands
-to remove, like Vim does.
-Vimb matches the autocommand pattern with \fIpat\fP.
-If [\fIgroup\fP] is not given, deletes autocommands in current group,
-as noted above.
-.TP
-.BI ":au[tocmd]! [" group "] {" event "} {" pat "}"
-Remove all autocommands associated with \fIevent\fP and which pattern matches
-\fIpat\fP in given group (current group by default).
-.TP
-.BI ":au[tocmd]! [" group "] * {" pat "}"
-Remove all autocommands with patterns matching \fIpat\fP for all events
-in given group (current group by default).
-.TP
-.BI ":au[tocmd]! [" group "] {" event "}"
-Remove all autocommands for \fIevent\fP in given group (current group
-by default).
-.TP
-.BI ":au[tocmd]! [" group "]"
-Remove all autocommands in given group (current group by default).
-.TP
-.BI ":aug[roup] {" name "}"
-Define the autocmd group \fIname\fP for the following ":autocmd" commands.
-The name "end" selects the default group.
-.TP
-.BI ":aug[roup]! {" name "}"
-Delete the autocmd group \fIname\fP.
-.PP
-Example:
-.EX
-:aug github
-: au LoadCommited * set scripts=off|set cookie-accept=never
-: au LoadCommited http{s,}://github.com/* set scripts=on
-:aug end
-.EE
-.SS Misc
-.TP
-.BI ":sh[ellcmd] " cmd
-Runs the given shell \fIcmd\fP syncron and print the output into inputbox.
-The following patterns in \fIcmd\fP are expanded: '~username', '~/', '$VAR'
-and '${VAR}'.
-A '\\' before these patterns disables the expansion.
-.PP
-.RS
-.PP
-.PD 0
-The following environment variables are set for called shell commands.
-.TP
-.B VIMB_URI
-This variable is set by Vimb everytime a new page is opened to the URI of the
-page.
-.TP
-.B VIMB_TITLE
-Contains the title of the current opened page.
-.TP
-.B VIMB_PID
-Contains the pid of the running Vimb instance.
-.TP
-.B VIMB_SOCKET
-Holds the full path to the control socket, if Vimb is compiled with SOCKET
-feature and started with `--socket' option.
-.TP
-.B VIMB_XID
-Holds the X-Window id of the Vimb window or of the embedding window if Vimb is
-started with the -e option.
-.PD
-.PP
-Example:
-.EX
-:sh ls -l $HOME
-.EE
-.RE
-.TP
-.BI ":sh[ellcmd]! " cmd
-Like :sh[ellcmd], but asyncron.
-.sp
-Example:
-.EX
-:sh! /bin/sh -c 'echo "`date` $VIMB_URI" >> myhistory.txt'
-.EE
-.TP
-.BI ":s[ave] [" path "]"
-Download current opened page into configured download directory.
-If \fIpath\fP is given, download under this file name or path.
-\fIpath\fP is expanded and can therefore contain '~/', '${ENV}'
-and '~user' pattern.
-.TP
-.BI ":so[urce] [" file "]"
-Read ex commands from \fIfile\fP.
-.TP
-.B :q[uit]
-Close the browser.
-This will be refused if there are running downloads.
-.TP
-.B :q[uit]!
-Close the browser independent from an running download.
-.TP
-.B :reg[ister]
-Display the contents of all registers.
-.RS
-.PP
-.PD 0
-Registers:
-.TP
-.BR \(dqa " - " \(dqz
-26 named registers "a to "z.
-Vimb fills these registers only when you say so.
-.TP
-.B \(dq:
-Last executed `ex` command.
-.TP
-.B \(dq"
-Last yanked content.
-.TP
-.B \(dq%
-Curent opened URI.
-.TP
-.B \(dq/
-Last search phrase.
-.TP
-.B \(dq;
-Contains the last hinted URL.
-This can be used in `x-hint-command' to get the URL of the hint.
-.PD
-.RE
-.TP
-.BI :e[val] " javascript"
-Runs the given \fIjavascript\fP in the current page and display the evaluated
-value.
-.sp
-Example: :eval document.cookie
-.TP
-.BI :e[val]! " javascript"
-Like :eval, but there is nothing print to the input box.
-.TP
-.BI ":no[rmal] [" cmds ]
-Execute normal mode commands \fIcmds\fP.
-This makes it possible to execute normal mode commands typed on the input box.
-.sp
-\fIcmds\fP cannot start with a space.
-Put a count of 1 (one) before it, "1 " is one space.
-.sp
-Example: :set scripts!|no! R
-.TP
-.BI ":no[rmal]! [" cmds ]
-Like :normal, but no mapping is applied to \fIcmds\fP.
-.TP
-.B :ha[rdcopy]
-Print current document.
-Open a GUI dialog where you can select the printer,
-number of copies, orientation, etc.
-.SH INPUT MODE
-.TP
-.B , CTRL\-[
-Switch back to normal mode.
-.TP
-.B CTRL\-O
-Executes the next command as normal mode command and return to input mode.
-.TP
-.B CTRL\-T
-Open configured $EDITOR with content of current form field.
-.TP
-.B CTRL\-V
-Pass the next key press directly to GTK.
-.TP
-.B CTRL\-Z
-Enter the pass-through mode.
-.SH COMPLETIONS
-The completions are triggered by pressing `` or `` in the
-activated inputbox.
-Depending of the current inserted content different completions are started.
-The completion takes additional typed chars to filter
-the completion list that is shown.
-.TP
-.B commands
-The completion for commands are started when at least `:` is shown in the
-inputbox.
-If initial chars are passed, the completion will lookup those
-commands that begin with the given chars.
-.TP
-.B settings
-The setting name completion is started if at least `:set ` is shown in
-inputbox and does also match settings that begins with already typed setting
-prefix.
-.TP
-.B history
-The history of URIs is shown for the `:open ` and `:tabopen ` commands.
-This completion looks up every given word in the history URI and titles.
-Only those history items are shown, where the title or URI contains all tags.
-.sp
-Example:
-.RS
-.PD 0
-.IP ":open foo bar"
-will complete only URIs that contain the words foo and bar.
-.PD
-.RE
-.TP
-.B bookmarks
-The bookmark completion is similar to the history completion, but does match
-only the tags of the bookmarks.
-The bookmark completion ist started by `:open \fB!\fP`
-or `:tabopen \fB!\fP` and does a prefix search for all given words in
-the bookmark tags.
-.sp
-Example:
-.RS
-.PD 0
-.IP ":open \fB!\fPfoo ba"
-will match all bookmarks that have tags starting with "foo" and "ba".
-If the bookmark does not have any tags set, the URL is split on `.' and `/'
-into tags.
-.PD
-.RE
-.TP
-.B boomark tags
-The boomark tag completion allows the insertion of already used bookmarks for the
-`:bma ` commands.
-.TP
-.B search
-The search completion allows a filtered list of already done searches.
-This completion starts by `/` or `?` in inputbox and performs a prefix
-comparison for further typed chars.
-.SH SETTINGS
-All settings listed below can be set with the `:set' command.
-.SS WebKit-Settings
-.TP
-.B accelerated-compositing (bool)
-Enable or disable support for accelerated compositing on pages.
-Accelerated compositing uses the GPU to render animations on pages
-smoothly and also allows proper rendering of 3D CSS transforms.
-.TP
-.B auto-load-images (bool)
-Load images automatically.
-.TP
-.B auto-resize-window (bool)
-Indicates if Vimb will honor size and position changes of the window by various
-DOM methods.
-.TP
-.B auto-shrink-images (bool)
-Automatically shrink standalone images to fit.
-.TP
-.B caret (bool)
-Whether to enable accessibility enhanced keyboard navigation.
-.TP
-.B closed-max-items (int)
-Maximum number of stored last closed browser windows. If closed-max-items is
-set to 0, closed browser windows will not be stored.
-.TP
-.B cursivfont (string)
-The font family used as the default for content using cursive font.
-.TP
-.B defaultencoding (string)
-The default text charset used when interpreting content with an unspecified
-charset.
-.TP
-.B defaultfont (string)
-The font family to use as the default for content that does not specify a
-font.
-.TP
-.B dns-prefetching (bool)
-Indicates if Vimb prefetches domain names.
-.TP
-.B dom-paste (bool)
-Whether to enable DOM paste.
-If set to TRUE, document.execCommand("Paste")
-will correctly execute and paste content of the clipboard.
-.TP
-.B file-access-from-file-uris (bool)
-Boolean property to control file access for file:// URIs.
-If this option is enabled every file:// will have its own security
-unique domain.
-.TP
-.B fontsize (int)
-The default font size used to display text.
-.TP
-.B frame-flattening (bool)
-Whether to enable the Frame Flattening.
-With this setting each subframe is expanded to its contents,
-which will flatten all the frames to become one scrollable page.
-.TP
-.B html5-database (bool)
-Whether to enable HTML5 client-side SQL database support.
-Client-side SQL database allows web pages to store structured data
-and be able to use SQL to manipulate that data asynchronously.
-.TP
-.B html5-local-storage (bool)
-Whether to enable HTML5 localStorage support.
-localStorage provides simple synchronous storage access.
-.TP
-.B hyperlink-auditing (bool)
-Enable or disable support for .
-.TP
-.B images (bool)
-Determines whether images should be automatically loaded or not.
-.TP
-.B insecure-content-show (bool)
-Whether pages loaded via HTTPS should load subresources such as images and
-frames from non-HTTPS URIs.
-Only for webkit>=2.0.
-.TP
-.B insecure-content-run (bool)
-Whether pages loaded via HTTPS should run subresources such as CSS, scripts,
-and plugins from non-HTTPS URIs.
-Only for webkit>=2.0.
-.TP
-.B java-applet (bool)
-Enable or disable support for the Java
-
-
- Also the following element using contenteditable="true"
- should switch vimb into input mode on click.
-
-
- Clicking this element using contenteditable="true" should
- switch vimb into input mode too.
-
- The hsts domain used in iFrame with http must not lead to load the
- iframe content as page.
-
-
-
-
diff --git a/tests/manual/201-editable-focus-in-iframes.html b/tests/manual/201-editable-focus-in-iframes.html
deleted file mode 100644
index d02c0fb5..00000000
--- a/tests/manual/201-editable-focus-in-iframes.html
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-Track Focu/Blur also within iFrames
-
-
-
-
-
-
diff --git a/tests/test-handlers.c b/tests/test-handlers.c
deleted file mode 100644
index 8cff0b1a..00000000
--- a/tests/test-handlers.c
+++ /dev/null
@@ -1,80 +0,0 @@
-/**
- * vimb - a webkit based vim like browser.
- *
- * Copyright (C) 2012-2015 Daniel Carl
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see http://www.gnu.org/licenses/.
- */
-
-#include
-#include
-
-#define TEST_URI "http://fanglingsu.github.io/vimb/"
-
-static void test_handler_add(void)
-{
- /* check none handled http first */
- g_assert_true(handler_add("http", "echo -n 'handled uri %s'"));
-}
-
-static void test_handler_remove(void)
-{
- handler_add("http", "e");
-
- g_assert_true(handler_remove("http"));
- g_assert_false(handler_remove("http"));
-}
-
-static void test_handler_run_success(void)
-{
- if (g_test_subprocess()) {
- handler_add("http", "echo -n 'handled uri %s'");
- handle_uri(TEST_URI);
- return;
- }
- g_test_trap_subprocess(NULL, 0, 0);
- g_test_trap_assert_passed();
- g_test_trap_assert_stdout("handled uri " TEST_URI);
-}
-
-static void test_handler_run_failed(void)
-{
- if (g_test_subprocess()) {
- handler_add("http", "unknown-program %s");
- handle_uri(TEST_URI);
- return;
- }
- g_test_trap_subprocess(NULL, 0, 0);
- g_test_trap_assert_failed();
- g_test_trap_assert_stderr("*Can't run *unknown-program*");
-}
-
-int main(int argc, char *argv[])
-{
- int result;
- handlers_init();
-
- g_test_init(&argc, &argv, NULL);
-
- g_test_add_func("/test-handlers/add", test_handler_add);
- g_test_add_func("/test-handlers/remove", test_handler_remove);
- g_test_add_func("/test-handlers/handle_uri/success", test_handler_run_success);
- g_test_add_func("/test-handlers/handle_uri/failed", test_handler_run_failed);
-
- result = g_test_run();
-
- handlers_cleanup();
-
- return result;
-}
diff --git a/tests/test-map.c b/tests/test-map.c
deleted file mode 100644
index 8fe5ace8..00000000
--- a/tests/test-map.c
+++ /dev/null
@@ -1,176 +0,0 @@
-/**
- * vimb - a webkit based vim like browser.
- *
- * Copyright (C) 2012-2015 Daniel Carl
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see http://www.gnu.org/licenses/.
- */
-
-#include
-#include
-#include
-#include
-#include
-
-static char queue[20]; /* receives the keypresses */
-static int qpos = 0; /* points to the queue entry for the next keypress */
-
-#define QUEUE_APPEND(c) { \
- queue[qpos++] = (char)c; \
- queue[qpos] = '\0'; \
-}
-#define QUEUE_CLEAR() {queue[(qpos = 0)] = '\0';}
-#define ASSERT_MAPPING(s, e) { \
- QUEUE_CLEAR(); \
- map_handle_string(s, true); \
- g_assert_cmpstr(queue, ==, e); \
-}
-
-typedef struct {
- guint state;
- guint keyval;
-} TestKeypress;
-
-VbResult keypress(int key)
-{
- /* put the key into the queue */
- QUEUE_APPEND(key);
-
- return RESULT_COMPLETE;
-}
-
-static void test_handle_string_simple(void)
-{
- /* test simple mappings */
- ASSERT_MAPPING("a", "[a]");
- ASSERT_MAPPING("b", "[b]");
- ASSERT_MAPPING("[c]", "c");
- ASSERT_MAPPING("d", " [d]");
- ASSERT_MAPPING("", "[tab]");
- ASSERT_MAPPING("", "[shift-tab]");
- ASSERT_MAPPING("", "[ctrl-f]");
- ASSERT_MAPPING("", "[ctrl-f]");
- ASSERT_MAPPING("", "[cr]");
- ASSERT_MAPPING("foobar", "[baz]");
-
- /* key sequences that are not changed by mappings */
- ASSERT_MAPPING("fghi", "fghi");
-}
-
-static void test_handle_string_alias(void)
-{
- /* CTRL-I is the same like and CTRL-M like */
- ASSERT_MAPPING("", "[tab]");
- ASSERT_MAPPING("", "[cr]");
-}
-
-static void test_handle_string_remapped(void)
-{
- /* test multiple mappings together */
- ASSERT_MAPPING("ba", "[b][a]");
- ASSERT_MAPPING("ab12345[c]", "[a][b]12345c");
-
- /* incomplete ambiguous sequences are not matched jet */
- ASSERT_MAPPING("foob", "");
- ASSERT_MAPPING("ar", "[baz]");
-
- /* test remapping */
- map_insert("c", "baza", 't', true);
- ASSERT_MAPPING("c", "[b][a]z[a]");
- map_insert("d", "cki", 't', true);
- ASSERT_MAPPING("d", "[b][a]z[a]ki");
-
- /* remove the no more needed mappings */
- map_delete("c", 't');
- map_delete("d", 't');
-}
-
-static void test_handle_string_overrule(void)
-{
- /* add another map for 'a' and check if this overrules the previous set */
- map_insert("a", "overruled", 't', false);
- ASSERT_MAPPING("a", "overruled");
-}
-
-static void test_remove(void)
-{
- map_insert("x", "[x]", 't', false);
- /* make sure that the mapping works */
- ASSERT_MAPPING("x", "[x]");
-
- map_delete("x", 't');
-
- /* make sure the mapping removed */
- ASSERT_MAPPING("x", "x");
-}
-
-static void test_keypress_single(void)
-{
- QUEUE_CLEAR();
-
- map_keypress(NULL, &((GdkEventKey){.keyval = GDK_Tab, .state = GDK_SHIFT_MASK}), NULL);
- g_assert_cmpstr(queue, ==, "[shift-tab]");
-}
-
-static void test_keypress_sequence(void)
-{
- QUEUE_CLEAR();
-
- map_keypress(NULL, &((GdkEventKey){.keyval = GDK_f}), NULL);
- g_assert_cmpstr(queue, ==, "");
- map_keypress(NULL, &((GdkEventKey){.keyval = GDK_o}), NULL);
- g_assert_cmpstr(queue, ==, "");
- map_keypress(NULL, &((GdkEventKey){.keyval = GDK_o}), NULL);
- g_assert_cmpstr(queue, ==, "");
- map_keypress(NULL, &((GdkEventKey){.keyval = GDK_b}), NULL);
- g_assert_cmpstr(queue, ==, "");
- map_keypress(NULL, &((GdkEventKey){.keyval = GDK_a}), NULL);
- g_assert_cmpstr(queue, ==, "");
- map_keypress(NULL, &((GdkEventKey){.keyval = GDK_r}), NULL);
- g_assert_cmpstr(queue, ==, "[baz]");
-}
-
-int main(int argc, char *argv[])
-{
- int result;
- g_test_init(&argc, &argv, NULL);
-
- /* add a test mode to handle the maped sequences */
- vb_add_mode('t', NULL, NULL, keypress, NULL);
- vb_enter('t');
- map_init();
-
- g_test_add_func("/test-map/handle_string/simple", test_handle_string_simple);
- g_test_add_func("/test-map/handle_string/alias", test_handle_string_alias);
- g_test_add_func("/test-map/handle_string/remapped", test_handle_string_remapped);
- g_test_add_func("/test-map/handle_string/overrule", test_handle_string_overrule);
- g_test_add_func("/test-map/remove", test_remove);
- g_test_add_func("/test-map/keypress/single-char", test_keypress_single);
- g_test_add_func("/test-map/keypress/sequence", test_keypress_sequence);
-
- /* add some mappings to test */
- map_insert("a", "[a]", 't', false); /* inlen < mappedlen */
- map_insert("b", "[b]", 't', false);
- map_insert("d", "[d]", 't', false);
- map_insert("[c]", "c", 't', false); /* inlen > mappedlen */
- map_insert("foobar", "[baz]", 't', false);
- map_insert("", "[tab]", 't', false);
- map_insert("", "[shift-tab]", 't', false);
- map_insert("", "[ctrl-f]", 't', false);
- map_insert("", "[cr]", 't', false);
-
- result = g_test_run();
- map_cleanup();
- return result;
-}
diff --git a/tests/test-shortcut.c b/tests/test-shortcut.c
deleted file mode 100644
index 697a04df..00000000
--- a/tests/test-shortcut.c
+++ /dev/null
@@ -1,142 +0,0 @@
-/**
- * vimb - a webkit based vim like browser.
- *
- * Copyright (C) 2012-2015 Daniel Carl
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see http://www.gnu.org/licenses/.
- */
-
-#include
-#include
-
-static void test_shortcut_single(void)
-{
- char *uri;
-
- /* call with shortcut identifier */
- uri = shortcut_get_uri("_vimb1_ zero one");
- g_assert_cmpstr(uri, ==, "only-zero:zero%20one");
- g_free(uri);
-
- /* don't fail on unmatches quotes if there are only $0 placeholders */
- uri = shortcut_get_uri("_vimb1_ 'unmatched quote");
- g_assert_cmpstr(uri, ==, "only-zero:'unmatched%20quote");
- g_free(uri);
-
- /* check if all placeholders $0 are replaces */
- uri = shortcut_get_uri("_vimb5_ one two");
- g_assert_cmpstr(uri, ==, "double-zero:one%20two-one%20two");
- g_free(uri);
-}
-
-static void test_shortcut_default(void)
-{
- char *uri;
-
- /* call without shortcut identifier and if the last placeholder become the
- * none matched query words */
- uri = shortcut_get_uri("zero one two three");
- g_assert_cmpstr(uri, ==, "default:zero-two%20three");
- g_free(uri);
-}
-
-static void test_shortcut_keep_unmatched(void)
-{
- char *uri;
-
- /* don't remove non matched placeholders */
- uri = shortcut_get_uri("zero");
- g_assert_cmpstr(uri, ==, "default:zero-$2");
- g_free(uri);
-}
-
-static void test_shortcut_fullrange(void)
-{
- char *uri;
-
- /* check if all placeholders $0-$9 are replaced */
- uri = shortcut_get_uri("_vimb3_ zero one two three four five six seven eight nine");
- g_assert_cmpstr(uri, ==, "fullrange:zero-one-nine");
- g_free(uri);
-}
-
-static void test_shortcut_shell_param(void)
-{
- char *uri;
-
- /* double quotes */
- uri = shortcut_get_uri("_vimb6_ \"rail station\" city hall");
- g_assert_cmpstr(uri, ==, "shell:rail%20station-city%20hall");
- g_free(uri);
-
- /* single quotes */
- uri = shortcut_get_uri("_vimb6_ 'rail station' 'city hall'");
- g_assert_cmpstr(uri, ==, "shell:rail%20station-city%20hall");
- g_free(uri);
-
- /* ignore none matching quote errors */
- uri = shortcut_get_uri("_vimb6_ \"rail station\" \"city hall");
- g_assert_cmpstr(uri, ==, "shell:rail%20station-city%20hall");
- g_free(uri);
-
- /* don't fill up quoted param with unquoted stuff */
- uri = shortcut_get_uri("_vimb6_ \"param 1\" \"param 2\" ignored params");
- g_assert_cmpstr(uri, ==, "shell:param%201-param%202");
- g_free(uri);
-
- /* allo quotes within tha last parameter */
- uri = shortcut_get_uri("_vimb6_ param1 param2 \"containing quotes\"");
- g_assert_cmpstr(uri, ==, "shell:param1-param2%20%22containing%20quotes%22");
- g_free(uri);
-}
-
-static void test_shortcut_remove(void)
-{
- char *uri;
-
- g_assert_true(shortcut_remove("_vimb4_"));
-
- /* check if the shortcut is really no used */
- uri = shortcut_get_uri("_vimb4_ test");
- g_assert_cmpstr(uri, ==, "default:_vimb4_-$2");
-}
-
-int main(int argc, char *argv[])
-{
- int result;
- shortcut_init();
-
- g_assert_true(shortcut_add("_vimb1_", "only-zero:$0"));
- g_assert_true(shortcut_add("_vimb2_", "default:$0-$2"));
- g_assert_true(shortcut_add("_vimb3_", "fullrange:$0-$1-$9"));
- g_assert_true(shortcut_add("_vimb4_", "for-remove:$0"));
- g_assert_true(shortcut_add("_vimb5_", "double-zero:$0-$0"));
- g_assert_true(shortcut_add("_vimb6_", "shell:$0-$1"));
- g_assert_true(shortcut_set_default("_vimb2_"));
-
- g_test_init(&argc, &argv, NULL);
-
- g_test_add_func("/test-shortcut/get_uri/single", test_shortcut_single);
- g_test_add_func("/test-shortcut/get_uri/default", test_shortcut_default);
- g_test_add_func("/test-shortcut/get_uri/keep-unmatched", test_shortcut_keep_unmatched);
- g_test_add_func("/test-shortcut/get_uri/fullrange", test_shortcut_fullrange);
- g_test_add_func("/test-shortcut/get_uri/shell-param", test_shortcut_shell_param);
- g_test_add_func("/test-shortcut/remove", test_shortcut_remove);
-
- result = g_test_run();
-
- shortcut_cleanup();
-
- return result;
-}
diff --git a/tests/test-util.c b/tests/test-util.c
deleted file mode 100644
index 67b1954c..00000000
--- a/tests/test-util.c
+++ /dev/null
@@ -1,285 +0,0 @@
-/**
- * vimb - a webkit based vim like browser.
- *
- * Copyright (C) 2012-2015 Daniel Carl
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see http://www.gnu.org/licenses/.
- */
-
-#include
-#include
-
-extern VbCore vb;
-
-static void check_expand(const char *str, const char *expected)
-{
- char *result = util_expand(str, UTIL_EXP_DOLLAR|UTIL_EXP_TILDE|UTIL_EXP_SPECIAL);
- g_assert_cmpstr(result, ==, expected);
- g_free(result);
-}
-
-static void test_expand_evn(void)
-{
- /* set environment var for testing expansion */
- g_setenv("VIMB_VAR", "value", true);
-
- check_expand("$VIMB_VAR", "value");
- check_expand("$VIMB_VAR", "value");
- check_expand("$VIMB_VAR$VIMB_VAR", "valuevalue");
- check_expand("${VIMB_VAR}", "value");
- check_expand("my$VIMB_VAR", "myvalue");
- check_expand("'$VIMB_VAR'", "'value'");
- check_expand("${VIMB_VAR}s ", "values ");
-
- g_unsetenv("UNKNOWN");
-
- check_expand("$UNKNOWN", "");
- check_expand("${UNKNOWN}", "");
- check_expand("'$UNKNOWN'", "''");
-}
-
-static void test_expand_escaped(void)
-{
- g_setenv("VIMB_VAR", "value", true);
-
- check_expand("\\$VIMB_VAR", "$VIMB_VAR");
- check_expand("\\${VIMB_VAR}", "${VIMB_VAR}");
-
- check_expand("\\~/", "~/");
- check_expand("\\~/vimb", "~/vimb");
- check_expand("\\~root", "~root");
-
- check_expand("\\%", "%");
-
- check_expand("\\\\$VIMB_VAR", "\\value"); /* \\$VAR becomes \ExpandedVar */
- check_expand("\\\\\\$VIMB_VAR", "\\$VIMB_VAR"); /* \\\$VAR becomes \$VAR */
-}
-
-static void test_expand_tilde_home(void)
-{
- char *dir;
- const char *home = util_get_home_dir();
-
- check_expand("~", "~");
- check_expand("~/", home);
- check_expand("foo~/bar", "foo~/bar");
- check_expand("~/foo", (dir = g_strdup_printf("%s/foo", home)));
- g_free(dir);
-
- check_expand("foo ~/bar", (dir = g_strdup_printf("foo %s/bar", home)));
- g_free(dir);
-
- check_expand("~/~", (dir = g_strdup_printf("%s/~", home)));
- g_free(dir);
-
- check_expand("~/~/", (dir = g_strdup_printf("%s/~/", home)));
- g_free(dir);
-}
-
-static void test_expand_tilde_user(void)
-{
- const char *home = util_get_home_dir();
- const char *user = g_get_user_name();
- char *in, *out;
-
- /* don't expand within words */
- in = g_strdup_printf("foo~%s/bar", user);
- check_expand(in, in);
- g_free(in);
-
- check_expand((in = g_strdup_printf("foo ~%s", user)), (out = g_strdup_printf("foo %s", home)));
- g_free(in);
- g_free(out);
-
- check_expand((in = g_strdup_printf("~%s", user)), home);
- g_free(in);
-
- check_expand((in = g_strdup_printf("~%s/bar", user)), (out = g_strdup_printf("%s/bar", home)));
- g_free(in);
- g_free(out);
-}
-
-static void test_expand_speacial(void)
-{
- vb.state.uri = "http://fanglingsu.github.io/vimb/";
-
- check_expand("%", "http://fanglingsu.github.io/vimb/");
- check_expand("'%'", "'http://fanglingsu.github.io/vimb/'");
-}
-
-static void test_strcasestr(void)
-{
- g_assert_nonnull(util_strcasestr("Vim like Browser", "browser"));
- g_assert_nonnull(util_strcasestr("Vim like Browser", "vim LIKE"));
-}
-
-static void test_str_replace(void)
-{
- char *value;
-
- value = util_str_replace("a", "uu", "foo bar baz");
- g_assert_cmpstr(value, ==, "foo buur buuz");
- g_free(value);
-
- value = util_str_replace("$1", "placeholder", "string with $1");
- g_assert_cmpstr(value, ==, "string with placeholder");
- g_free(value);
-}
-
-static void test_wildmatch_simple(void)
-{
- g_assert_true(util_wildmatch("", ""));
- g_assert_true(util_wildmatch("w", "w"));
- g_assert_true(util_wildmatch(".", "."));
- g_assert_true(util_wildmatch("~", "~"));
- g_assert_true(util_wildmatch("wildmatch", "WildMatch"));
- g_assert_true(util_wildmatch("wild\\match", "wild\\match"));
-
- /* no special meaning of . and ~ in pattern */
- g_assert_false(util_wildmatch(".", "w"));
- g_assert_false(util_wildmatch("~", "w"));
- g_assert_false(util_wildmatch("wild", "wild "));
- g_assert_false(util_wildmatch("wild", " wild"));
- g_assert_false(util_wildmatch("wild", "\\ wild"));
- g_assert_false(util_wildmatch("wild", "\\wild"));
- g_assert_false(util_wildmatch("wild", "wild\\"));
- g_assert_false(util_wildmatch("wild\\1", "wild\\2"));
-}
-
-static void test_wildmatch_questionmark(void)
-{
- g_assert_true(util_wildmatch("wild?atch", "wildmatch"));
- g_assert_true(util_wildmatch("wild?atch", "wildBatch"));
- g_assert_true(util_wildmatch("wild?atch", "wild?atch"));
- g_assert_true(util_wildmatch("?ild?atch", "MildBatch"));
- g_assert_true(util_wildmatch("foo\\?bar", "foo?bar"));
- g_assert_true(util_wildmatch("???", "foo"));
- g_assert_true(util_wildmatch("???", "bar"));
-
- g_assert_false(util_wildmatch("foo\\?bar", "foorbar"));
- g_assert_false(util_wildmatch("?", ""));
- g_assert_false(util_wildmatch("b??r", "bar"));
- /* ? does not match / in contrast to * which does */
- g_assert_false(util_wildmatch("user?share", "user/share"));
-}
-
-static void test_wildmatch_wildcard(void)
-{
- g_assert_true(util_wildmatch("*", ""));
- g_assert_true(util_wildmatch("*", "Match as much as possible"));
- g_assert_true(util_wildmatch("*match", "prefix match"));
- g_assert_true(util_wildmatch("match*", "match suffix"));
- g_assert_true(util_wildmatch("match*", "match*"));
- g_assert_true(util_wildmatch("match\\*", "match*"));
- g_assert_true(util_wildmatch("match\\\\*", "match\\*"));
- g_assert_true(util_wildmatch("do * match", "do a infix match"));
- /* '*' matches also / in contrast to other implementations */
- g_assert_true(util_wildmatch("start*end", "start/something/end"));
- g_assert_true(util_wildmatch("*://*.io/*", "http://fanglingsu.github.io/vimb/"));
- /* multiple * should act like a single one */
- g_assert_true(util_wildmatch("**", ""));
- g_assert_true(util_wildmatch("match **", "Match as much as possible"));
- g_assert_true(util_wildmatch("f***u", "fu"));
-
- g_assert_false(util_wildmatch("match\\*", "match fail"));
- g_assert_false(util_wildmatch("f***u", "full"));
-}
-
-static void test_wildmatch_curlybraces(void)
-{
- g_assert_true(util_wildmatch("{foo}", "foo"));
- g_assert_true(util_wildmatch("{foo,bar}", "foo"));
- g_assert_true(util_wildmatch("{foo,bar}", "bar"));
- g_assert_true(util_wildmatch("foo{lish,t}bar", "foolishbar"));
- g_assert_true(util_wildmatch("foo{lish,t}bar", "footbar"));
- /* esacped special chars */
- g_assert_true(util_wildmatch("foo\\{l\\}bar", "foo{l}bar"));
- g_assert_true(util_wildmatch("ba{r,z\\{\\}}", "bar"));
- g_assert_true(util_wildmatch("ba{r,z\\{\\}}", "baz{}"));
- g_assert_true(util_wildmatch("test{one\\,two,three}", "testone,two"));
- g_assert_true(util_wildmatch("test{one\\,two,three}", "testthree"));
- /* backslash before none special char is a normal char */
- g_assert_true(util_wildmatch("back{\\slash,}", "back\\slash"));
- g_assert_true(util_wildmatch("one\\two", "one\\two"));
- g_assert_true(util_wildmatch("\\}match", "}match"));
- g_assert_true(util_wildmatch("\\{", "{"));
- /* empty list parts */
- g_assert_true(util_wildmatch("{}", ""));
- g_assert_true(util_wildmatch("{,}", ""));
- g_assert_true(util_wildmatch("{,foo}", ""));
- g_assert_true(util_wildmatch("{,foo}", "foo"));
- g_assert_true(util_wildmatch("{bar,}", ""));
- g_assert_true(util_wildmatch("{bar,}", "bar"));
- /* no special meaning of ? and * in curly braces */
- g_assert_true(util_wildmatch("ab{*,cd}ef", "ab*ef"));
- g_assert_true(util_wildmatch("ab{d,?}ef", "ab?ef"));
-
- g_assert_false(util_wildmatch("{foo,bar}", "foo,bar"));
- g_assert_false(util_wildmatch("}match{ it", "}match{ anything"));
- /* don't match single parts that are seperated by escaped ',' */
- g_assert_false(util_wildmatch("{a,b\\,c,d}", "b"));
- g_assert_false(util_wildmatch("{a,b\\,c,d}", "c"));
- /* lonesome braces - this is a syntax error and will always be false */
- g_assert_false(util_wildmatch("}", "}"));
- g_assert_false(util_wildmatch("}", ""));
- g_assert_false(util_wildmatch("}suffix", "}suffux"));
- g_assert_false(util_wildmatch("}suffix", "suffux"));
- g_assert_false(util_wildmatch("{", "{"));
- g_assert_false(util_wildmatch("{", ""));
- g_assert_false(util_wildmatch("{foo", "{foo"));
- g_assert_false(util_wildmatch("{foo", "foo"));
- g_assert_false(util_wildmatch("foo{bar", "foo{bar"));
-}
-
-static void test_wildmatch_complete(void)
-{
- g_assert_true(util_wildmatch("http{s,}://{fanglingsu.,}github.{io,com}/*vimb/", "http://fanglingsu.github.io/vimb/"));
- g_assert_true(util_wildmatch("http{s,}://{fanglingsu.,}github.{io,com}/*vimb/", "https://github.com/fanglingsu/vimb/"));
-}
-
-static void test_wildmatch_multi(void)
-{
- g_assert_true(util_wildmatch("foo,?", "foo"));
- g_assert_true(util_wildmatch("foo,?", "f"));
- g_assert_true(util_wildmatch("foo,b{a,o,}r,ba?", "foo"));
- g_assert_true(util_wildmatch("foo,b{a,o,}r,ba?", "bar"));
- g_assert_true(util_wildmatch("foo,b{a,o,}r,ba?", "bor"));
- g_assert_true(util_wildmatch("foo,b{a,o,}r,ba?", "br"));
- g_assert_true(util_wildmatch("foo,b{a,o,}r,ba?", "baz"));
- g_assert_true(util_wildmatch("foo,b{a,o,}r,ba?", "bat"));
-
- g_assert_false(util_wildmatch("foo,b{a,o,}r,ba?", "foo,"));
- g_assert_false(util_wildmatch("foo,?", "fo"));
-}
-
-int main(int argc, char *argv[])
-{
- g_test_init(&argc, &argv, NULL);
-
- g_test_add_func("/test-util/expand-env", test_expand_evn);
- g_test_add_func("/test-util/expand-escaped", test_expand_escaped);
- g_test_add_func("/test-util/expand-tilde-home", test_expand_tilde_home);
- g_test_add_func("/test-util/expand-tilde-user", test_expand_tilde_user);
- g_test_add_func("/test-util/expand-spacial", test_expand_speacial);
- g_test_add_func("/test-util/strcasestr", test_strcasestr);
- g_test_add_func("/test-util/str_replace", test_str_replace);
- g_test_add_func("/test-util/wildmatch-simple", test_wildmatch_simple);
- g_test_add_func("/test-util/wildmatch-questionmark", test_wildmatch_questionmark);
- g_test_add_func("/test-util/wildmatch-wildcard", test_wildmatch_wildcard);
- g_test_add_func("/test-util/wildmatch-curlybraces", test_wildmatch_curlybraces);
- g_test_add_func("/test-util/wildmatch-complete", test_wildmatch_complete);
- g_test_add_func("/test-util/wildmatch-multi", test_wildmatch_multi);
-
- return g_test_run();
-}
From 7edb3dfebc4e83fd1d01cb4b7284cf93f12cf163 Mon Sep 17 00:00:00 2001
From: Daniel Carl
Date: Fri, 15 Apr 2016 23:54:39 +0200
Subject: [PATCH 002/201] Fix none applied status style.
---
src/config.def.h | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/config.def.h b/src/config.def.h
index da33cc76..9aecde07 100644
--- a/src/config.def.h
+++ b/src/config.def.h
@@ -37,9 +37,9 @@
/* number of chars to be shown in statusbar for ambiguous commands */
#define SHOWCMD_LEN 10
/* css applied to the gui elements of the borwser window */
-#define GUI_STYLE "GtkBox#statusbar{color:#fff;background-color:#000;font:monospace bold 10;} \
-GtkBox#statusbar.secure{background-color:#95e454;color:#000;} \
-GtkBox#statusbar.insecure{background-color:#f77;color:#000;} \
+#define GUI_STYLE "#statusbar{color:#fff;background-color:#000;font:monospace bold 10;} \
+#statusbar.secure{background-color:#95e454;color:#000;} \
+#statusbar.insecure{background-color:#f77;color:#000;} \
GtkTextView{background-color:#fff;color:#000;font:monospace 10;} \
GtkTextView.error{background-color:#f77;font-weight:bold;} \
GtkTreeView{color:#fff;background-color:#656565;font:monospace;} \
From 0938b3fd432c2320d143b14be1bf54457f94d5f5 Mon Sep 17 00:00:00 2001
From: Daniel Carl
Date: Wed, 1 Jun 2016 23:00:01 +0200
Subject: [PATCH 003/201] Update license year.
---
src/ascii.h | 2 +-
src/command.c | 2 +-
src/command.h | 2 +-
src/completion.c | 2 +-
src/completion.h | 2 +-
src/config.def.h | 2 +-
src/ex.c | 2 +-
src/ex.h | 2 +-
src/ext-proxy.c | 2 +-
src/ext-proxy.h | 2 +-
src/history.c | 2 +-
src/history.h | 2 +-
src/input.c | 2 +-
src/input.h | 2 +-
src/js.c | 2 +-
src/js.h | 2 +-
src/main.c | 2 +-
src/main.h | 2 +-
src/map.c | 2 +-
src/map.h | 2 +-
src/normal.c | 2 +-
src/normal.h | 2 +-
src/setting.c | 2 +-
src/setting.h | 2 +-
src/shortcut.c | 2 +-
src/shortcut.h | 2 +-
src/util.c | 2 +-
src/util.h | 2 +-
src/webextension/ext-dom.c | 2 +-
src/webextension/ext-dom.h | 2 +-
src/webextension/ext-main.c | 2 +-
src/webextension/ext-main.h | 2 +-
src/webextension/ext-util.c | 2 +-
src/webextension/ext-util.h | 2 +-
34 files changed, 34 insertions(+), 34 deletions(-)
diff --git a/src/ascii.h b/src/ascii.h
index f375a302..d85ef688 100644
--- a/src/ascii.h
+++ b/src/ascii.h
@@ -1,7 +1,7 @@
/**
* vimb - a webkit based vim like browser.
*
- * Copyright (C) 2012-2015 Daniel Carl
+ * Copyright (C) 2012-2016 Daniel Carl
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/command.c b/src/command.c
index c957c463..09ab5ef9 100644
--- a/src/command.c
+++ b/src/command.c
@@ -1,7 +1,7 @@
/**
* vimb - a webkit based vim like browser.
*
- * Copyright (C) 2012-2015 Daniel Carl
+ * Copyright (C) 2012-2016 Daniel Carl
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/command.h b/src/command.h
index 92cf4941..ba2ba46b 100644
--- a/src/command.h
+++ b/src/command.h
@@ -1,7 +1,7 @@
/**
* vimb - a webkit based vim like browser.
*
- * Copyright (C) 2012-2015 Daniel Carl
+ * Copyright (C) 2012-2016 Daniel Carl
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/completion.c b/src/completion.c
index 8bfb9b03..714ddcf8 100644
--- a/src/completion.c
+++ b/src/completion.c
@@ -1,7 +1,7 @@
/**
* vimb - a webkit based vim like browser.
*
- * Copyright (C) 2012-2015 Daniel Carl
+ * Copyright (C) 2012-2016 Daniel Carl
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/completion.h b/src/completion.h
index e353ecba..8c8d2286 100644
--- a/src/completion.h
+++ b/src/completion.h
@@ -1,7 +1,7 @@
/**
* vimb - a webkit based vim like browser.
*
- * Copyright (C) 2012-2015 Daniel Carl
+ * Copyright (C) 2012-2016 Daniel Carl
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/config.def.h b/src/config.def.h
index 9aecde07..fdcb23a1 100644
--- a/src/config.def.h
+++ b/src/config.def.h
@@ -1,7 +1,7 @@
/**
* vimb - a webkit based vim like browser.
*
- * Copyright (C) 2012-2015 Daniel Carl
+ * Copyright (C) 2012-2016 Daniel Carl
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/ex.c b/src/ex.c
index 914a5549..2d0f2e46 100644
--- a/src/ex.c
+++ b/src/ex.c
@@ -1,7 +1,7 @@
/**
* vimb - a webkit based vim like browser.
*
- * Copyright (C) 2012-2015 Daniel Carl
+ * Copyright (C) 2012-2016 Daniel Carl
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/ex.h b/src/ex.h
index 1173d90a..ec0960d3 100644
--- a/src/ex.h
+++ b/src/ex.h
@@ -1,7 +1,7 @@
/**
* vimb - a webkit based vim like browser.
*
- * Copyright (C) 2012-2015 Daniel Carl
+ * Copyright (C) 2012-2016 Daniel Carl
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/ext-proxy.c b/src/ext-proxy.c
index 75ccbd77..0fe07b8c 100644
--- a/src/ext-proxy.c
+++ b/src/ext-proxy.c
@@ -1,7 +1,7 @@
/**
* vimb - a webkit based vim like browser.
*
- * Copyright (C) 2012-2015 Daniel Carl
+ * Copyright (C) 2012-2016 Daniel Carl
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/ext-proxy.h b/src/ext-proxy.h
index b5b33a16..3d6ae141 100644
--- a/src/ext-proxy.h
+++ b/src/ext-proxy.h
@@ -1,7 +1,7 @@
/**
* vimb - a webkit based vim like browser.
*
- * Copyright (C) 2012-2015 Daniel Carl
+ * Copyright (C) 2012-2016 Daniel Carl
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/history.c b/src/history.c
index fcd89fce..b2bb1d47 100644
--- a/src/history.c
+++ b/src/history.c
@@ -1,7 +1,7 @@
/**
* vimb - a webkit based vim like browser.
*
- * Copyright (C) 2012-2015 Daniel Carl
+ * Copyright (C) 2012-2016 Daniel Carl
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/history.h b/src/history.h
index 8709f5d6..c074d062 100644
--- a/src/history.h
+++ b/src/history.h
@@ -1,7 +1,7 @@
/**
* vimb - a webkit based vim like browser.
*
- * Copyright (C) 2012-2015 Daniel Carl
+ * Copyright (C) 2012-2016 Daniel Carl
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/input.c b/src/input.c
index b5381ffd..afa93606 100644
--- a/src/input.c
+++ b/src/input.c
@@ -1,7 +1,7 @@
/**
* vimb - a webkit based vim like browser.
*
- * Copyright (C) 2012-2015 Daniel Carl
+ * Copyright (C) 2012-2016 Daniel Carl
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/input.h b/src/input.h
index 64d1d5c1..29a07995 100644
--- a/src/input.h
+++ b/src/input.h
@@ -1,7 +1,7 @@
/**
* vimb - a webkit based vim like browser.
*
- * Copyright (C) 2012-2015 Daniel Carl
+ * Copyright (C) 2012-2016 Daniel Carl
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/js.c b/src/js.c
index e6f467ef..a65c41c2 100644
--- a/src/js.c
+++ b/src/js.c
@@ -1,7 +1,7 @@
/**
* vimb - a webkit based vim like browser.
*
- * Copyright (C) 2012-2015 Daniel Carl
+ * Copyright (C) 2012-2016 Daniel Carl
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/js.h b/src/js.h
index 1a63d0a3..fd6158b5 100644
--- a/src/js.h
+++ b/src/js.h
@@ -1,7 +1,7 @@
/**
* vimb - a webkit based vim like browser.
*
- * Copyright (C) 2012-2015 Daniel Carl
+ * Copyright (C) 2012-2016 Daniel Carl
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/main.c b/src/main.c
index a8c9f74d..a91cde3f 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1,7 +1,7 @@
/**
* vimb - a webkit based vim like browser.
*
- * Copyright (C) 2012-2015 Daniel Carl
+ * Copyright (C) 2012-2016 Daniel Carl
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/main.h b/src/main.h
index f0816d04..2db4696e 100644
--- a/src/main.h
+++ b/src/main.h
@@ -1,7 +1,7 @@
/**
* vimb - a webkit based vim like browser.
*
- * Copyright (C) 2012-2015 Daniel Carl
+ * Copyright (C) 2012-2016 Daniel Carl
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/map.c b/src/map.c
index 5b4017a9..d5b1768b 100644
--- a/src/map.c
+++ b/src/map.c
@@ -1,7 +1,7 @@
/**
* vimb - a webkit based vim like browser.
*
- * Copyright (C) 2012-2015 Daniel Carl
+ * Copyright (C) 2012-2016 Daniel Carl
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/map.h b/src/map.h
index 4d5308ad..d97d1b42 100644
--- a/src/map.h
+++ b/src/map.h
@@ -1,7 +1,7 @@
/**
* vimb - a webkit based vim like browser.
*
- * Copyright (C) 2012-2015 Daniel Carl
+ * Copyright (C) 2012-2016 Daniel Carl
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/normal.c b/src/normal.c
index 2980ecf5..3398488d 100644
--- a/src/normal.c
+++ b/src/normal.c
@@ -1,7 +1,7 @@
/**
* vimb - a webkit based vim like browser.
*
- * Copyright (C) 2012-2015 Daniel Carl
+ * Copyright (C) 2012-2016 Daniel Carl
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/normal.h b/src/normal.h
index e4f626c8..912d2c64 100644
--- a/src/normal.h
+++ b/src/normal.h
@@ -1,7 +1,7 @@
/**
* vimb - a webkit based vim like browser.
*
- * Copyright (C) 2012-2015 Daniel Carl
+ * Copyright (C) 2012-2016 Daniel Carl
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/setting.c b/src/setting.c
index 79d3ebb3..a3ad8a69 100644
--- a/src/setting.c
+++ b/src/setting.c
@@ -1,7 +1,7 @@
/**
* vimb - a webkit based vim like browser.
*
- * Copyright (C) 2012-2015 Daniel Carl
+ * Copyright (C) 2012-2016 Daniel Carl
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/setting.h b/src/setting.h
index cd1d8d50..93f7182c 100644
--- a/src/setting.h
+++ b/src/setting.h
@@ -1,7 +1,7 @@
/**
* vimb - a webkit based vim like browser.
*
- * Copyright (C) 2012-2015 Daniel Carl
+ * Copyright (C) 2012-2016 Daniel Carl
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/shortcut.c b/src/shortcut.c
index 0663b9f8..7545037e 100644
--- a/src/shortcut.c
+++ b/src/shortcut.c
@@ -1,7 +1,7 @@
/**
* vimb - a webkit based vim like browser.
*
- * Copyright (C) 2012-2015 Daniel Carl
+ * Copyright (C) 2012-2016 Daniel Carl
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/shortcut.h b/src/shortcut.h
index f932abf1..9b44e29f 100644
--- a/src/shortcut.h
+++ b/src/shortcut.h
@@ -1,7 +1,7 @@
/**
* vimb - a webkit based vim like browser.
*
- * Copyright (C) 2012-2015 Daniel Carl
+ * Copyright (C) 2012-2016 Daniel Carl
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/util.c b/src/util.c
index 9670b848..be48e711 100644
--- a/src/util.c
+++ b/src/util.c
@@ -1,7 +1,7 @@
/**
* vimb - a webkit based vim like browser.
*
- * Copyright (C) 2012-2015 Daniel Carl
+ * Copyright (C) 2012-2016 Daniel Carl
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/util.h b/src/util.h
index c09b0987..94a60ca7 100644
--- a/src/util.h
+++ b/src/util.h
@@ -1,7 +1,7 @@
/**
* vimb - a webkit based vim like browser.
*
- * Copyright (C) 2012-2015 Daniel Carl
+ * Copyright (C) 2012-2016 Daniel Carl
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/webextension/ext-dom.c b/src/webextension/ext-dom.c
index 26aeaf0f..911e4e36 100644
--- a/src/webextension/ext-dom.c
+++ b/src/webextension/ext-dom.c
@@ -1,7 +1,7 @@
/**
* vimb - a webkit based vim like browser.
*
- * Copyright (C) 2012-2015 Daniel Carl
+ * Copyright (C) 2012-2016 Daniel Carl
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/webextension/ext-dom.h b/src/webextension/ext-dom.h
index 657821d0..795754c4 100644
--- a/src/webextension/ext-dom.h
+++ b/src/webextension/ext-dom.h
@@ -1,7 +1,7 @@
/**
* vimb - a webkit based vim like browser.
*
- * Copyright (C) 2012-2015 Daniel Carl
+ * Copyright (C) 2012-2016 Daniel Carl
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/webextension/ext-main.c b/src/webextension/ext-main.c
index 669fd7db..a3a8a838 100644
--- a/src/webextension/ext-main.c
+++ b/src/webextension/ext-main.c
@@ -1,7 +1,7 @@
/**
* vimb - a webkit based vim like browser.
*
- * Copyright (C) 2012-2015 Daniel Carl
+ * Copyright (C) 2012-2016 Daniel Carl
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/webextension/ext-main.h b/src/webextension/ext-main.h
index 61788004..ff3f0a30 100644
--- a/src/webextension/ext-main.h
+++ b/src/webextension/ext-main.h
@@ -1,7 +1,7 @@
/**
* vimb - a webkit based vim like browser.
*
- * Copyright (C) 2012-2015 Daniel Carl
+ * Copyright (C) 2012-2016 Daniel Carl
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/webextension/ext-util.c b/src/webextension/ext-util.c
index 0bb40e41..f63cb11b 100644
--- a/src/webextension/ext-util.c
+++ b/src/webextension/ext-util.c
@@ -1,7 +1,7 @@
/**
* vimb - a webkit based vim like browser.
*
- * Copyright (C) 2012-2015 Daniel Carl
+ * Copyright (C) 2012-2016 Daniel Carl
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/webextension/ext-util.h b/src/webextension/ext-util.h
index 452c4276..a4286a5a 100644
--- a/src/webextension/ext-util.h
+++ b/src/webextension/ext-util.h
@@ -1,7 +1,7 @@
/**
* vimb - a webkit based vim like browser.
*
- * Copyright (C) 2012-2015 Daniel Carl
+ * Copyright (C) 2012-2016 Daniel Carl
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
From 2d5a6a36d81a25798f50f6e03395d90c94b4fac2 Mon Sep 17 00:00:00 2001
From: Daniel Carl
Date: Thu, 16 Jun 2016 22:46:51 +0200
Subject: [PATCH 004/201] Prepare the style provider only once.
Added names for the main styled gui elements for easier styling via css.
---
src/completion.c | 5 ++---
src/main.c | 11 +++++++----
src/main.h | 1 +
3 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/src/completion.c b/src/completion.c
index 714ddcf8..8bda61f0 100644
--- a/src/completion.c
+++ b/src/completion.c
@@ -98,11 +98,10 @@ gboolean completion_create(Client *c, GtkTreeModel *model,
comp->win = gtk_scrolled_window_new(NULL, NULL);
comp->tree = gtk_tree_view_new();
- GtkCssProvider* provider = gtk_css_provider_get_default();
- gtk_css_provider_load_from_data(provider, GUI_STYLE, -1, NULL);
gtk_style_context_add_provider(gtk_widget_get_style_context(comp->tree),
- GTK_STYLE_PROVIDER(provider),
+ GTK_STYLE_PROVIDER(vb.style_provider),
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+ gtk_widget_set_name(GTK_WIDGET(comp->tree), "completion");
gtk_box_pack_end(GTK_BOX(gtk_widget_get_parent(GTK_WIDGET(c->statusbar.box))), comp->win, FALSE, FALSE, 0);
gtk_container_add(GTK_CONTAINER(comp->win), comp->tree);
diff --git a/src/main.c b/src/main.c
index a91cde3f..982ec7cf 100644
--- a/src/main.c
+++ b/src/main.c
@@ -559,13 +559,11 @@ static Client *client_new(WebKitWebView *webview)
gtk_box_pack_end(GTK_BOX(box), GTK_WIDGET(c->input), FALSE, FALSE, 0);
/* Set the default style for statusbar and inputbox. */
- GtkCssProvider* provider = gtk_css_provider_get_default();
- gtk_css_provider_load_from_data(provider, GUI_STYLE, -1, NULL);
gtk_style_context_add_provider(gtk_widget_get_style_context(GTK_WIDGET(c->statusbar.box)),
- GTK_STYLE_PROVIDER(provider),
+ GTK_STYLE_PROVIDER(vb.style_provider),
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
gtk_style_context_add_provider(gtk_widget_get_style_context(c->input),
- GTK_STYLE_PROVIDER(provider),
+ GTK_STYLE_PROVIDER(vb.style_provider),
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
/* set the x window id to env */
@@ -1075,6 +1073,7 @@ static void vimb_setup(void)
* the documentation. */
ctx = webkit_web_context_get_default();
webkit_web_context_set_process_model(ctx, WEBKIT_PROCESS_MODEL_MULTIPLE_SECONDARY_PROCESSES);
+ webkit_web_context_set_web_process_count_limit(ctx, 1);
webkit_web_context_set_cache_model(ctx, WEBKIT_CACHE_MODEL_WEB_BROWSER);
g_signal_connect(ctx, "initialize-web-extensions", G_CALLBACK(on_webctx_init_web_extension), NULL);
@@ -1096,6 +1095,10 @@ static void vimb_setup(void)
vb_mode_add('c', ex_enter, ex_leave, ex_keypress, ex_input_changed);
vb_mode_add('i', input_enter, input_leave, input_keypress, NULL);
vb_mode_add('p', pass_enter, pass_leave, pass_keypress, NULL);
+
+ /* Prepare the style provider to be used for the clients and completion. */
+ vb.style_provider = gtk_css_provider_get_default();
+ gtk_css_provider_load_from_data(vb.style_provider, GUI_STYLE, -1, NULL);
}
/**
diff --git a/src/main.h b/src/main.h
index 2db4696e..b4af03e8 100644
--- a/src/main.h
+++ b/src/main.h
@@ -255,6 +255,7 @@ struct Vimb {
struct {
guint history_max;
} config;
+ GtkCssProvider *style_provider;
};
From a9b302273d0d519c1b5a1dd6d1ff732ef08e7d83 Mon Sep 17 00:00:00 2001
From: Daniel Carl
Date: Thu, 16 Jun 2016 23:19:41 +0200
Subject: [PATCH 005/201] Adapted default gui style to new naming of widgets.
---
src/config.def.h | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/src/config.def.h b/src/config.def.h
index fdcb23a1..3f85383b 100644
--- a/src/config.def.h
+++ b/src/config.def.h
@@ -37,14 +37,15 @@
/* number of chars to be shown in statusbar for ambiguous commands */
#define SHOWCMD_LEN 10
/* css applied to the gui elements of the borwser window */
-#define GUI_STYLE "#statusbar{color:#fff;background-color:#000;font:monospace bold 10;} \
+#define GUI_STYLE "\
+#statusbar{color:#fff;background-color:#000;font:monospace bold 10;} \
#statusbar.secure{background-color:#95e454;color:#000;} \
#statusbar.insecure{background-color:#f77;color:#000;} \
-GtkTextView{background-color:#fff;color:#000;font:monospace 10;} \
-GtkTextView.error{background-color:#f77;font-weight:bold;} \
-GtkTreeView{color:#fff;background-color:#656565;font:monospace;} \
-GtkTreeView:hover{background-color:#777;} \
-GtkTreeView:selected{color:#f6f3e8;background-color:#888;}"
+#input{background-color:#fff;color:#000;font:monospace 10;} \
+#input.error{background-color:#f77;font-weight:bold;} \
+#completion{color:#fff;background-color:#656565;font:monospace 10;} \
+#completion:hover{background-color:#777;} \
+#completion:selected{color:#f6f3e8;background-color:#888;}"
/* default font size for fonts in webview */
#define SETTING_DEFAULT_FONT_SIZE 10
From 6ac60d8e8eae8a5e1b7b2d64b01732a0b63832b2 Mon Sep 17 00:00:00 2001
From: Daniel Carl
Date: Thu, 16 Jun 2016 23:48:55 +0200
Subject: [PATCH 006/201] Show progress in window title.
---
src/config.def.h | 9 ++++++---
src/main.c | 26 +++++++++++++++++++++++++-
src/main.h | 1 +
3 files changed, 32 insertions(+), 4 deletions(-)
diff --git a/src/config.def.h b/src/config.def.h
index 3f85383b..cc3b915c 100644
--- a/src/config.def.h
+++ b/src/config.def.h
@@ -22,13 +22,16 @@
#define FEATURE_HISTORY_INDICATOR
/* show wget style progressbar in status bar */
#define FEATURE_WGET_PROGRESS_BAR
+/* show load progress in window title */
+#define FEATURE_TITLE_PROGRESS
+/* show page title in url completions */
+#define FEATURE_TITLE_IN_COMPLETION
+
#ifdef FEATURE_WGET_PROGRESS_BAR
/* chars to use for the progressbar */
-#define PROGRESS_BAR "=> "
+#define PROGRESS_BAR "=> "
#define PROGRESS_BAR_LEN 20
#endif
-/* show page title in url completions */
-#define FEATURE_TITLE_IN_COMPLETION
/* time in seconds after that message will be removed from inputbox if the
* message where only temporary */
diff --git a/src/main.c b/src/main.c
index 982ec7cf..39d87700 100644
--- a/src/main.c
+++ b/src/main.c
@@ -70,6 +70,7 @@ static gboolean on_webview_web_process_crashed(WebKitWebView *webview, Client *c
static void on_window_destroy(GtkWidget *window, Client *c);
static gboolean quit(Client *c);
static void register_cleanup(Client *c);
+static void update_title(Client *c);
static void update_urlbar(Client *c);
static void set_statusbar_style(Client *c, StatusType type);
static void set_title(Client *c, const char *title);
@@ -683,7 +684,9 @@ static void set_statusbar_style(Client *c, StatusType type)
*/
static void set_title(Client *c, const char *title)
{
- gtk_window_set_title(GTK_WINDOW(c->window), title);
+ OVERWRITE_STRING(c->state.title, title);
+ update_title(c);
+ g_setenv("VIMB_TITLE", title ? title : "", true);
}
/**
@@ -909,6 +912,7 @@ static void on_webview_notify_estimated_load_progress(WebKitWebView *webview,
{
c->state.progress = webkit_web_view_get_estimated_load_progress(webview) * 100;
vb_statusbar_update(c);
+ update_title(c);
}
/**
@@ -983,6 +987,26 @@ static void register_cleanup(Client *c)
}
}
+static void update_title(Client *c)
+{
+#ifdef FEATURE_TITLE_PROGRESS
+ /* Show load status of page or the downloads. */
+ if (c->state.progress != 100) {
+ char *title = g_strdup_printf(
+ "[%i%%] %s",
+ c->state.progress,
+ c->state.title ? c->state.title : "");
+ gtk_window_set_title(GTK_WINDOW(c->window), title);
+ g_free(title);
+
+ return;
+ }
+#endif
+ if (c->state.title) {
+ gtk_window_set_title(GTK_WINDOW(c->window), c->state.title);
+ }
+}
+
/**
* Update the contents of the url bar on the left of the statu bar according
* to current opened url and position in back forward history.
diff --git a/src/main.h b/src/main.h
index b4af03e8..6e91291e 100644
--- a/src/main.h
+++ b/src/main.h
@@ -162,6 +162,7 @@ struct State {
StatusType status_type;
glong scroll_max; /* Maxmimum scrollable height of the document. */
guint scroll_percent; /* Current position of the viewport in document. */
+ char *title; /* Window title of the client. */
char *reg[REG_SIZE]; /* holds the yank buffers */
/* TODO rename to reg_{enabled,current} */
From f85e43d06957e517bbae0e62fd0e9486d6246b66 Mon Sep 17 00:00:00 2001
From: Daniel Carl
Date: Fri, 17 Jun 2016 00:00:46 +0200
Subject: [PATCH 007/201] Don't use deprecated node list api.
---
src/webextension/ext-dom.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/src/webextension/ext-dom.c b/src/webextension/ext-dom.c
index 911e4e36..7c0b7cd6 100644
--- a/src/webextension/ext-dom.c
+++ b/src/webextension/ext-dom.c
@@ -83,19 +83,19 @@ gboolean ext_dom_is_editable(WebKitDOMElement *element)
gboolean ext_dom_focus_input(WebKitDOMDocument *doc)
{
WebKitDOMNode *html, *node;
- WebKitDOMNodeList *list;
+ WebKitDOMHTMLCollection *collection;
WebKitDOMXPathNSResolver *resolver;
WebKitDOMXPathResult* result;
WebKitDOMDocument *frame_doc;
guint i, len;
- list = webkit_dom_document_get_elements_by_tag_name(doc, "html");
- if (!list) {
+ collection = webkit_dom_document_get_elements_by_tag_name_as_html_collection(doc, "html");
+ if (!collection) {
return FALSE;
}
- html = webkit_dom_node_list_item(list, 0);
- g_object_unref(list);
+ html = webkit_dom_html_collection_item(collection, 0);
+ g_object_unref(collection);
resolver = webkit_dom_document_create_ns_resolver(doc, html);
if (!resolver) {
@@ -134,19 +134,19 @@ gboolean ext_dom_focus_input(WebKitDOMDocument *doc)
}
/* Look for editable elements in frames too. */
- list = webkit_dom_document_get_elements_by_tag_name(doc, "iframe");
- len = webkit_dom_node_list_get_length(list);
+ collection = webkit_dom_document_get_elements_by_tag_name_as_html_collection(doc, "iframe");
+ len = webkit_dom_html_collection_get_length(collection);
for (i = 0; i < len; i++) {
- node = webkit_dom_node_list_item(list, i);
+ node = webkit_dom_html_collection_item(collection, i);
frame_doc = webkit_dom_html_iframe_element_get_content_document(WEBKIT_DOM_HTML_IFRAME_ELEMENT(node));
/* Stop on first frame with focused element. */
if (ext_dom_focus_input(frame_doc)) {
- g_object_unref(list);
+ g_object_unref(collection);
return TRUE;
}
}
- g_object_unref(list);
+ g_object_unref(collection);
return FALSE;
}
From 90afd399fd58f2084fd8c74dcc7de7511f46b02f Mon Sep 17 00:00:00 2001
From: Daniel Carl
Date: Mon, 20 Jun 2016 22:11:17 +0200
Subject: [PATCH 008/201] Enable registers to continue a search.
---
src/main.c | 2 ++
src/main.h | 1 -
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/main.c b/src/main.c
index 39d87700..bc1496ed 100644
--- a/src/main.c
+++ b/src/main.c
@@ -577,6 +577,8 @@ static Client *client_new(WebKitWebView *webview)
/* start client in normal mode */
vb_enter(c, 'n');
+ c->state.enable_register = TRUE;
+
gtk_widget_show_all(c->window);
/* Prepend the new client to the queue of clients. */
diff --git a/src/main.h b/src/main.h
index 6e91291e..c1e925eb 100644
--- a/src/main.h
+++ b/src/main.h
@@ -187,7 +187,6 @@ struct Map {
int mappedlen; /* length of the mapped keys string */
char mode; /* mode for which the map is available */
gboolean remap; /* if FALSE do not remap the {rhs} of this map */
- gboolean enable_register; /* indicates if registers are filled */
};
struct Mode {
From 2dc1b9df59d9d9cb78869637ec4ba017fcae6d35 Mon Sep 17 00:00:00 2001
From: Daniel Carl
Date: Mon, 20 Jun 2016 22:15:22 +0200
Subject: [PATCH 009/201] Mark search as done.
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index b2e03318..126946fd 100644
--- a/README.md
+++ b/README.md
@@ -67,7 +67,7 @@ project directory.
- [ ] editor command
- [ ] external downloader
- [ ] hinting
- - [ ] searching and matching of search results
+ - [x] searching and matching of search results
- [ ] navigation j, k, h, l, ...
- [ ] history and history lookup
- [ ] completion
From fcedbe1fea08239650db9c151cac5022bbaa3782 Mon Sep 17 00:00:00 2001
From: Daniel Carl
Date: Wed, 29 Jun 2016 23:26:26 +0200
Subject: [PATCH 010/201] Found a nice way to disable scrollbars.
---
README.md | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 126946fd..42beb577 100644
--- a/README.md
+++ b/README.md
@@ -78,7 +78,9 @@ project directory.
- [ ] read it later queue
- [ ] show scroll indicator in statusbar as top, x%, bttom or all
how can we get this information from webview easily?
- - [ ] find a way to disable the scrollbars on the main frame
+ - [x] find a way to disable the scrollbars on the main frame
+ Can be achieved by `document.documentElement.style.overflow =
+ 'hidden';` in _scripts.js_
- [ ] page marks - maybe we change make them global (shared between
instances and to work also if the page was reloaded or changed like
the marks in vim)
From a2642b38586c7e530b8beaf9aac0594c1c8751c8 Mon Sep 17 00:00:00 2001
From: Daniel Carl
Date: Wed, 29 Jun 2016 23:49:12 +0200
Subject: [PATCH 011/201] Allow to set config file per option --config, -c.
---
README.md | 2 +-
src/ex.c | 83 +++++++++++++++++++++++++++++++++++++-----------------
src/ex.h | 1 +
src/main.c | 3 ++
4 files changed, 62 insertions(+), 27 deletions(-)
diff --git a/README.md b/README.md
index 42beb577..c80bd9a2 100644
--- a/README.md
+++ b/README.md
@@ -54,7 +54,7 @@ project directory.
- [x] establish communication channel between the vimb instance and the now
required webextension (dbus)
2. migrate as many of the features of the webkit1 vimb
- - [ ] starting with custom config file `--config,-c` option
+ - [x] starting with custom config file `--config,-c` option
- [ ] running multiple ex-commands during startup `--cmd,-C` options
- [ ] starting with a named profile `--profile,-p` option
- [ ] xembed `--embed,-e` option
diff --git a/src/ex.c b/src/ex.c
index 2d0f2e46..e3a5a712 100644
--- a/src/ex.c
+++ b/src/ex.c
@@ -408,6 +408,63 @@ gboolean ex_fill_completion(GtkListStore *store, const char *input)
return found;
}
+/**
+ * Run all ex commands from a file.
+ */
+VbCmdResult ex_run_file(Client *c, const char *filename)
+{
+ int length, i;
+ char *line, **lines;
+ VbCmdResult res = CMD_SUCCESS;
+
+ lines = util_get_lines(filename);
+ if (!lines) {
+ return res;
+ }
+
+ length = g_strv_length(lines) - 1;
+ for (i = 0; i < length; i++) {
+ line = lines[i];
+ /* skip commented or empty lines */
+ if (*line == '#' || !*line) {
+ continue;
+ }
+ if ((ex_run_string(c, line, false) & ~CMD_KEEPINPUT) == CMD_ERROR) {
+ res = CMD_ERROR | CMD_KEEPINPUT;
+ g_warning("Invalid command in %s: '%s'", filename, line);
+ }
+ }
+ g_strfreev(lines);
+
+ return res;
+}
+
+VbCmdResult ex_run_string(Client *c, const char *input, gboolean enable_history)
+{
+ /* copy to have original command for history */
+ const char *in = input;
+ gboolean nohist = FALSE;
+ VbCmdResult res = CMD_ERROR | CMD_KEEPINPUT;
+ ExArg *arg = g_slice_new0(ExArg);
+ arg->lhs = g_string_new("");
+ arg->rhs = g_string_new("");
+
+ while (in && *in) {
+ if (!parse(c, &in, arg, &nohist) || !(res = execute(c, arg))) {
+ break;
+ }
+ }
+
+ if (enable_history && !nohist) {
+ history_add(c, HISTORY_COMMAND, input, NULL);
+ vb_register_add(c, ':', input);
+ }
+
+ free_cmdarg(arg);
+
+ return res;
+}
+
/**
* This is called if the user typed or into the inputbox.
*/
@@ -446,32 +503,6 @@ static void input_activate(Client *c)
g_free(text);
}
-VbCmdResult ex_run_string(Client *c, const char *input, gboolean enable_history)
-{
- /* copy to have original command for history */
- const char *in = input;
- gboolean nohist = FALSE;
- VbCmdResult res = CMD_ERROR | CMD_KEEPINPUT;
- ExArg *arg = g_slice_new0(ExArg);
- arg->lhs = g_string_new("");
- arg->rhs = g_string_new("");
-
- while (in && *in) {
- if (!parse(c, &in, arg, &nohist) || !(res = execute(c, arg))) {
- break;
- }
- }
-
- if (enable_history && !nohist) {
- history_add(c, HISTORY_COMMAND, input, NULL);
- vb_register_add(c, ':', input);
- }
-
- free_cmdarg(arg);
-
- return res;
-}
-
/**
* Parses given input string into given ExArg pointer.
*/
diff --git a/src/ex.h b/src/ex.h
index ec0960d3..1fd057f2 100644
--- a/src/ex.h
+++ b/src/ex.h
@@ -28,6 +28,7 @@ void ex_leave(Client *c);
VbResult ex_keypress(Client *c, int key);
void ex_input_changed(Client *c, const char *text);
gboolean ex_fill_completion(GtkListStore *store, const char *input);
+VbCmdResult ex_run_file(Client *c, const char *filename);
VbCmdResult ex_run_string(Client *c, const char *input, gboolean enable_history);
#endif /* end of include guard: _EX_H */
diff --git a/src/main.c b/src/main.c
index bc1496ed..8644123a 100644
--- a/src/main.c
+++ b/src/main.c
@@ -581,6 +581,9 @@ static Client *client_new(WebKitWebView *webview)
gtk_widget_show_all(c->window);
+ /* read the config file */
+ ex_run_file(c, vb.files[FILES_CONFIG]);
+
/* Prepend the new client to the queue of clients. */
c->next = vb.clients;
vb.clients = c;
From 92bbe9c75c0c55d277fa69590d892b278bf2e05e Mon Sep 17 00:00:00 2001
From: Daniel Carl
Date: Thu, 30 Jun 2016 00:07:50 +0200
Subject: [PATCH 012/201] Reorder Makefile a little.
---
Makefile | 30 +++++++++++++++++-------------
1 file changed, 17 insertions(+), 13 deletions(-)
diff --git a/Makefile b/Makefile
index b7abcfd9..eb5b82b2 100644
--- a/Makefile
+++ b/Makefile
@@ -9,6 +9,14 @@ options:
@echo "LDFLAGS = $(LDFLAGS)"
@echo "CC = $(CC)"
+vimb: $(SUBDIRS:%=%.subdir-all)
+
+%.subdir-all:
+ $(MAKE) $(MFLAGS) -C $*
+
+%.subdir-clean:
+ $(MAKE) $(MFLAGS) -C $* clean
+
install: vimb
@# binary
install -d $(BINPREFIX)
@@ -16,24 +24,20 @@ install: vimb
@# extension
install -d $(EXTPREFIX)
install -m 644 $(SRCDIR)/webextension/$(EXTTARGET) $(EXTPREFIX)/$(EXTTARGET)
+ install -d $(DESTDIR)$(MANDIR)/man1
+ @sed -e "s!VERSION!$(VERSION)!g" \
+ -e "s!PREFIX!$(PREFIX)!g" \
+ -e "s!DATE!`date +'%m %Y'`!g" $(DOCDIR)/vimb.1 > $(DESTDIR)$(MANDIR)/man1/vimb.1
uninstall:
- $(RM) $(BINPREFIX)/vimb $(EXTPREFIX)/$(EXTTARGET)
-
-vimb: $(SUBDIRS:%=%.subdir-all)
-
-%.subdir-all:
- $(MAKE) $(MFLAGS) -C $*
-
-%.subdir-clean:
- $(MAKE) $(MFLAGS) -C $* clean
+ $(RM) $(BINPREFIX)/vimb $(DESTDIR)$(MANDIR)/man1/vimb.1 $(EXTPREFIX)/$(EXTTARGET)
clean: $(SUBDIRS:%=%.subdir-clean)
-runsandbox: sandbox
- sandbox/usr/bin/vimb
-
sandbox:
make RUNPREFIX=$(CURDIR)/sandbox/usr PREFIX=/usr DESTDIR=./sandbox install
-.PHONY: all options clean install uninstall sandbox
+runsandbox: sandbox
+ sandbox/usr/bin/vimb
+
+.PHONY: all options clean install uninstall sandbox sandbox-clean
From 79366c7c4710bfdb4697eb5b0a82a7472bc76482 Mon Sep 17 00:00:00 2001
From: Daniel Carl
Date: Thu, 30 Jun 2016 00:53:20 +0200
Subject: [PATCH 013/201] Made make a bit more silent.
---
Makefile | 6 +++---
config.mk | 1 +
src/webextension/Makefile | 2 +-
3 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/Makefile b/Makefile
index eb5b82b2..57731e0e 100644
--- a/Makefile
+++ b/Makefile
@@ -12,10 +12,10 @@ options:
vimb: $(SUBDIRS:%=%.subdir-all)
%.subdir-all:
- $(MAKE) $(MFLAGS) -C $*
+ @$(MAKE) $(MFLAGS) -C $*
%.subdir-clean:
- $(MAKE) $(MFLAGS) -C $* clean
+ @$(MAKE) $(MFLAGS) -C $* clean
install: vimb
@# binary
@@ -35,7 +35,7 @@ uninstall:
clean: $(SUBDIRS:%=%.subdir-clean)
sandbox:
- make RUNPREFIX=$(CURDIR)/sandbox/usr PREFIX=/usr DESTDIR=./sandbox install
+ @make $(MFLAGS) RUNPREFIX=$(CURDIR)/sandbox/usr PREFIX=/usr DESTDIR=./sandbox install
runsandbox: sandbox
sandbox/usr/bin/vimb
diff --git a/config.mk b/config.mk
index e3f18005..4a7dae54 100644
--- a/config.mk
+++ b/config.mk
@@ -35,3 +35,4 @@ EXTLDFLAGS = $(shell pkg-config --libs webkit2gtk-4.0) -shared
CFLAGS += $(shell pkg-config --cflags $(LIBS))
CFLAGS += ${CPPFLAGS}
LDFLAGS += $(shell pkg-config --libs $(LIBS))
+MFLAGS = --no-print-directory
diff --git a/src/webextension/Makefile b/src/webextension/Makefile
index 671c23f0..c15c0885 100644
--- a/src/webextension/Makefile
+++ b/src/webextension/Makefile
@@ -6,7 +6,7 @@ OBJ = $(patsubst %.c, %.lo, $(wildcard *.c))
all: $(EXTTARGET)
clean:
- $(RM) -f $(EXTTARGET) *.lo
+ $(RM) $(EXTTARGET) *.lo
$(EXTTARGET): $(OBJ)
@echo "$(CC) $@"
From 005a5875c3189ab6e82eabda7bce011251412373 Mon Sep 17 00:00:00 2001
From: Robert Timm
Date: Sun, 18 Sep 2016 23:48:16 +0200
Subject: [PATCH 014/201] Disables Makefile man page processing, man page
missing for now
---
Makefile | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/Makefile b/Makefile
index 57731e0e..3ca776fd 100644
--- a/Makefile
+++ b/Makefile
@@ -25,9 +25,9 @@ install: vimb
install -d $(EXTPREFIX)
install -m 644 $(SRCDIR)/webextension/$(EXTTARGET) $(EXTPREFIX)/$(EXTTARGET)
install -d $(DESTDIR)$(MANDIR)/man1
- @sed -e "s!VERSION!$(VERSION)!g" \
- -e "s!PREFIX!$(PREFIX)!g" \
- -e "s!DATE!`date +'%m %Y'`!g" $(DOCDIR)/vimb.1 > $(DESTDIR)$(MANDIR)/man1/vimb.1
+ # @sed -e "s!VERSION!$(VERSION)!g" \
+ # -e "s!PREFIX!$(PREFIX)!g" \
+ # -e "s!DATE!`date +'%m %Y'`!g" $(DOCDIR)/vimb.1 > $(DESTDIR)$(MANDIR)/man1/vimb.1
uninstall:
$(RM) $(BINPREFIX)/vimb $(DESTDIR)$(MANDIR)/man1/vimb.1 $(EXTPREFIX)/$(EXTTARGET)
From 67407191572c44edec10f1ec045c5f2a337cb2c2 Mon Sep 17 00:00:00 2001
From: Robert Timm
Date: Mon, 19 Sep 2016 00:03:16 +0200
Subject: [PATCH 015/201] Fixes man page install rule
---
Makefile | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/Makefile b/Makefile
index 3ca776fd..0201ccb6 100644
--- a/Makefile
+++ b/Makefile
@@ -24,10 +24,11 @@ install: vimb
@# extension
install -d $(EXTPREFIX)
install -m 644 $(SRCDIR)/webextension/$(EXTTARGET) $(EXTPREFIX)/$(EXTTARGET)
- install -d $(DESTDIR)$(MANDIR)/man1
+ @# man page
+ install -d $(MANPREFIX)/man1
# @sed -e "s!VERSION!$(VERSION)!g" \
# -e "s!PREFIX!$(PREFIX)!g" \
- # -e "s!DATE!`date +'%m %Y'`!g" $(DOCDIR)/vimb.1 > $(DESTDIR)$(MANDIR)/man1/vimb.1
+ # -e "s!DATE!`date +'%m %Y'`!g" $(DOCDIR)/vimb.1 > $(MANPREFIX)/man1/vimb.1
uninstall:
$(RM) $(BINPREFIX)/vimb $(DESTDIR)$(MANDIR)/man1/vimb.1 $(EXTPREFIX)/$(EXTTARGET)
From 70a3fd8ca932aba8f3046f83a1d63c76cda94714 Mon Sep 17 00:00:00 2001
From: Robert Timm
Date: Mon, 19 Sep 2016 00:31:51 +0200
Subject: [PATCH 016/201] Adds default-zoom setting
---
README.md | 1 +
src/setting.c | 13 +++++++++++++
2 files changed, 14 insertions(+)
diff --git a/README.md b/README.md
index c80bd9a2..c79c9a61 100644
--- a/README.md
+++ b/README.md
@@ -85,6 +85,7 @@ project directory.
instances and to work also if the page was reloaded or changed like
the marks in vim)
- [x] zooming
+ - [x] default zoom
- [ ] yanking
- [x] keymapping
- [ ] URL handler
diff --git a/src/setting.c b/src/setting.c
index a3ad8a69..373a9db3 100644
--- a/src/setting.c
+++ b/src/setting.c
@@ -49,6 +49,7 @@ static void setting_print(Client *c, Setting *s);
static void setting_free(Setting *s);
static int cookie_accept(Client *c, const char *name, DataType type, void *value, void *data);
+static int default_zoom(Client *c, const char *name, DataType type, void *value, void *data);
static int fullscreen(Client *c, const char *name, DataType type, void *value, void *data);
static int input_autohide(Client *c, const char *name, DataType type, void *value, void *data);
static int internal(Client *c, const char *name, DataType type, void *value, void *data);
@@ -137,6 +138,8 @@ void setting_init(Client *c)
setting_add(c, "timeoutlen", TYPE_INTEGER, &i, internal, 0, &c->map.timeoutlen);
setting_add(c, "input-autohide", TYPE_BOOLEAN, &off, input_autohide, 0, &c->config.input_autohide);
setting_add(c, "fullscreen", TYPE_BOOLEAN, &off, fullscreen, 0, NULL);
+ i = 100;
+ setting_add(c, "default-zoom", TYPE_INTEGER, &i, default_zoom, 0, NULL);
/* initialize the shortcuts and set the default shortcuts */
shortcut_init(c);
@@ -464,6 +467,16 @@ static int cookie_accept(Client *c, const char *name, DataType type, void *value
return CMD_SUCCESS;
}
+static int default_zoom(Client *c, const char *name, DataType type, void *value, void *data)
+{
+ float zoom = (float)*(int*)value / 100.0;
+
+ webkit_settings_set_zoom_text_only(webkit_web_view_get_settings(c->webview), FALSE);
+ webkit_web_view_set_zoom_level(c->webview, zoom);
+
+ return CMD_SUCCESS;
+}
+
static int fullscreen(Client *c, const char *name, DataType type, void *value, void *data)
{
if (*(gboolean*)value) {
From c4b159a1ba42d4456ba918a5925c71917f6ce44a Mon Sep 17 00:00:00 2001
From: Daniel Carl
Date: Tue, 2 Aug 2016 22:54:26 +0200
Subject: [PATCH 017/201] Mark navigation as done.
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index c79c9a61..b22b6934 100644
--- a/README.md
+++ b/README.md
@@ -68,7 +68,7 @@ project directory.
- [ ] external downloader
- [ ] hinting
- [x] searching and matching of search results
- - [ ] navigation j, k, h, l, ...
+ - [x] navigation j, k, h, l, ...
- [ ] history and history lookup
- [ ] completion
- [ ] HSTS
From 12d53b57e29807d619c114cdd0bef76bc96772a7 Mon Sep 17 00:00:00 2001
From: Daniel Carl
Date: Wed, 28 Sep 2016 00:03:32 +0200
Subject: [PATCH 018/201] Show output of :eval in inputbox.
---
src/ex.c | 47 +++++++++++++++++++++++++++++++++++++++++++++--
src/main.c | 1 +
2 files changed, 46 insertions(+), 2 deletions(-)
diff --git a/src/ex.c b/src/ex.c
index e3a5a712..98570d1a 100644
--- a/src/ex.c
+++ b/src/ex.c
@@ -22,6 +22,7 @@
* commands from inputbox and the ex commands.
*/
+#include
#include
#include
@@ -121,6 +122,8 @@ static VbCmdResult execute(Client *c, const ExArg *arg);
static VbCmdResult ex_bookmark(Client *c, const ExArg *arg);
static VbCmdResult ex_eval(Client *c, const ExArg *arg);
+static void ex_eval_javascript_finished(GObject *object,
+ GAsyncResult *result, Client *c);
static VbCmdResult ex_hardcopy(Client *c, const ExArg *arg);
static VbCmdResult ex_map(Client *c, const ExArg *arg);
static VbCmdResult ex_unmap(Client *c, const ExArg *arg);
@@ -747,11 +750,51 @@ static VbCmdResult ex_bookmark(Client *c, const ExArg *arg)
static VbCmdResult ex_eval(Client *c, const ExArg *arg)
{
- /* TODO allow to get the return value and possible errors. */
- webkit_web_view_run_javascript(c->webview, arg->rhs->str, NULL, NULL, NULL);
+ /* Called as :eval! - don't print to inputbox. */
+ if (arg->bang) {
+ webkit_web_view_run_javascript(c->webview, arg->rhs->str, NULL, NULL, NULL);
+ } else {
+ webkit_web_view_run_javascript(c->webview, arg->rhs->str, NULL,
+ (GAsyncReadyCallback)ex_eval_javascript_finished, c);
+ }
+
return CMD_SUCCESS;
}
+static void ex_eval_javascript_finished(GObject *object,
+ GAsyncResult *result, Client *c)
+{
+ WebKitJavascriptResult *js_result;
+ JSValueRef value;
+ JSGlobalContextRef context;
+ GError *error = NULL;
+
+ js_result = webkit_web_view_run_javascript_finish(WEBKIT_WEB_VIEW(object), result, &error);
+ if (!js_result) {
+ vb_echo(c, MSG_ERROR, TRUE, "%s", error->message);
+ g_error_free(error);
+
+ return;
+ }
+
+ context = webkit_javascript_result_get_global_context(js_result);
+ value = webkit_javascript_result_get_value(js_result);
+ if (JSValueIsString(context, value)) {
+ JSStringRef str_ref;
+ char *string;
+ size_t len;
+
+ str_ref = JSValueToStringCopy(context, value, NULL);
+ len = JSStringGetMaximumUTF8CStringSize(str_ref);
+ string = g_new(char, len);
+ JSStringGetUTF8CString(str_ref, string, len);
+ JSStringRelease(str_ref);
+ vb_echo(c, MSG_NORMAL, FALSE, "%s", string);
+ g_free(string);
+ }
+ webkit_javascript_result_unref(js_result);
+}
+
static VbCmdResult ex_hardcopy(Client *c, const ExArg *arg)
{
/* TODO no implemented yet */
diff --git a/src/main.c b/src/main.c
index 8644123a..93141ad6 100644
--- a/src/main.c
+++ b/src/main.c
@@ -622,6 +622,7 @@ static void input_print(Client *c, gboolean force, MessageType type,
/* apply input style only if the message type was changed */
if (type != c->state.input_type) {
c->state.input_type = type;
+ vb_input_update_style(c);
}
vb_input_set_text(c, message);
if (hide) {
From ff51de70107faf42b0ef0e3772acd0b7b01ae50b Mon Sep 17 00:00:00 2001
From: Daniel Carl
Date: Wed, 28 Sep 2016 00:29:27 +0200
Subject: [PATCH 019/201] Allow link activation from search result.
When a search is performed and the current highlighted result is part of
a link, a click event is triggered on the link to open it. Currently
the click() is done by JavaScript on the element so that we can't
control if the target open in current window or in a new one.
---
src/command.c | 1 +
src/normal.c | 19 ++++++++++++++++++-
2 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/src/command.c b/src/command.c
index 09ab5ef9..9d97f426 100644
--- a/src/command.c
+++ b/src/command.c
@@ -68,6 +68,7 @@ gboolean command_search(Client *c, const Arg *arg)
WEBKIT_FIND_OPTIONS_WRAP_AROUND |
(forward ? WEBKIT_FIND_OPTIONS_NONE : WEBKIT_FIND_OPTIONS_BACKWARDS),
G_MAXUINT);
+ /* TODO get the number of matches */
c->state.search.active = TRUE;
/* Skip first search because the first match is already
* highlighted on search start. */
diff --git a/src/normal.c b/src/normal.c
index 3398488d..7410fb9e 100644
--- a/src/normal.c
+++ b/src/normal.c
@@ -53,6 +53,7 @@ typedef VbResult (*NormalCommand)(Client *c, const NormalCmdInfo *info);
static VbResult normal_clear_input(Client *c, const NormalCmdInfo *info);
static VbResult normal_descent(Client *c, const NormalCmdInfo *info);
static VbResult normal_ex(Client *c, const NormalCmdInfo *info);
+static VbResult normal_fire(Client *c, const NormalCmdInfo *info);
static VbResult normal_g_cmd(Client *c, const NormalCmdInfo *info);
static VbResult normal_hint(Client *c, const NormalCmdInfo *info);
static VbResult normal_do_hint(Client *c, const char *prompt);
@@ -90,7 +91,7 @@ static struct {
/* ^J 0x0a */ {NULL},
/* ^K 0x0b */ {NULL},
/* ^L 0x0c */ {NULL},
-/* ^M 0x0d */ {NULL},
+/* ^M 0x0d */ {normal_fire},
/* ^N 0x0e */ {NULL},
/* ^O 0x0f */ {normal_navigate},
/* ^P 0x10 */ {normal_queue},
@@ -415,6 +416,22 @@ static VbResult normal_ex(Client *c, const NormalCmdInfo *info)
return RESULT_COMPLETE;
}
+static VbResult normal_fire(Client *c, const NormalCmdInfo *info)
+{
+ /* If searching is currently active - click link containing current search
+ * highlight. We use the search_matches as indicator that the searching is
+ * active. */
+ if (c->state.search.active) {
+ webkit_web_view_run_javascript(c->webview,
+ "getSelection().anchorNode.parentNode.click();", NULL, NULL,
+ NULL);
+
+ return RESULT_COMPLETE;
+ }
+
+ return RESULT_ERROR;
+}
+
static VbResult normal_g_cmd(Client *c, const NormalCmdInfo *info)
{
Arg a;
From 1a77685e0b3be694b65a930734dd06986e811434 Mon Sep 17 00:00:00 2001
From: Robert Timm
Date: Sun, 25 Sep 2016 22:35:22 +0200
Subject: [PATCH 020/201] Adds yank command
---
README.md | 2 +-
src/command.c | 44 +++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 44 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
index b22b6934..ad60253e 100644
--- a/README.md
+++ b/README.md
@@ -86,7 +86,7 @@ project directory.
the marks in vim)
- [x] zooming
- [x] default zoom
- - [ ] yanking
+ - [x] yanking
- [x] keymapping
- [ ] URL handler
- [x] shortcuts
diff --git a/src/command.c b/src/command.c
index 9d97f426..a8495e0b 100644
--- a/src/command.c
+++ b/src/command.c
@@ -91,7 +91,49 @@ gboolean command_search(Client *c, const Arg *arg)
gboolean command_yank(Client *c, const Arg *arg, char buf)
{
- /* TODO no implemented yet */
+ /**
+ * This implementation is quite 'brute force', same as in vimb2
+ * - both X clipboards are always set, PRIMARY and CLIPBOARD
+ * - the X clipboards are always set, even though a vimb register was given
+ */
+
+ const char *uri = NULL;
+ char *yanked = NULL;
+
+ g_assert(c);
+ g_assert(arg);
+ g_assert(c->webview);
+ g_assert(arg->i == COMMAND_YANK_URI || arg->i == COMMAND_YANK_SELECTION);
+
+ if (arg->i == COMMAND_YANK_URI) {
+ if ((uri = webkit_web_view_get_uri(c->webview))) {
+ yanked = g_strdup(uri);
+ }
+ } else if (arg->i == COMMAND_YANK_SELECTION) {
+ // copy web view selection to clipboard
+ webkit_web_view_execute_editing_command(c->webview, WEBKIT_EDITING_COMMAND_COPY);
+ // read back copy from clipboard
+ yanked = gtk_clipboard_wait_for_text(gtk_clipboard_get(GDK_SELECTION_PRIMARY));
+ }
+
+ if(!yanked) {
+ return FALSE;
+ }
+
+ // store in vimb default register
+ vb_register_add(c, '"', yanked);
+ // store in vimb register buf if buf != 0
+ vb_register_add(c, buf, yanked);
+
+ // store in X clipboard primary (selected text copy, middle mouse paste)
+ gtk_clipboard_set_text(gtk_clipboard_get(GDK_SELECTION_PRIMARY), yanked, -1);
+ // store in X "windows style" clipboard
+ gtk_clipboard_set_text(gtk_clipboard_get(GDK_SELECTION_CLIPBOARD), yanked, -1);
+
+ vb_echo(c, MSG_NORMAL, false, "Yanked: %s", yanked);
+
+ g_free(yanked);
+
return TRUE;
}
From 596d0e05b9aa4007a02ecf40936d3a9340fec143 Mon Sep 17 00:00:00 2001
From: Robert Timm
Date: Tue, 27 Sep 2016 21:27:36 +0200
Subject: [PATCH 021/201] Fixes comment style
---
src/command.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/command.c b/src/command.c
index a8495e0b..700bd2ce 100644
--- a/src/command.c
+++ b/src/command.c
@@ -110,9 +110,9 @@ gboolean command_yank(Client *c, const Arg *arg, char buf)
yanked = g_strdup(uri);
}
} else if (arg->i == COMMAND_YANK_SELECTION) {
- // copy web view selection to clipboard
+ /* copy web view selection to clipboard */
webkit_web_view_execute_editing_command(c->webview, WEBKIT_EDITING_COMMAND_COPY);
- // read back copy from clipboard
+ /* read back copy from clipboard */
yanked = gtk_clipboard_wait_for_text(gtk_clipboard_get(GDK_SELECTION_PRIMARY));
}
@@ -120,14 +120,14 @@ gboolean command_yank(Client *c, const Arg *arg, char buf)
return FALSE;
}
- // store in vimb default register
+ /* store in vimb default register */
vb_register_add(c, '"', yanked);
- // store in vimb register buf if buf != 0
+ /* store in vimb register buf if buf != 0 */
vb_register_add(c, buf, yanked);
- // store in X clipboard primary (selected text copy, middle mouse paste)
+ /* store in X clipboard primary (selected text copy, middle mouse paste) */
gtk_clipboard_set_text(gtk_clipboard_get(GDK_SELECTION_PRIMARY), yanked, -1);
- // store in X "windows style" clipboard
+ /* store in X "windows style" clipboard */
gtk_clipboard_set_text(gtk_clipboard_get(GDK_SELECTION_CLIPBOARD), yanked, -1);
vb_echo(c, MSG_NORMAL, false, "Yanked: %s", yanked);
From d98b47e362227a1fc0a1be78f57b02d7f6740a6f Mon Sep 17 00:00:00 2001
From: Robert Timm
Date: Sun, 18 Sep 2016 23:50:34 +0200
Subject: [PATCH 022/201] Adds vimb.desktop file and install rule
---
Makefile | 3 +++
config.mk | 13 +++++++------
vimb.desktop | 11 +++++++++++
3 files changed, 21 insertions(+), 6 deletions(-)
create mode 100644 vimb.desktop
diff --git a/Makefile b/Makefile
index 0201ccb6..912bf669 100644
--- a/Makefile
+++ b/Makefile
@@ -29,6 +29,9 @@ install: vimb
# @sed -e "s!VERSION!$(VERSION)!g" \
# -e "s!PREFIX!$(PREFIX)!g" \
# -e "s!DATE!`date +'%m %Y'`!g" $(DOCDIR)/vimb.1 > $(MANPREFIX)/man1/vimb.1
+ @# .desktop file
+ install -d $(DOTDESKTOPPREFIX)
+ install -m 644 vimb.desktop $(DOTDESKTOPPREFIX)/vimb.desktop
uninstall:
$(RM) $(BINPREFIX)/vimb $(DESTDIR)$(MANDIR)/man1/vimb.1 $(EXTPREFIX)/$(EXTTARGET)
diff --git a/config.mk b/config.mk
index 4a7dae54..2bf9eed8 100644
--- a/config.mk
+++ b/config.mk
@@ -1,11 +1,12 @@
VERSION = dev-3.0
-PREFIX ?= /usr/local
-BINPREFIX := $(DESTDIR)$(PREFIX)/bin
-MANPREFIX := $(DESTDIR)$(PREFIX)/share/man
-EXAMPLEPREFIX := $(DESTDIR)$(PREFIX)/share/vimb/example
-RUNPREFIX := $(PREFIX)
-EXTPREFIX := $(RUNPREFIX)/lib/vimb
+PREFIX ?= /usr/local
+BINPREFIX := $(DESTDIR)$(PREFIX)/bin
+MANPREFIX := $(DESTDIR)$(PREFIX)/share/man
+EXAMPLEPREFIX := $(DESTDIR)$(PREFIX)/share/vimb/example
+DOTDESKTOPPREFIX := $(DESTDIR)$(PREFIX)/share/applications
+RUNPREFIX := $(PREFIX)
+EXTPREFIX := $(RUNPREFIX)/lib/vimb
# define some directories
SRCDIR = src
diff --git a/vimb.desktop b/vimb.desktop
new file mode 100644
index 00000000..37fa6e90
--- /dev/null
+++ b/vimb.desktop
@@ -0,0 +1,11 @@
+# Based on Arch Linux' chromium.desktop
+[Desktop Entry]
+Name=vimb
+GenericName=Web Browser
+Comment=Access the Internet
+Exec=vimb %U
+Terminal=false
+Icon=
+Type=Application
+Categories=GTK;Network;WebBrowser;
+MimeType=text/html;application/xhtml+xml;x-scheme-handler/http;x-scheme-handler/https;
From 9834c6c658f5b2e39b33529da9335fd9fb099806 Mon Sep 17 00:00:00 2001
From: Robert Timm
Date: Mon, 19 Sep 2016 00:15:28 +0200
Subject: [PATCH 023/201] Mark cookie support as done.
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index ad60253e..ef58d27b 100644
--- a/README.md
+++ b/README.md
@@ -73,7 +73,7 @@ project directory.
- [ ] completion
- [ ] HSTS
- [ ] auto-response-header
- - [ ] cookies support
+ - [x] cookies support
- [ ] register support and `:register` command
- [ ] read it later queue
- [ ] show scroll indicator in statusbar as top, x%, bttom or all
From ef2780d8e22b0ef2ef1d078bcb7cdc15b28fe89a Mon Sep 17 00:00:00 2001
From: Robert Timm
Date: Wed, 28 Sep 2016 22:00:36 +0200
Subject: [PATCH 024/201] Mark register support as done
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index ef58d27b..f10dfcb8 100644
--- a/README.md
+++ b/README.md
@@ -74,7 +74,7 @@ project directory.
- [ ] HSTS
- [ ] auto-response-header
- [x] cookies support
- - [ ] register support and `:register` command
+ - [x] register support and `:register` command
- [ ] read it later queue
- [ ] show scroll indicator in statusbar as top, x%, bttom or all
how can we get this information from webview easily?
From dd69464ca6e832a1d1967e52bb7acfee770eb299 Mon Sep 17 00:00:00 2001
From: Daniel Carl
Date: Fri, 30 Sep 2016 09:59:03 +0200
Subject: [PATCH 025/201] Fix some typos.
---
README.md | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/README.md b/README.md
index f10dfcb8..0b23412f 100644
--- a/README.md
+++ b/README.md
@@ -24,7 +24,7 @@ If you like to have a working vimb, please use the master branch.
├── doc documentation like manual page
└── src all sources to build vimb
- ├── scripts JavaScripts that are compiled in to various purposes
+ ├── scripts JavaScripts that are compiled in for various purposes
└── webextension Source files for the webextension
## dependencies
@@ -35,9 +35,9 @@ If you like to have a working vimb, please use the master branch.
To inform vimb during compile time where the webextension should be loaded
from, the `RUNPREFIX` option can be set to a full qualified path to the
-directory where the extension should be sotred in.
+directory where the extension should be stored in.
-To run vimb wihtout installation you could run as a sandbox like this
+To run vimb without installation you could run as a sandbox like this
make runsandbox
@@ -50,7 +50,7 @@ project directory.
- [x] write make file
- [x] allow to built as sandbox for local testing
- [x] add a way to specify the target of the webextension shared objects
- this is now available with the `RUNPREFIX` oprion for the make
+ this is now available with the `RUNPREFIX` option for the make
- [x] establish communication channel between the vimb instance and the now
required webextension (dbus)
2. migrate as many of the features of the webkit1 vimb
@@ -76,7 +76,7 @@ project directory.
- [x] cookies support
- [x] register support and `:register` command
- [ ] read it later queue
- - [ ] show scroll indicator in statusbar as top, x%, bttom or all
+ - [ ] show scroll indicator in statusbar as top, x%, bottom or all
how can we get this information from webview easily?
- [x] find a way to disable the scrollbars on the main frame
Can be achieved by `document.documentElement.style.overflow =
From a1f982e56162dc04facd6993116a5165b1f0d031 Mon Sep 17 00:00:00 2001
From: Daniel Carl
Date: Tue, 11 Oct 2016 11:15:34 +0200
Subject: [PATCH 026/201] Allow to print page via :hardcopy command.
---
src/ex.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/ex.c b/src/ex.c
index 98570d1a..d1d38c5a 100644
--- a/src/ex.c
+++ b/src/ex.c
@@ -797,7 +797,7 @@ static void ex_eval_javascript_finished(GObject *object,
static VbCmdResult ex_hardcopy(Client *c, const ExArg *arg)
{
- /* TODO no implemented yet */
+ webkit_web_view_run_javascript(c->webview, "window.print();", NULL, NULL, NULL);
return CMD_SUCCESS;
}
From a4a6b0ff689c13e954552bbe9ba8fd7c822d449f Mon Sep 17 00:00:00 2001
From: Robert Timm
Date: Thu, 29 Sep 2016 17:35:29 +0200
Subject: [PATCH 027/201] Implements download path and tracking
---
README.md | 2 +-
src/main.c | 192 +++++++++++++++++++++++++++++++++++++++++++++++++-
src/main.h | 2 +-
src/setting.c | 1 +
4 files changed, 192 insertions(+), 5 deletions(-)
diff --git a/README.md b/README.md
index 0b23412f..b46bc2f5 100644
--- a/README.md
+++ b/README.md
@@ -63,7 +63,7 @@ project directory.
- [ ] kiosk-mode `--kiosk,-k`
- [ ] allow to start vimb reading html from `stdin` by `vimb -`
- [ ] browser modes normal, input, command, pass-through and hintmode
- - [ ] download support
+ - [x] download support
- [ ] editor command
- [ ] external downloader
- [ ] hinting
diff --git a/src/main.c b/src/main.c
index 93141ad6..77d7af75 100644
--- a/src/main.c
+++ b/src/main.c
@@ -49,7 +49,14 @@ static void input_print(Client *c, gboolean force, MessageType type,
gboolean hide, const char *message);
static void marks_clear(Client *c);
static void mode_free(Mode *mode);
+static void on_webctx_download_started(WebKitWebContext *webctx,
+ WebKitDownload *download, Client *c);
static void on_webctx_init_web_extension(WebKitWebContext *webctx, gpointer data);
+static gboolean on_webdownload_decide_destination(WebKitDownload *download,
+ gchar *suggested_filename, Client *c);
+static void on_webdownload_failed(WebKitDownload *download,
+ GError *error, Client *c);
+static void on_webdownload_finished(WebKitDownload *download, Client *c);
static void on_webview_close(WebKitWebView *webview, Client *c);
static WebKitWebView *on_webview_create(WebKitWebView *webview,
WebKitNavigationAction *navact, Client *c);
@@ -348,13 +355,12 @@ void vb_modelabel_update(Client *c, const char *label)
*/
void vb_quit(Client *c, gboolean force)
{
-#if 0 /* TODO don't quit on running downloads */
/* if not forced quit - don't quit if there are still running downloads */
if (!force && c->state.downloads) {
- vb_echo_force(c, VB_MSG_ERROR, TRUE, "Can't quit: there are running downloads");
+ vb_echo_force(c, MSG_ERROR, TRUE, "Can't quit: there are running downloads");
return;
}
-#endif
+
/* Don't run the quit synchronously, because this could lead to access of
* no more existing widget where some command response is written. */
g_idle_add((GSourceFunc)quit, c);
@@ -722,6 +728,22 @@ static void spawn_new_instance(const char *uri, gboolean embed)
g_spawn_async(NULL, cmd, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, NULL);
}
+/**
+ * Callback for the web contexts download-started signal.
+ */
+static void on_webctx_download_started(WebKitWebContext *webctx,
+ WebKitDownload *download, Client *c)
+{
+ g_signal_connect(download, "decide-destination", G_CALLBACK(on_webdownload_decide_destination), c);
+ g_signal_connect(download, "failed", G_CALLBACK(on_webdownload_failed), c);
+ g_signal_connect(download, "finished", G_CALLBACK(on_webdownload_finished), c);
+
+ c->state.downloads = g_list_append(c->state.downloads, download);
+
+ /* to reflect the correct download count */
+ vb_statusbar_update(c);
+}
+
/**
* Callback for the web contexts initialize-web-extensions signal.
*/
@@ -743,6 +765,168 @@ static void on_webctx_init_web_extension(WebKitWebContext *webctx, gpointer data
g_free(name);
}
+/**
+ * Callback for the webkit download decide destination signal.
+ * This signal is emitted after response is received to decide a destination
+ * URI for the download.
+ */
+static gboolean on_webdownload_decide_destination(WebKitDownload *download,
+ gchar *suggested_filename, Client *c)
+{
+ g_assert(download);
+ g_assert(suggested_filename);
+ g_assert(c);
+
+ char *path, *filename, *uri;
+ GString *expanded, *filepath;
+ const char *extension_dot;
+ int suffix;
+ gssize suffix_pos;
+
+ /* get the download path from settings */
+ path = GET_CHAR(c, "download-path");
+ g_assert(path);
+
+ /* expand any ~ or $VAR patterns in download path */
+ expanded = g_string_new(NULL);
+ util_parse_expansion(c, (const char**)&path, expanded, UTIL_EXP_TILDE|UTIL_EXP_DOLLAR, "");
+ g_string_append(expanded, path + 1);
+
+ /* for unnamed downloads set default filename */
+ filename = strlen(suggested_filename) ? suggested_filename : "vimb-download";
+
+ /* construct complete download filepath */
+ filepath = g_string_new(NULL);
+ g_string_printf(filepath, "%s%c%s", expanded->str, G_DIR_SEPARATOR, filename);
+
+ /* if the filepath exists already
+ * insert numerical suffix before file extension */
+ if (g_file_test(filepath->str, G_FILE_TEST_EXISTS)) {
+ suffix = 2;
+
+ /* position on .tar. (special case, extension with two dots),
+ * position on last dot (if any) otherwise */
+ if (!(extension_dot = strstr(filename, ".tar."))) {
+ extension_dot = strrchr(filename, '.');
+ }
+
+ /* the position to insert the suffix at */
+ if (extension_dot) {
+ suffix_pos = extension_dot - filename;
+ } else {
+ suffix_pos = strlen(filename);
+ }
+
+ /* construct a new complete download filepath and add the suffix before
+ * the filename extension, keep incrementing the suffix value as long
+ * as the filepath exists, stop on first unused filename. */
+ do {
+ g_string_printf(filepath, "%s%c%.*s_%i%s",
+ expanded->str, G_DIR_SEPARATOR,
+ (int)suffix_pos, filename,
+ suffix++, filename + suffix_pos);
+ } while (g_file_test(filepath->str, G_FILE_TEST_EXISTS));
+ }
+
+ /* build URI from filepath */
+ uri = g_filename_to_uri(filepath->str, NULL, NULL);
+ g_assert(uri);
+
+ /* configure download */
+ webkit_download_set_allow_overwrite(download, FALSE);
+ webkit_download_set_destination(download, uri);
+
+ /* cleanup */
+ g_string_free(expanded, TRUE);
+ g_string_free(filepath, TRUE);
+ g_free(uri);
+
+ return TRUE;
+}
+
+/**
+ * Callback for the webkit download failed signal.
+ * This signal is emitted when an error occurs during the download operation.
+ */
+static void on_webdownload_failed(WebKitDownload *download,
+ GError *error, Client *c)
+{
+ gchar *destination = NULL, *filename = NULL, *basename = NULL;
+
+ g_assert(download);
+ g_assert(error);
+ g_assert(c);
+
+ /* get the failed download's destination uri */
+ g_object_get(download, "destination", &destination, NULL);
+ g_assert(destination);
+
+ /* filename from uri */
+ if (destination) {
+ filename = g_filename_from_uri(destination, NULL, NULL);
+ g_free(destination);
+ }
+
+ /* basename from filename */
+ if (filename) {
+ basename = g_path_get_basename(filename);
+ g_free(filename);
+ }
+
+ /* report the error to the user */
+ if (basename) {
+ vb_echo(c, MSG_ERROR, FALSE, "Download of %s failed (%s)", basename, error->message);
+ g_free(basename);
+ }
+}
+
+/**
+ * Callback for the webkit download finished signal.
+ * This signal is emitted when download finishes successfully or due to an
+ * error. In case of errors “failed” signal is emitted before this one.
+ */
+static void on_webdownload_finished(WebKitDownload *download, Client *c)
+{
+ gchar *destination = NULL, *filename = NULL, *basename = NULL;
+
+ g_assert(download);
+ g_assert(c);
+
+ c->state.downloads = g_list_remove(c->state.downloads, download);
+
+ /* to reflect the correct download count */
+ vb_statusbar_update(c);
+
+ /* get the finished downloads destination uri */
+ g_object_get(download, "destination", &destination, NULL);
+ g_assert(destination);
+
+ /* filename from uri */
+ if (destination) {
+ filename = g_filename_from_uri(destination, NULL, NULL);
+ g_free(destination);
+ }
+
+ if (filename) {
+ /* basename from filename */
+ basename = g_path_get_basename(filename);
+
+ if (basename) {
+ /* Only report to the user if the downloaded file exists, so the
+ * download was successful. Otherwise, this is a failed download
+ * finished signal and it was reported to the user in
+ * on_webdownload_failed() already. */
+ if (g_file_test(filename, G_FILE_TEST_EXISTS)) {
+ vb_echo(c, MSG_NORMAL, FALSE, "Download of %s finished", basename);
+ }
+
+ g_free(basename);
+ }
+
+ g_free(filename);
+ }
+}
+
/**
* Callback for the webview close signal.
*/
@@ -1168,6 +1352,8 @@ static WebKitWebView *webview_new(Client *c, WebKitWebView *webview)
NULL
);
+ g_signal_connect(webkit_web_context_get_default(), "download-started", G_CALLBACK(on_webctx_download_started), c);
+
/* Inject the user script file. */
if (g_file_get_contents(vb.files[FILES_SCRIPT], &js, NULL, NULL)) {
script = webkit_user_script_new(js,
diff --git a/src/main.h b/src/main.h
index c1e925eb..a4c7d7fb 100644
--- a/src/main.h
+++ b/src/main.h
@@ -213,7 +213,7 @@ struct Client {
struct Statusbar statusbar;
void *comp; /* pointer to data used in completion.c */
Mode *mode; /* current active browser mode */
- WebKitWebContext *webctx;
+ /* WebKitWebContext *webctx; */ /* not used atm, use webkit_web_context_get_default() instead */
GtkWidget *window, *input;
WebKitWebView *webview;
guint64 page_id; /* page id of the webview */
diff --git a/src/setting.c b/src/setting.c
index 373a9db3..d8b0de04 100644
--- a/src/setting.c
+++ b/src/setting.c
@@ -140,6 +140,7 @@ void setting_init(Client *c)
setting_add(c, "fullscreen", TYPE_BOOLEAN, &off, fullscreen, 0, NULL);
i = 100;
setting_add(c, "default-zoom", TYPE_INTEGER, &i, default_zoom, 0, NULL);
+ setting_add(c, "download-path", TYPE_CHAR, &"~", NULL, 0, NULL);
/* initialize the shortcuts and set the default shortcuts */
shortcut_init(c);
From bc006a453301ccd27c2fba46d02388443d30ac5a Mon Sep 17 00:00:00 2001
From: Robert Timm
Date: Mon, 17 Oct 2016 22:35:59 +0700
Subject: [PATCH 028/201] Implements gui style settings
---
README.md | 2 +-
src/config.def.h | 14 +++-----
src/main.c | 91 +++++++++++++++++++++++++++++++++++++++++++++++-
src/main.h | 1 +
src/setting.c | 42 ++++++++++++++++++++++
5 files changed, 138 insertions(+), 12 deletions(-)
diff --git a/README.md b/README.md
index b46bc2f5..e22640d5 100644
--- a/README.md
+++ b/README.md
@@ -102,7 +102,7 @@ project directory.
- [ ] try to use the webkit2 feature of running multiple pages with related
view instance `webkit_web_view_new_with_related_view`
- [ ] allow setting of different scopes, global and instance (new feature)
- - [ ] remove the settings related to the gui like `status-color-bg` this was
+ - [x] remove the settings related to the gui like `status-color-bg` this was
only a hack and is not recommended for new gtk3 applications. the
color and font settings should be setup by css instead.
- [ ] webkit2 does not provide the view mode `source` so maybe this is going
diff --git a/src/config.def.h b/src/config.def.h
index cc3b915c..8d0f7f22 100644
--- a/src/config.def.h
+++ b/src/config.def.h
@@ -26,6 +26,8 @@
#define FEATURE_TITLE_PROGRESS
/* show page title in url completions */
#define FEATURE_TITLE_IN_COMPLETION
+/* support gui style settings compatible with vimb2 */
+#define FEATURE_GUI_STYLE_VIMB2_COMPAT
#ifdef FEATURE_WGET_PROGRESS_BAR
/* chars to use for the progressbar */
@@ -39,16 +41,8 @@
/* number of chars to be shown in statusbar for ambiguous commands */
#define SHOWCMD_LEN 10
-/* css applied to the gui elements of the borwser window */
-#define GUI_STYLE "\
-#statusbar{color:#fff;background-color:#000;font:monospace bold 10;} \
-#statusbar.secure{background-color:#95e454;color:#000;} \
-#statusbar.insecure{background-color:#f77;color:#000;} \
-#input{background-color:#fff;color:#000;font:monospace 10;} \
-#input.error{background-color:#f77;font-weight:bold;} \
-#completion{color:#fff;background-color:#656565;font:monospace 10;} \
-#completion:hover{background-color:#777;} \
-#completion:selected{color:#f6f3e8;background-color:#888;}"
+/* css applied to the gui elements regardless of user's settings */
+#define GUI_STYLE_CSS_BASE "#input text{background-color:inherit;color:inherit;caret-color:@color;font:inherit;}"
/* default font size for fonts in webview */
#define SETTING_DEFAULT_FONT_SIZE 10
diff --git a/src/main.c b/src/main.c
index 77d7af75..dcbed9cf 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1312,7 +1312,96 @@ static void vimb_setup(void)
/* Prepare the style provider to be used for the clients and completion. */
vb.style_provider = gtk_css_provider_get_default();
- gtk_css_provider_load_from_data(vb.style_provider, GUI_STYLE, -1, NULL);
+}
+
+/**
+ * Update the gui style settings for client c, given a style setting name and a
+ * style setting value to be updated. The complete style sheet document will be
+ * regenerated and re-fed into gtk css provider.
+ */
+void vb_gui_style_update(Client *c, const char *setting_name_new, const char *setting_value_new)
+{
+ g_assert(c);
+ g_assert(setting_name_new);
+ g_assert(setting_value_new);
+
+ /* The css style sheet document being composed in this function */
+ GString *style_sheet = g_string_new(GUI_STYLE_CSS_BASE);
+
+ /* Mapping from vimb config setting name to css style sheet string */
+ static const char *setting_style_map[][2] = {
+#ifdef FEATURE_GUI_STYLE_VIMB2_COMPAT
+ {"completion-bg-active", " #completion:selected{background-color:%s;}"},
+ {"completion-bg-normal", " #completion{background-color:%s;}"},
+ {"completion-fg-active", " #completion:selected{color:%s;}"},
+ {"completion-fg-normal", " #completion{color:%s;}"},
+ {"completion-font", " #completion{font:%s;}"},
+ {"input-bg-error", " #input.error{background-color:%s;}"},
+ {"input-bg-normal", " #input{background-color:%s;}"},
+ {"input-fg-error", " #input.error{color:%s;}"},
+ {"input-fg-normal", " #input{color:%s;}"},
+ {"input-font-error", " #input.error{font:%s;}"},
+ {"input-font-normal", " #input{font:%s;}"},
+ {"status-color-bg", " #statusbar{background-color:%s;}"},
+ {"status-color-fg", " #statusbar{color:%s;}"},
+ {"status-font", " #statusbar{font:%s;}"},
+ {"status-ssl-color-bg", " #statusbar.secure{background-color:%s;}"},
+ {"status-ssl-color-fg", " #statusbar.secure{color:%s;}"},
+ {"status-ssl-font", " #statusbar.secure{font:%s;}"},
+ {"status-sslinvalid-color-bg", " #statusbar.unsecure{background-color:%s;}"},
+ {"status-sslinvalid-color-fg", " #statusbar.unsecure{color:%s;}"},
+ {"status-sslinvalid-font", " #statusbar.unsecure{font:%s;}"},
+#else /* vimb3 gui style settings */
+ {"completion-css", " #completion{%s;}"},
+ {"completion-hover-css", " #completion:hover{%s;}"},
+ {"completion-selected-css", " #completion:selected{%s;}"},
+ {"input-css", " #input{%s;}"},
+ {"input-error-css", " #input.error{%s;}"},
+ {"status-css", " #statusbar{%s;}"},
+ {"status-ssl-css", " #statusbar.secure{%s;}"},
+ {"status-sslinvalid-css", " #statusbar.unsecure{%s;}"},
+#endif /* FEATURE_GUI_STYLE_VIMB2_COMPAT */
+
+ {0, 0},
+ };
+
+ /* For each supported style setting name */
+ for (size_t i = 0; setting_style_map[i][0]; i++) {
+ const char *setting_name = setting_style_map[i][0];
+ const char *style_string = setting_style_map[i][1];
+
+ /* If the current style setting name is the one to be updated,
+ * append the given value with appropriate css wrapping to the
+ * style sheet document. */
+ if (strcmp(setting_name, setting_name_new) == 0) {
+ if (strlen(setting_value_new)) {
+ g_string_append_printf(style_sheet, style_string, setting_value_new);
+ }
+ }
+ /* If the current style setting name is NOT the one being updated,
+ * append the css string based on the current config setting. */
+ else {
+ Setting* setting_value = (Setting*)g_hash_table_lookup(c->config.settings, setting_name);
+
+ /* If the current style setting name is not available via settings
+ * yet - this happens during setting_init() - cleanup and return.
+ * We are going to be called again. With the last setting_add(),
+ * all style setting names are available. */
+ if(!setting_value) {
+ goto cleanup;
+ }
+
+ if (strlen(setting_value->value.s)) {
+ g_string_append_printf(style_sheet, style_string, setting_value->value.s);
+ }
+ }
+ }
+
+ /* Feed style sheet document to gtk */
+ gtk_css_provider_load_from_data(vb.style_provider, style_sheet->str, -1, NULL);
+
+cleanup:
+ g_string_free(style_sheet, TRUE);
}
/**
diff --git a/src/main.h b/src/main.h
index a4c7d7fb..9b93c6a2 100644
--- a/src/main.h
+++ b/src/main.h
@@ -275,5 +275,6 @@ void vb_quit(Client *c, gboolean force);
void vb_register_add(Client *c, char buf, const char *value);
const char *vb_register_get(Client *c, char buf);
void vb_statusbar_update(Client *c);
+void vb_gui_style_update(Client *c, const char *name, const char *value);
#endif /* end of include guard: _MAIN_H */
diff --git a/src/setting.c b/src/setting.c
index d8b0de04..6ebb3505 100644
--- a/src/setting.c
+++ b/src/setting.c
@@ -51,6 +51,7 @@ static void setting_free(Setting *s);
static int cookie_accept(Client *c, const char *name, DataType type, void *value, void *data);
static int default_zoom(Client *c, const char *name, DataType type, void *value, void *data);
static int fullscreen(Client *c, const char *name, DataType type, void *value, void *data);
+static int gui_style(Client *c, const char *name, DataType type, void *value, void *data);
static int input_autohide(Client *c, const char *name, DataType type, void *value, void *data);
static int internal(Client *c, const char *name, DataType type, void *value, void *data);
static int headers(Client *c, const char *name, DataType type, void *value, void *data);
@@ -142,6 +143,40 @@ void setting_init(Client *c)
setting_add(c, "default-zoom", TYPE_INTEGER, &i, default_zoom, 0, NULL);
setting_add(c, "download-path", TYPE_CHAR, &"~", NULL, 0, NULL);
+#ifdef FEATURE_GUI_STYLE_VIMB2_COMPAT
+ /* gui style settings vimb2 compatibility */
+ setting_add(c, "completion-bg-active", TYPE_CHAR, &"#888", gui_style, 0, NULL);
+ setting_add(c, "completion-bg-normal", TYPE_CHAR, &"#656565", gui_style, 0, NULL);
+ setting_add(c, "completion-fg-active", TYPE_CHAR, &"#f6f3e8", gui_style, 0, NULL);
+ setting_add(c, "completion-fg-normal", TYPE_CHAR, &"#fff", gui_style, 0, NULL);
+ setting_add(c, "completion-font", TYPE_CHAR, &"monospace 10", gui_style, 0, NULL);
+ setting_add(c, "input-bg-error", TYPE_CHAR, &"#f77", gui_style, 0, NULL);
+ setting_add(c, "input-bg-normal", TYPE_CHAR, &"#fff", gui_style, 0, NULL);
+ setting_add(c, "input-fg-error", TYPE_CHAR, &"#000", gui_style, 0, NULL);
+ setting_add(c, "input-fg-normal", TYPE_CHAR, &"#000", gui_style, 0, NULL);
+ setting_add(c, "input-font-error", TYPE_CHAR, &"monospace bold 10", gui_style, 0, NULL);
+ setting_add(c, "input-font-normal", TYPE_CHAR, &"monospace 10", gui_style, 0, NULL);
+ setting_add(c, "status-color-bg", TYPE_CHAR, &"#000", gui_style, 0, NULL);
+ setting_add(c, "status-color-fg", TYPE_CHAR, &"#fff", gui_style, 0, NULL);
+ setting_add(c, "status-font", TYPE_CHAR, &"monospace bold 10", gui_style, 0, NULL);
+ setting_add(c, "status-ssl-color-bg", TYPE_CHAR, &"#95e454", gui_style, 0, NULL);
+ setting_add(c, "status-ssl-color-fg", TYPE_CHAR, &"#000", gui_style, 0, NULL);
+ setting_add(c, "status-ssl-font", TYPE_CHAR, &"", gui_style, 0, NULL);
+ setting_add(c, "status-sslinvalid-color-bg", TYPE_CHAR, &"#f77", gui_style, 0, NULL);
+ setting_add(c, "status-sslinvalid-color-fg", TYPE_CHAR, &"#000", gui_style, 0, NULL);
+ setting_add(c, "status-sslinvalid-font", TYPE_CHAR, &"", gui_style, 0, NULL);
+#else
+ /* gui style settings vimb3 */
+ setting_add(c, "completion-css", TYPE_CHAR, &"color:#fff;background-color:#656565;font:monospace 10;", gui_style, 0, NULL);
+ setting_add(c, "completion-hover-css", TYPE_CHAR, &"background-color:#777;", gui_style, 0, NULL);
+ setting_add(c, "completion-selected-css", TYPE_CHAR, &"color:#f6f3e8;background-color:#888;", gui_style, 0, NULL);
+ setting_add(c, "input-css", TYPE_CHAR, &"background-color:#fff;color:#000;font:monospace 10;", gui_style, 0, NULL);
+ setting_add(c, "input-error-css", TYPE_CHAR, &"background-color:#f77;font-weight:bold;", gui_style, 0, NULL);
+ setting_add(c, "status-css", TYPE_CHAR, &"color:#fff;background-color:#000;font:monospace bold 10;", gui_style, 0, NULL);
+ setting_add(c, "status-ssl-css", TYPE_CHAR, &"background-color:#95e454;color:#000;", gui_style, 0, NULL);
+ setting_add(c, "status-sslinvalid-css", TYPE_CHAR, &"background-color:#f77;color:#000;", gui_style, 0, NULL);
+#endif /* FEATURE_GUI_STYLE_VIMB2_COMPAT */
+
/* initialize the shortcuts and set the default shortcuts */
shortcut_init(c);
shortcut_add(c, "dl", "https://duckduckgo.com/html/?q=$0");
@@ -613,6 +648,13 @@ static int statusbar(Client *c, const char *name, DataType type, void *value, vo
return CMD_SUCCESS;
}
+static int gui_style(Client *c, const char *name, DataType type, void *value, void *data)
+{
+ vb_gui_style_update(c, name, (const char*)value);
+
+ return CMD_SUCCESS;
+}
+
static int tls_policy(Client *c, const char *name, DataType type, void *value, void *data)
{
gboolean strict = *((gboolean*)value);
From 40183ae0aae819d757e7b45cecbe1cd7637e56db Mon Sep 17 00:00:00 2001
From: Daniel Carl
Date: Tue, 18 Oct 2016 23:49:39 +0200
Subject: [PATCH 029/201] Removed none needed trailing ; in css rules.
---
src/main.c | 56 +++++++++++++++++++++++++++---------------------------
1 file changed, 28 insertions(+), 28 deletions(-)
diff --git a/src/main.c b/src/main.c
index dcbed9cf..12cbf307 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1331,35 +1331,35 @@ void vb_gui_style_update(Client *c, const char *setting_name_new, const char *se
/* Mapping from vimb config setting name to css style sheet string */
static const char *setting_style_map[][2] = {
#ifdef FEATURE_GUI_STYLE_VIMB2_COMPAT
- {"completion-bg-active", " #completion:selected{background-color:%s;}"},
- {"completion-bg-normal", " #completion{background-color:%s;}"},
- {"completion-fg-active", " #completion:selected{color:%s;}"},
- {"completion-fg-normal", " #completion{color:%s;}"},
- {"completion-font", " #completion{font:%s;}"},
- {"input-bg-error", " #input.error{background-color:%s;}"},
- {"input-bg-normal", " #input{background-color:%s;}"},
- {"input-fg-error", " #input.error{color:%s;}"},
- {"input-fg-normal", " #input{color:%s;}"},
- {"input-font-error", " #input.error{font:%s;}"},
- {"input-font-normal", " #input{font:%s;}"},
- {"status-color-bg", " #statusbar{background-color:%s;}"},
- {"status-color-fg", " #statusbar{color:%s;}"},
- {"status-font", " #statusbar{font:%s;}"},
- {"status-ssl-color-bg", " #statusbar.secure{background-color:%s;}"},
- {"status-ssl-color-fg", " #statusbar.secure{color:%s;}"},
- {"status-ssl-font", " #statusbar.secure{font:%s;}"},
- {"status-sslinvalid-color-bg", " #statusbar.unsecure{background-color:%s;}"},
- {"status-sslinvalid-color-fg", " #statusbar.unsecure{color:%s;}"},
- {"status-sslinvalid-font", " #statusbar.unsecure{font:%s;}"},
+ {"completion-bg-active", " #completion:selected{background-color:%s}"},
+ {"completion-bg-normal", " #completion{background-color:%s}"},
+ {"completion-fg-active", " #completion:selected{color:%s}"},
+ {"completion-fg-normal", " #completion{color:%s}"},
+ {"completion-font", " #completion{font:%s}"},
+ {"input-bg-error", " #input.error{background-color:%s}"},
+ {"input-bg-normal", " #input{background-color:%s}"},
+ {"input-fg-error", " #input.error{color:%s}"},
+ {"input-fg-normal", " #input{color:%s}"},
+ {"input-font-error", " #input.error{font:%s}"},
+ {"input-font-normal", " #input{font:%s}"},
+ {"status-color-bg", " #statusbar{background-color:%s}"},
+ {"status-color-fg", " #statusbar{color:%s}"},
+ {"status-font", " #statusbar{font:%s}"},
+ {"status-ssl-color-bg", " #statusbar.secure{background-color:%s}"},
+ {"status-ssl-color-fg", " #statusbar.secure{color:%s}"},
+ {"status-ssl-font", " #statusbar.secure{font:%s}"},
+ {"status-sslinvalid-color-bg", " #statusbar.unsecure{background-color:%s}"},
+ {"status-sslinvalid-color-fg", " #statusbar.unsecure{color:%s}"},
+ {"status-sslinvalid-font", " #statusbar.unsecure{font:%s}"},
#else /* vimb3 gui style settings */
- {"completion-css", " #completion{%s;}"},
- {"completion-hover-css", " #completion:hover{%s;}"},
- {"completion-selected-css", " #completion:selected{%s;}"},
- {"input-css", " #input{%s;}"},
- {"input-error-css", " #input.error{%s;}"},
- {"status-css", " #statusbar{%s;}"},
- {"status-ssl-css", " #statusbar.secure{%s;}"},
- {"status-sslinvalid-css", " #statusbar.unsecure{%s;}"},
+ {"completion-css", " #completion{%s}"},
+ {"completion-hover-css", " #completion:hover{%s}"},
+ {"completion-selected-css", " #completion:selected{%s}"},
+ {"input-css", " #input{%s}"},
+ {"input-error-css", " #input.error{%s}"},
+ {"status-css", " #statusbar{%s}"},
+ {"status-ssl-css", " #statusbar.secure{%s}"},
+ {"status-sslinvalid-css", " #statusbar.unsecure{%s}"},
#endif /* FEATURE_GUI_STYLE_VIMB2_COMPAT */
{0, 0},
From 73465561834c13ab34db6d561d591e2cbc8880e3 Mon Sep 17 00:00:00 2001
From: Daniel Carl
Date: Wed, 19 Oct 2016 00:07:55 +0200
Subject: [PATCH 030/201] Allow to set initial setting for gui fonts.
There where multiple font configurations in the settings that have to be
adapt by the user before compiling to setup some suitable default gui
styling. So we use two new constants to setup a normal gui font and the
emphasized one.
---
src/config.def.h | 2 ++
src/setting.c | 18 +++++++++---------
2 files changed, 11 insertions(+), 9 deletions(-)
diff --git a/src/config.def.h b/src/config.def.h
index 8d0f7f22..d73d4806 100644
--- a/src/config.def.h
+++ b/src/config.def.h
@@ -46,4 +46,6 @@
/* default font size for fonts in webview */
#define SETTING_DEFAULT_FONT_SIZE 10
+#define SETTING_GUI_FONT_NORMAL "10px monospace"
+#define SETTING_GUI_FONT_EMPH "bold 10px monospace"
#define SETTING_HOME_PAGE "about:blank"
diff --git a/src/setting.c b/src/setting.c
index 6ebb3505..71eddad3 100644
--- a/src/setting.c
+++ b/src/setting.c
@@ -149,30 +149,30 @@ void setting_init(Client *c)
setting_add(c, "completion-bg-normal", TYPE_CHAR, &"#656565", gui_style, 0, NULL);
setting_add(c, "completion-fg-active", TYPE_CHAR, &"#f6f3e8", gui_style, 0, NULL);
setting_add(c, "completion-fg-normal", TYPE_CHAR, &"#fff", gui_style, 0, NULL);
- setting_add(c, "completion-font", TYPE_CHAR, &"monospace 10", gui_style, 0, NULL);
+ setting_add(c, "completion-font", TYPE_CHAR, &"" SETTING_GUI_FONT_NORMAL, gui_style, 0, NULL);
setting_add(c, "input-bg-error", TYPE_CHAR, &"#f77", gui_style, 0, NULL);
setting_add(c, "input-bg-normal", TYPE_CHAR, &"#fff", gui_style, 0, NULL);
setting_add(c, "input-fg-error", TYPE_CHAR, &"#000", gui_style, 0, NULL);
setting_add(c, "input-fg-normal", TYPE_CHAR, &"#000", gui_style, 0, NULL);
- setting_add(c, "input-font-error", TYPE_CHAR, &"monospace bold 10", gui_style, 0, NULL);
- setting_add(c, "input-font-normal", TYPE_CHAR, &"monospace 10", gui_style, 0, NULL);
+ setting_add(c, "input-font-error", TYPE_CHAR, &"" SETTING_GUI_FONT_EMPH, gui_style, 0, NULL);
+ setting_add(c, "input-font-normal", TYPE_CHAR, &"" SETTING_GUI_FONT_NORMAL, gui_style, 0, NULL);
setting_add(c, "status-color-bg", TYPE_CHAR, &"#000", gui_style, 0, NULL);
setting_add(c, "status-color-fg", TYPE_CHAR, &"#fff", gui_style, 0, NULL);
- setting_add(c, "status-font", TYPE_CHAR, &"monospace bold 10", gui_style, 0, NULL);
+ setting_add(c, "status-font", TYPE_CHAR, &"" SETTING_GUI_FONT_EMPH, gui_style, 0, NULL);
setting_add(c, "status-ssl-color-bg", TYPE_CHAR, &"#95e454", gui_style, 0, NULL);
setting_add(c, "status-ssl-color-fg", TYPE_CHAR, &"#000", gui_style, 0, NULL);
setting_add(c, "status-ssl-font", TYPE_CHAR, &"", gui_style, 0, NULL);
setting_add(c, "status-sslinvalid-color-bg", TYPE_CHAR, &"#f77", gui_style, 0, NULL);
setting_add(c, "status-sslinvalid-color-fg", TYPE_CHAR, &"#000", gui_style, 0, NULL);
- setting_add(c, "status-sslinvalid-font", TYPE_CHAR, &"", gui_style, 0, NULL);
+ setting_add(c, "status-sslinvalid-font", TYPE_CHAR, &"" SETTING_GUI_FONT_EMPH, gui_style, 0, NULL);
#else
/* gui style settings vimb3 */
- setting_add(c, "completion-css", TYPE_CHAR, &"color:#fff;background-color:#656565;font:monospace 10;", gui_style, 0, NULL);
+ setting_add(c, "completion-css", TYPE_CHAR, &"color:#fff;background-color:#656565;font:" SETTING_GUI_FONT_NORMAL, gui_style, 0, NULL);
setting_add(c, "completion-hover-css", TYPE_CHAR, &"background-color:#777;", gui_style, 0, NULL);
setting_add(c, "completion-selected-css", TYPE_CHAR, &"color:#f6f3e8;background-color:#888;", gui_style, 0, NULL);
- setting_add(c, "input-css", TYPE_CHAR, &"background-color:#fff;color:#000;font:monospace 10;", gui_style, 0, NULL);
- setting_add(c, "input-error-css", TYPE_CHAR, &"background-color:#f77;font-weight:bold;", gui_style, 0, NULL);
- setting_add(c, "status-css", TYPE_CHAR, &"color:#fff;background-color:#000;font:monospace bold 10;", gui_style, 0, NULL);
+ setting_add(c, "input-css", TYPE_CHAR, &"background-color:#fff;color:#000;font:" SETTING_GUI_FONT_NORMAL, gui_style, 0, NULL);
+ setting_add(c, "input-error-css", TYPE_CHAR, &"background-color:#f77;font:" SETTING_GUI_FONT_EMPH, gui_style, 0, NULL);
+ setting_add(c, "status-css", TYPE_CHAR, &"color:#fff;background-color:#000;font:" SETTING_GUI_FONT_EMPH, gui_style, 0, NULL);
setting_add(c, "status-ssl-css", TYPE_CHAR, &"background-color:#95e454;color:#000;", gui_style, 0, NULL);
setting_add(c, "status-sslinvalid-css", TYPE_CHAR, &"background-color:#f77;color:#000;", gui_style, 0, NULL);
#endif /* FEATURE_GUI_STYLE_VIMB2_COMPAT */
From 46c094a57f4b8b3b67909e1f390690306d65a577 Mon Sep 17 00:00:00 2001
From: Daniel Carl
Date: Wed, 19 Oct 2016 00:26:02 +0200
Subject: [PATCH 031/201] Removed loop initial declarations.
---
src/main.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/main.c b/src/main.c
index 12cbf307..0a158e80 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1327,6 +1327,7 @@ void vb_gui_style_update(Client *c, const char *setting_name_new, const char *se
/* The css style sheet document being composed in this function */
GString *style_sheet = g_string_new(GUI_STYLE_CSS_BASE);
+ size_t i;
/* Mapping from vimb config setting name to css style sheet string */
static const char *setting_style_map[][2] = {
@@ -1366,7 +1367,7 @@ void vb_gui_style_update(Client *c, const char *setting_name_new, const char *se
};
/* For each supported style setting name */
- for (size_t i = 0; setting_style_map[i][0]; i++) {
+ for (i = 0; setting_style_map[i][0]; i++) {
const char *setting_name = setting_style_map[i][0];
const char *style_string = setting_style_map[i][1];
From 2e99f769fb75d81e251efe1e2f8bcfca410f16c9 Mon Sep 17 00:00:00 2001
From: Daniel Carl
Date: Wed, 19 Oct 2016 00:31:55 +0200
Subject: [PATCH 032/201] More code style hints.
---
README.md | 34 +++++++++++++++++++++++++++++++++-
1 file changed, 33 insertions(+), 1 deletion(-)
diff --git a/README.md b/README.md
index e22640d5..087a1390 100644
--- a/README.md
+++ b/README.md
@@ -8,9 +8,41 @@ If you like to have a working vimb, please use the master branch.
## Patching and Coding style
+### File Layout
+
+- Comment with LICENSE and possibly short explanation of file/tool
+- Headers
+- Macros
+- Types
+- Function declarations
+ - Include variable names
+ - For short files these can be left out
+ - Group/order in logical manner
+- Global variables
+- Function definitions in same order as declarations
+- main
+
+### C Features
+
+- Do not mix declarations and code
+- Do not use for loop initial declarations
+- Use `/* */` for comments, not `//`
+
+### Headers
+
+- Place system/libc headers first in alphabetical order
+ - If headers must be included in a specific order comment to explain
+- Place local headers after an empty line
+
+### Variables
+
+- Global variables not used outside translation unit should be declared static
+- In declaration of pointers the `*` is adjacent to variable name, not type
+
+### Indentation
+
- the code is indented by 4 spaces - if you use vim to code you can set
`:set expandtab ts=4 sts=4 sw=4`
-- the functions are sorted alphabetically within the c files
- it's a good advice to orientate on the already available code
- if you are using `indent`, following options describe best the code style
- `--k-and-r-style`
From 2cbadab4ceb262a0d0f741ce994e337f3a95fa99 Mon Sep 17 00:00:00 2001
From: Daniel Carl
Date: Wed, 19 Oct 2016 22:07:19 +0200
Subject: [PATCH 033/201] Added manual page.
---
Makefile | 6 +-
doc/vimb.1 | 672 +++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 675 insertions(+), 3 deletions(-)
create mode 100644 doc/vimb.1
diff --git a/Makefile b/Makefile
index 912bf669..9cb1bf01 100644
--- a/Makefile
+++ b/Makefile
@@ -26,9 +26,9 @@ install: vimb
install -m 644 $(SRCDIR)/webextension/$(EXTTARGET) $(EXTPREFIX)/$(EXTTARGET)
@# man page
install -d $(MANPREFIX)/man1
- # @sed -e "s!VERSION!$(VERSION)!g" \
- # -e "s!PREFIX!$(PREFIX)!g" \
- # -e "s!DATE!`date +'%m %Y'`!g" $(DOCDIR)/vimb.1 > $(MANPREFIX)/man1/vimb.1
+ @sed -e "s!VERSION!$(VERSION)!g" \
+ -e "s!PREFIX!$(PREFIX)!g" \
+ -e "s!DATE!`date +'%m %Y'`!g" $(DOCDIR)/vimb.1 > $(MANPREFIX)/man1/vimb.1
@# .desktop file
install -d $(DOTDESKTOPPREFIX)
install -m 644 vimb.desktop $(DOTDESKTOPPREFIX)/vimb.desktop
diff --git a/doc/vimb.1 b/doc/vimb.1
new file mode 100644
index 00000000..bf780c60
--- /dev/null
+++ b/doc/vimb.1
@@ -0,0 +1,672 @@
+.\" vim: ft=groff
+.ad l
+.TH VIMB 1 "DATE" "vimb/VERSION" "Vimb Manual"
+.de EX
+.nf
+.ft CW
+..
+.de EE
+.ft R
+.fi
+..
+.SH NAME
+Vimb - Vim Browser - A modal web browser based on WebKit, inspired by Vim: the
+great editor.
+.SH SYNOPSIS
+.B vimb
+.OP OPTIONS
+.RI [ URI "|" file ]
+.SH DESCRIPTION
+Vimb is a WebKit based web browser that behaves like the Vimperator
+plugin for Firefox and has usage paradigms from the great editor, Vim.
+The goal of Vimb is to build a completely keyboard-driven, efficient
+and pleasurable browsing-experience.
+.SH OPTIONS
+.PP
+Mandatory arguments to long options are mandatory for short options too.
+.TP
+.BI "\-c, \-\-config " "FILE"
+Use custom configuration given as \fIFILE\fP.
+This will also be applied on new spawned instances.
+.TP
+.BI "\-e, \-\-embed " "WINID"
+.I WINID
+of an XEmbed-aware application, that Vimb will use as its parent.
+.TP
+.B "\-h, \-\-help"
+Show help options.
+.TP
+.B "\-v, \-\-version"
+Print build and version information.
+.SH MODES
+Vimb is modal and has the following main modes:
+.TP
+.B Normal Mode
+The default mode.
+Pressing Escape always enter normal mode.
+.TP
+.B Input Mode
+Used for editing text elements in a webpage.
+.TP
+.B Command Mode
+Execute `ex` commands from the builtin inputbox (commandline).
+.TP
+.B Pass-Through Mode
+In Pass-Through mode only the `` and `` keybindings are interpreted
+by Vimb, all other keystrokes are given to the webview to handle them.
+This allows the use of a website's configured keybindings, that might otherwise
+be swallowed by Vimb.
+.SH NORMAL MODE COMMANDS
+Some of the Normal Model Commands can have a numeric count to multiply the
+effect of the command.
+If a command supports the count this is shown as \fB[N]\fP.
+.SS General
+.TP
+.B :
+Start Command Mode and print `:' to the input box.
+.TP
+.B gi
+Set cursor to the first editable element in the page and switch to Input
+Mode.
+.TP
+.B CTRL\-Z
+Switch Vimb into Pass-Through Mode.
+.TP
+.B gF
+Open the Web Inspector for the current page.
+.TP
+.B CTRL\-V
+Pass the next key press directly to GTK.
+.TP
+.B CTRL\-Q
+Quit the browser if there are no running downloads.
+.SS Navigation
+.TP
+.B o
+Start Command Mode and print `:open ' to the input box.
+.TP
+.B O
+Start Command Mode and print `:open URI' to the input box.
+.TP
+.B t
+Start Command Mode and print `:tabopen ' to the input box.
+.TP
+.B T
+Start Command Mode and print `:tabopen URI' to the input box.
+.TP
+.B gh
+Open the configured home-page.
+.TP
+.B gH
+Open the configured home-page in a new window.
+.TP
+.B u
+Open the last closed page.
+.TP
+.B U
+Open the last closed page in a new window.
+.TP
+.BI [ \(dqx ]p
+Open the URI out of the register \fIx\fP or, if not given, from the clipboard.
+.TP
+.BI [ \(dqx ]P
+Open the URI out of the register \fIx\fP or, if not given, from the clipboard in a
+new window.
+.TP
+.BI [ N ]CTRL\-O
+Go back \fIN\fP steps in the browser history.
+.TP
+.BI [ N ]CTRL\-I
+Go forward \fIN\fP steps in the browser history.
+.TP
+.BI [ N ]gu
+Go to the \fIN\fPth descendent directory of the current opened URI.
+.TP
+.B gU
+Go to the domain of the current opened page.
+.TP
+.B r
+Reload the website.
+.TP
+.B R
+Reload the website without using caches.
+.TP
+.B CTRL\-C
+Stop loading the current page.
+.SS Motion
+.TP
+.BI [ N ]CTRL\-F
+Scroll \fIN\fP pages down.
+.TP
+.BI [ N ]CTRL\-B
+Scroll \fIN\fP pages up.
+.TP
+.BI [ N ]CTRL\-D
+Scroll \fIN\fP half pages down.
+.TP
+.BI [ N ]CTRL\-U
+Scroll \fIN\fP half pages up.
+.TP
+.BI [ N ]gg
+Scroll to the top of the current page.
+Or if \fIN\fP is given to \fIN\fP% of the page.
+.TP
+.BI [ N ]G
+Scroll to the bottom of the current page.
+Or if \fIN\fP is given to \fIN\fP% of the page.
+.TP
+.B 0, ^
+Scroll to the absolute left of the document.
+Unlike in Vim, 0 and ^ work exactly the same way.
+.TP
+.B $
+Scroll to the absolute right of the document.
+.TP
+.BI [ N ]h
+Scroll \fIN\fP steps to the left of page.
+.TP
+.BI [ N ]l
+Scroll \fIN\fP steps to the right of page.
+.TP
+.BI [ N ]j
+Scroll page \fIN\fP steps down.
+.TP
+.BI [ N ]k
+Scroll page \fIN\fP steps up.
+.SS Searching
+.TP
+.BI / QUERY ", ?" QUERY
+Start searching for \fIQUERY\fP in the current page.
+\fI/\fP start search forward, \fI?\fP in backward direction.
+.TP
+.B *, #
+Start searching for the current selected text, or if no text is selected for
+the content of the primary or secondary clipboard.
+\fI*\fP start the search in forward direction and \fI#\fP in backward
+direction.
+.sp
+Note that these commands will yank the text selection into the clipboard and
+may remove other content from there!
+.TP
+.BI [ N ]n
+Search for \fIN\fPnth next search result depending on current search
+direction.
+.TP
+.BI [ N ]N
+Search for \fIN\fPnth previous search result depending on current search
+.TP
+.B
+Perform a click on element containing the current highlighted search result.
+direction.
+.SS Zooming
+.TP
+.BI [ N ]zi
+Zoom-In the text of the page by \fIN\fP steps.
+.TP
+.BI [ N ]zo
+Zoom-Out the text of the page by \fIN\fP steps.
+.TP
+.BI [ N ]zI
+Full-Content Zoom-In the page by \fIN\fP steps.
+.TP
+.BI [ N ]zO
+Full-Content Zoom-Out the page by \fIN\fP steps.
+.TP
+.B zz
+Reset Zoom.
+.SS Yank
+.TP
+.BI [ \(dqx ]y
+Yank the URI or current page into register \fIx\fP and clipboard.
+.TP
+.BI [ \(dqx ]Y
+.SH COMMAND MODE
+Commands that are listed below are ex-commands like in Vim, that are typed
+into the inputbox (the command line of vimb).
+The commands may vary in their syntax or in the parts they allow,
+but in general they follow a simple syntax.
+.PP
+.BI Syntax: " :[:| ][N]cmd[name][!][ lhs][ rhs]"
+.sp
+Where \fIlhs\fP (left hand side) must not contain any unescaped space.
+The syntax of the rhs (right hand side) if this is available depends on the
+command.
+At the moment the count parts [N] of commands is parsed, but currently there is
+no command that uses the count.
+.sp
+Commands that are typed interactivly are normally recorded into command
+history and register.
+To avoid this, the commands can be prefixed by one or more additional `:' or
+whitespace.
+.PP
+Multiple commands, separated by a `|' can be given in a single command line
+and will be executed consecutively.
+The pipe can be included as an argument to a command by escaping it with a
+backslash.
+.br
+Following commands process the entire command-line string literally.
+These commands will include any `|' as part of their argument string and so
+cannot be followed by another command.
+.PP
+.PD 0
+.IP - 2
+cmap, cnoremap, imap, inoremap, nmap, nnoremap
+.IP -
+eval
+.IP -
+normal
+.IP -
+open, tabopen
+.IP -
+shellcmd
+.PD
+.SS Command Line Editing
+.TP
+.B , CTRL\-[, CTRL-C
+Ignore all typed content and switch back to normal mode.
+.TP
+.B
+Submit the entered `ex` command or search query to run it.
+.TP
+.B CTRL\-H
+Deletes the char before the cursor.
+.TP
+.B CTRL\-W
+Deletes the last word before the cursor.
+.TP
+.B CTRL\-U
+Remove everything between cursor and prompt.
+.TP
+.B CTRL\-B
+Moves the cursor directly behind the prompt `:'.
+.TP
+.B CTRL\-E
+Moves the cursor after the prompt in inputbox.
+.TP
+.B CTRL\-V
+Pass the next key press directly to GTK.
+.TP
+.B CTRL\-R {a-z"%:/;}
+Insert the content of given register at cursor position.
+See also section about `:reg[ister]' command.
+.SS Command Line History
+.TP
+.B
+Start completion of the content in the inputbox in forward direction.
+.TP
+.B
+Start completion of the content in the inputbox in backward direction.
+.TP
+.B
+Step backward in the command history.
+.TP
+.B
+Step forward in the command history.
+Yank the current selection into register \fIx\fP and clipboard.
+.SS Open
+.TP
+.BI ":o[pen] [" URI ]
+Open the give \fIURI\fP in the current window.
+If \fIURI\fP is empty, the configured 'home-page' is opened.
+.TP
+.BI ":t[abopen] [" URI ]
+Open the give \fIURI\fP in a new window.
+If \fIURI\fP is empty, the configured 'home-page' is opened.
+.SS Key Mapping
+Key mappings allow users to alter the actions of key presses.
+Each key mapping is associated with a mode and only has effect
+when the mode is active.
+The following commands allow the user to substitute one sequence
+of key presses by another.
+.PP
+.BI Syntax: " :{m}map {lhs} {rhs}"
+.PP
+Note that the \fIlhs\fP ends with the first found space.
+If you want to use space also in the {lhs} you have to escape this
+with a single `\\', as shown in the examples.
+.sp
+The \fIrhs\fP starts with the first non-space char. If you want a \fIrhs\fP
+that starts with a space, you have to use "".
+.PP
+Standard key mapping commands are provided for these modes \fIm\fP:
+.PD 0
+.IP \fBn\fP
+Normal mode: when browsing normally.
+.IP \fBi\fP
+Insert mode: when interacting with text fields on a website.
+.IP \fBc\fP
+Command Line mode: when typing into Vimb's command line.
+.PD
+.PP
+Most keys in key sequences are represented simply by the character that you
+see on the screen when you type them.
+However, as a number of these characters have special meanings, and a
+number of keys have no visual representation, a special notation is required.
+.PP
+As special key names have the format \fI<...>\fP.
+The following special keys can be used: , , ,
+for the cursor keys, , , , , , - and -.
+.TP
+.BI ":nm[ap] {" lhs "} {" rhs }
+.TP
+.BI ":im[ap] {" lhs "} {" rhs }
+.TP
+.BI ":cm[ap] {" lhs "} {" rhs }
+Map the key sequence \fIlhs\fP to \fIrhs\fP for the modes where the map
+command applies.
+The result, including \fIrhs\fP, is then further scanned for mappings.
+This allows for nested and recursive use of mappings.
+.RS
+.P
+Examples:
+.PD 0
+.IP ":cmap h /home/user/downloads/"
+Adds a keybind to insert a file path into the input box.
+This could be useful for the `:save' command
+that could be used as ":save ^Gh".
+.IP ":nmap :set scripts=on:open !glib"
+This will enable scripts and lookup the first bookmarked URI with the tag
+`glib' and open it immediately if F1 key is pressed.
+.IP ":nmap \\\\\ \\\\\ 50G"
+Example which maps two spaces to go to 50% of the page.
+.PD
+.RE
+.TP
+.BI ":nn[oremap] {" lhs "} {" rhs }
+.TP
+.BI ":ino[remap] {" lhs "} {" rhs }
+.TP
+.BI ":cno[remap] {" lhs "} {" rhs }
+Map the key sequence \fIlhs\fP to \fIrhs\fP for the mode where the map command
+applies.
+Disallow mapping of \fIrhs\fP, to avoid nested and recursive mappings.
+Often used to redefine a command.
+.TP
+.BI ":nu[nmap] {" lhs }
+.TP
+.BI ":iu[nmap] {" lhs }
+.TP
+.BI ":cu[nmap] {" lhs }
+Remove the mapping of \fIlhs\fP for the applicable mode.
+.SS Bookmarks
+.TP
+.BI ":bma [" tags ]
+Save the current opened URI with \fItags\fP to the bookmark file.
+.TP
+.BI ":bmr [" URI ]
+Removes all bookmarks for given \fIURI\fP or, if not given, the current opened
+page.
+.SS Shortcuts
+Shortcuts allow the opening of an URI built up from a named template with additional
+parameters.
+If a shortcut named 'dd' is defined, you can use it with `:open dd
+list of parameters' to open the generated URI.
+.PP
+Shortcuts are convenient to use with search engines where the URI is standardised
+and a single parameter is user defined.
+.TP
+.BI ":shortcut-add " "shortcut" "=" "URI"
+Adds a shortcut with the \fIshortcut\fP and \fIURI\fP template.
+The \fIURI\fP can contain multiple placeholders $0-$9 that will be
+filled by the parameters given when the shortcut is called.
+The parameters given when the shortcut is called will be split
+into as many parameters like the highest used placeholder.
+.sp
+To use spaces within the parameters, the parameters can be grouped by
+surrounding them with single-or double quotes-as shown in example shortcut
+`map'.
+.RS
+.P
+Examples:
+.PD 0
+.IP ":shortcut-add dl=https://duckduckgo.com/lite/?q=$0"
+to setup a search engine.
+Can be called by `:open dl my search phrase'.
+.IP ":shortcut-add gh=https://github.com/$0/$1"
+to build URIs from given parameters.
+Can be called `:open gh fanglingsu vimb'.
+.IP ":shortcut-add map=https://maps.google.com/maps?saddr=$0&daddr=$1"
+to search for a route, all but the last parameter must be quoted if they
+contain spaces like `:open map "city hall, London" railway station, London'
+.PD
+.RE
+.TP
+.BI ":shortcut-remove " "shortcut"
+Remove the search engine to the given \fIshortcut\fP.
+.TP
+.BI ":shortcut-default " "shortcut"
+Set the shortcut for given \fIshortcut\fP as the default.
+It doesn't matter if the \fIshortcut\fP is already in use or not
+to be able to set it.
+.SS Settings
+.TP
+.BI ":se[t] " var = value
+Set configuration values named by \fIvar\fP.
+To set boolean variable you should use 'on', 'off' or 'true' and 'false'.
+Colors are given as hexadecimal value like '#f57700'.
+.TP
+.BI ":se[t] " var += value
+Add the \fIvalue\fP to a number option, or append the \fIvalue\fP to a string
+option.
+When the option is a comma separated list, a comma is added, unless
+the value was empty.
+.TP
+.BI ":se[t] " var ^= value
+Multiply the \fIvalue\fP to a number option, or prepend the \fIvalue\fP to a
+string option.
+When the option is a comma separated list, a comma is added,
+unless the value was empty.
+.TP
+.BI ":se[t] " var -= value
+Subtract the \fIvalue\fP from a number option, or remove the \fIvalue\fP from
+a string option, if it is there.
+When the option is a comma separated list, a
+comma is deleted, unless the option becomes empty.
+.TP
+.BI ":se[t] " var ?
+Show the current set value of variable.
+.IR VAR .
+.TP
+.BI ":se[t] " var !
+Toggle the value of boolean variable \fIvar\fP and display the new set value.
+.SS Misc
+.TP
+.BI ":sh[ellcmd] " cmd
+Runs the given shell \fIcmd\fP syncron and print the output into inputbox.
+The following patterns in \fIcmd\fP are expanded: '~username', '~/', '$VAR'
+and '${VAR}'.
+A '\\' before these patterns disables the expansion.
+.PP
+.RS
+.PP
+.PD 0
+The following environment variables are set for called shell commands.
+.TP
+.B VIMB_URI
+This variable is set by Vimb everytime a new page is opened to the URI of the
+page.
+.TP
+.B VIMB_TITLE
+Contains the title of the current opened page.
+.TP
+.B VIMB_PID
+Contains the pid of the running Vimb instance.
+.TP
+.B VIMB_XID
+Holds the X-Window id of the Vimb window or of the embedding window if Vimb is
+started with the -e option.
+.PD
+.PP
+Example:
+.EX
+:sh ls -l $HOME
+.EE
+.RE
+.TP
+.BI ":sh[ellcmd]! " cmd
+Like :sh[ellcmd], but asyncron.
+.sp
+Example:
+.EX
+:sh! /bin/sh -c 'echo "`date` $VIMB_URI" >> myhistory.txt'
+.EE
+.TP
+.BI ":s[ave] [" path "]"
+Download current opened page into configured download directory.
+If \fIpath\fP is given, download under this file name or path.
+\fIpath\fP is expanded and can therefore contain '~/', '${ENV}'
+and '~user' pattern.
+.TP
+.B :q[uit]
+Close the browser.
+This will be refused if there are running downloads.
+.TP
+.B :q[uit]!
+Close the browser independent from an running download.
+.TP
+.B :reg[ister]
+Display the contents of all registers.
+.RS
+.PP
+.PD 0
+Registers:
+.TP
+.BR \(dqa " - " \(dqz
+26 named registers "a to "z.
+Vimb fills these registers only when you say so.
+.TP
+.B \(dq:
+Last executed `ex` command.
+.TP
+.B \(dq"
+Last yanked content.
+.TP
+.B \(dq%
+Curent opened URI.
+.TP
+.B \(dq/
+Last search phrase.
+.PD
+.RE
+.TP
+.BI :e[val] " javascript"
+Runs the given \fIjavascript\fP in the current page and display the evaluated
+value.
+.sp
+Example: :eval document.cookie
+.TP
+.BI :e[val]! " javascript"
+Like :eval, but there is nothing print to the input box.
+.TP
+.BI ":no[rmal] [" cmds ]
+Execute normal mode commands \fIcmds\fP.
+This makes it possible to execute normal mode commands typed on the input box.
+.sp
+\fIcmds\fP cannot start with a space.
+Put a count of 1 (one) before it, "1 " is one space.
+.sp
+Example: :set scripts!|no! R
+.TP
+.BI ":no[rmal]! [" cmds ]
+Like :normal, but no mapping is applied to \fIcmds\fP.
+.TP
+.B :ha[rdcopy]
+Print current document.
+Open a GUI dialog where you can select the printer,
+number of copies, orientation, etc.
+.SH COMPLETIONS
+The completions are triggered by pressing `` or `` in the
+activated inputbox.
+Depending of the current inserted content different completions are started.
+The completion takes additional typed chars to filter
+the completion list that is shown.
+.TP
+.B commands
+The completion for commands are started when at least `:` is shown in the
+inputbox.
+If initial chars are passed, the completion will lookup those
+commands that begin with the given chars.
+.TP
+.B settings
+The setting name completion is started if at least `:set ` is shown in
+inputbox and does also match settings that begins with already typed setting
+prefix.
+.TP
+.B history
+The history of URIs is shown for the `:open ` and `:tabopen ` commands.
+This completion looks up every given word in the history URI and titles.
+Only those history items are shown, where the title or URI contains all tags.
+.sp
+Example:
+.RS
+.PD 0
+.IP ":open foo bar"
+will complete only URIs that contain the words foo and bar.
+.PD
+.RE
+.TP
+.B search
+The search completion allows a filtered list of already done searches.
+This completion starts by `/` or `?` in inputbox and performs a prefix
+comparison for further typed chars.
+.SH SETTINGS
+All settings listed below can be set with the `:set' command.
+.SH FILES
+.TP
+.IR $XDG_CONFIG_HOME/vimb[/PROFILE]
+Directory for configuration data.
+If executed with \fB-p \fIPROFILE\fR parameter, configuration is read from
+this subdirectory.
+.RS
+.PD 0
+.TP
+.I config
+Configuration file to set WebKit setting, some GUI styles and keybindings.
+.TP
+.I cookies
+Cookie store file.
+.TP
+.I closed
+Holds the URI of last closed browser windows.
+.TP
+.I history
+This file holds the history of unique opened URIs.
+.TP
+.I command
+This file holds the history of commands and search queries performed via input
+box.
+.TP
+.I search
+This file holds the history of search queries.
+.TP
+.I scripts.js
+This file can be used to run user scripts, that are injected into every paged
+that is opened.
+.TP
+.I style.css
+File for userdefined CSS styles.
+These file is used if the config variable `stylesheet' is enabled.
+.PD
+.RE
+.TP
+There are also some sample scripts installed together with Vimb under
+PREFIX/share/vimb/examples.
+.SH ENVIRONMENT
+.TP
+.B http_proxy
+If this variable is set to an non-empty value, and the configuration option
+`proxy' is enabled, this will be used as HTTP proxy.
+If the proxy URL has no scheme set, HTTP is assumed.
+.TP
+.B no_proxy
+A comma separated list of domains and/or IPs which should not be proxied.
+Note that an IPv6 address must appear in brackets if used with a port,
+for example "[::1]:443".
+.IP
+Example: "localhost,127.0.0.1,::1,fc00::/7,example.com:8080"
+.SH "REPORTING BUGS"
+Report bugs to the main project page on https://github.com/fanglingsu/vimb/issues
+.br
+or on the mailing list https://lists.sourceforge.net/lists/listinfo/vimb-users.
+.SH AUTHOR
+Daniel Carl
From 512ea79df8cf2d0e6473f4a4a980e427f7352a78 Mon Sep 17 00:00:00 2001
From: Daniel Carl
Date: Wed, 19 Oct 2016 22:23:54 +0200
Subject: [PATCH 034/201] Show webview crash to the user.
---
src/main.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/main.c b/src/main.c
index 0a158e80..e8c97dad 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1139,7 +1139,8 @@ static void on_webview_ready_to_show(WebKitWebView *webview, Client *c)
*/
static gboolean on_webview_web_process_crashed(WebKitWebView *webview, Client *c)
{
- g_warning("Webview Crashed on %s", webkit_web_view_get_uri(webview));
+ vb_echo(c, MSG_ERROR, FALSE, "Webview Crashed on %s", webkit_web_view_get_uri(webview));
+
return TRUE;
}
From 4f7482e2f6c4263e0d0fd2116a2e2fa05a61f5e9 Mon Sep 17 00:00:00 2001
From: Daniel Carl
Date: Wed, 19 Oct 2016 22:37:14 +0200
Subject: [PATCH 035/201] Shut up GTK warning on realize widget.
We have to call gtk_widget_get_preferred_size to avoid warning like this
when the window widget is realized.
> Allocating size to WebKitWebViewBase 0x280c380 without calling
> gtk_widget_get_preferred_width/height(). How does the code know the size
> to allocate?
---
src/main.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/src/main.c b/src/main.c
index e8c97dad..d3588d79 100644
--- a/src/main.c
+++ b/src/main.c
@@ -514,8 +514,13 @@ static Client *client_new(WebKitWebView *webview)
c->window = gtk_plug_new(vb.embed);
xid = g_strdup_printf("%d", (int)vb.embed);
} else {
+ GtkRequisition req;
c->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_role(GTK_WINDOW(c->window), PROJECT_UCFIRST);
+ /* We have to call gtk_widget_get_preferred_size before
+ * gtk_widget_size_allocate otherwise a warning is thrown when the
+ * widget is realized. */
+ gtk_widget_get_preferred_size(GTK_WIDGET(c->window), &req, NULL);
gtk_widget_realize(GTK_WIDGET(c->window));
xid = g_strdup_printf("%d",
From f1e576ef069ddcccf4913d68b7ca390688d6a91d Mon Sep 17 00:00:00 2001
From: Daniel Carl
Date: Wed, 19 Oct 2016 23:14:52 +0200
Subject: [PATCH 036/201] Update usage agent string to current webkit version.
---
src/setting.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/setting.c b/src/setting.c
index 71eddad3..4a6a41bd 100644
--- a/src/setting.c
+++ b/src/setting.c
@@ -74,7 +74,7 @@ void setting_init(Client *c)
* Separate the setting definition from the data.
* Don't set the webkit settings if they are the default on startup. */
c->config.settings = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, (GDestroyNotify)setting_free);
- setting_add(c, "useragent", TYPE_CHAR, &"Mozilla/5.0 (X11; Linux i686) AppleWebKit/538.15+ (KHTML, like Gecko) " PROJECT "/" VERSION " Version/8.0 Safari/538.15", webkit, 0, "user-agent");
+ setting_add(c, "useragent", TYPE_CHAR, &"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/603.1 (KHTML, like Gecko) " PROJECT "/" VERSION " Version/10.0 Safari/603.1", webkit, 0, "user-agent");
/* TODO use the real names for webkit settings */
i = 14;
setting_add(c, "fontsize", TYPE_INTEGER, &i, webkit, 0, "default-font-size");
From 3cb9d54c96219ba68837a6da68c57f6b7c03bbf5 Mon Sep 17 00:00:00 2001
From: Daniel Carl
Date: Sat, 22 Oct 2016 23:30:24 +0200
Subject: [PATCH 037/201] Attempt to start dbus server from ui.
---
Makefile | 9 +-
README.md | 1 +
src/ext-proxy.c | 185 +++++++++++++--------
src/ext-proxy.h | 2 +-
src/main.c | 11 +-
src/main.h | 1 +
src/webextension/ext-main.c | 317 +++++++++++++++++++++---------------
7 files changed, 309 insertions(+), 217 deletions(-)
diff --git a/Makefile b/Makefile
index 9cb1bf01..a554a39e 100644
--- a/Makefile
+++ b/Makefile
@@ -4,10 +4,11 @@ all: vimb
options:
@echo "vimb build options:"
- @echo "LIBS = $(LIBS)"
- @echo "CFLAGS = $(CFLAGS)"
- @echo "LDFLAGS = $(LDFLAGS)"
- @echo "CC = $(CC)"
+ @echo "LIBS = $(LIBS)"
+ @echo "CFLAGS = $(CFLAGS)"
+ @echo "LDFLAGS = $(LDFLAGS)"
+ @echo "EXTCFLAGS = $(EXTCFLAGS)"
+ @echo "CC = $(CC)"
vimb: $(SUBDIRS:%=%.subdir-all)
diff --git a/README.md b/README.md
index 087a1390..3b4d73fa 100644
--- a/README.md
+++ b/README.md
@@ -85,6 +85,7 @@ project directory.
this is now available with the `RUNPREFIX` option for the make
- [x] establish communication channel between the vimb instance and the now
required webextension (dbus)
+ - [ ] use propper authorization for dbus peers
2. migrate as many of the features of the webkit1 vimb
- [x] starting with custom config file `--config,-c` option
- [ ] running multiple ex-commands during startup `--cmd,-C` options
diff --git a/src/ext-proxy.c b/src/ext-proxy.c
index 0fe07b8c..2e7fb5b2 100644
--- a/src/ext-proxy.c
+++ b/src/ext-proxy.c
@@ -24,16 +24,18 @@
#include "main.h"
#include "webextension/ext-main.h"
+static gboolean on_authorize_authenticated_peer(GDBusAuthObserver *observer,
+ GIOStream *stream, GCredentials *credentials, gpointer data);
+static gboolean on_new_connection(GDBusServer *server,
+ GDBusConnection *connection, gpointer data);
+static void on_proxy_created (GDBusProxy *proxy, GAsyncResult *result,
+ gpointer data);
static void dbus_call(Client *c, const char *method, GVariant *param,
GAsyncReadyCallback callback);
static void on_editable_change_focus(GDBusConnection *connection,
const char *sender_name, const char *object_path,
const char *interface_name, const char *signal_name,
GVariant *parameters, gpointer data);
-static void on_name_appeared(GDBusConnection *connection, const char *name,
- const char *owner, gpointer data);
-static void on_proxy_created(GDBusProxy *new_proxy, GAsyncResult *result,
- gpointer data);
static void on_web_extension_page_created(GDBusConnection *connection,
const char *sender_name, const char *object_path,
const char *interface_name, const char *signal_name,
@@ -43,34 +45,125 @@ static void on_web_extension_page_created(GDBusConnection *connection,
* vimb may hold multiple clients which may use more than one webprocess and
* therefore multiple webextension instances. */
extern struct Vimb vb;
+static GDBusServer *dbusserver;
/**
- * Request the web extension to focus first editable element.
- * Returns whether an focusable element was found or not.
+ * Initialize the dbus proxy by watching for appearing dbus name.
*/
-void ext_proxy_focus_input(Client *c)
+const char *ext_proxy_init(void)
{
- dbus_call(c, "FocusInput", NULL, NULL);
+ char *address, *guid;
+ GDBusAuthObserver *observer;
+ GError *error = NULL;
+
+ address = g_strdup_printf("unix:tmpdir=%s", g_get_tmp_dir());
+ guid = g_dbus_generate_guid();
+ observer = g_dbus_auth_observer_new();
+
+ g_signal_connect(observer, "authorize-authenticated-peer",
+ G_CALLBACK(on_authorize_authenticated_peer), NULL);
+
+ /* Use sync call because server must be starte before the web extension
+ * attempt to connect */
+ dbusserver = g_dbus_server_new_sync(address, G_DBUS_SERVER_FLAGS_NONE,
+ guid, observer, NULL, &error);
+
+ if (error) {
+ g_warning("Failed to start web extension server on %s: %s", address, error->message);
+ g_error_free(error);
+ goto out;
+ }
+
+ g_signal_connect(dbusserver, "new-connection", G_CALLBACK(on_new_connection), NULL);
+ g_dbus_server_start(dbusserver);
+
+out:
+ g_free(address);
+ g_free(guid);
+ g_object_unref(observer);
+
+ return g_dbus_server_get_client_address(dbusserver);
}
-/**
- * Initialize the dbus proxy by watching for appearing dbus name.
- */
-void ext_proxy_init(const char *id)
+/* TODO move this to a lib or somthing that can be used from ui and web
+ * process together */
+static gboolean on_authorize_authenticated_peer(GDBusAuthObserver *observer,
+ GIOStream *stream, GCredentials *credentials, gpointer data)
{
- char *service_name;
-
- service_name = g_strdup_printf("%s-%s", VB_WEBEXTENSION_SERVICE_NAME, id);
- g_bus_watch_name(
- G_BUS_TYPE_SESSION,
- service_name,
- G_BUS_NAME_WATCHER_FLAGS_NONE,
- (GBusNameAppearedCallback)on_name_appeared,
+ static GCredentials *own_credentials = NULL;
+ GError *error = NULL;
+
+ if (!own_credentials) {
+ own_credentials = g_credentials_new();
+ }
+
+ if (credentials && g_credentials_is_same_user(credentials, own_credentials, &error)) {
+ return TRUE;
+ }
+
+ if (error) {
+ g_warning("Failed to authorize web extension connection: %s", error->message);
+ g_error_free(error);
+ }
+
+ return FALSE;
+}
+
+static gboolean on_new_connection(GDBusServer *server,
+ GDBusConnection *connection, gpointer data)
+{
+ /* Create dbus proxy. */
+ g_return_val_if_fail(G_IS_DBUS_CONNECTION(connection), FALSE);
+
+ /*g_signal_connect(connection, "closed", G_CALLBACK(connection_closed_cb), NULL);*/
+
+ g_dbus_proxy_new(connection,
+ G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES|G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS,
+ NULL,
NULL,
+ VB_WEBEXTENSION_OBJECT_PATH,
+ VB_WEBEXTENSION_INTERFACE,
NULL,
+ (GAsyncReadyCallback)on_proxy_created,
NULL);
- g_free(service_name);
+
+ return TRUE;
+}
+
+static void on_proxy_created(GDBusProxy *new_proxy, GAsyncResult *result,
+ gpointer data)
+{
+ GError *error = NULL;
+ GDBusProxy *proxy;
+ GDBusConnection *connection;
+
+ proxy = g_dbus_proxy_new_finish(result, &error);
+ if (!proxy) {
+ if (!g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
+ g_warning("Error creating web extension proxy: %s", error->message);
+ }
+ g_error_free(error);
+
+ /* TODO cancel the dbus connection - use cancelable */
+ return;
+ }
+
+ connection = g_dbus_proxy_get_connection(proxy);
+ g_dbus_connection_signal_subscribe(connection, NULL,
+ VB_WEBEXTENSION_INTERFACE, "PageCreated",
+ VB_WEBEXTENSION_OBJECT_PATH, NULL, G_DBUS_SIGNAL_FLAGS_NONE,
+ (GDBusSignalCallback)on_web_extension_page_created, proxy,
+ NULL);
+}
+
+/**
+ * Request the web extension to focus first editable element.
+ * Returns whether an focusable element was found or not.
+ */
+void ext_proxy_focus_input(Client *c)
+{
+ dbus_call(c, "FocusInput", NULL, NULL);
}
/**
@@ -90,6 +183,7 @@ static void dbus_call(Client *c, const char *method, GVariant *param,
/* TODO add function to queue calls until the proxy connection is
* established */
if (!c->dbusproxy) {
+ g_message("dbus_call without proxy: %s", method);
return;
}
g_dbus_proxy_call(c->dbusproxy, method, param, G_DBUS_CALL_FLAGS_NONE, -1, NULL, callback, c);
@@ -116,53 +210,6 @@ static void on_editable_change_focus(GDBusConnection *connection,
/* TODO allo strict-focus to ignore focus event for initial set focus */
}
-/**
- * Called when the name of the webextension appeared on the dbus session bus.
- */
-static void on_name_appeared(GDBusConnection *connection, const char *name,
- const char *owner, gpointer data)
-{
- int flags = G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START
- | G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES
- | G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS;
-
- /* Create the proxy to communicate over dbus. */
- g_dbus_proxy_new(connection, flags, NULL, name,
- VB_WEBEXTENSION_OBJECT_PATH, VB_WEBEXTENSION_INTERFACE, NULL,
- (GAsyncReadyCallback)on_proxy_created, NULL);
-}
-
-/**
- * Callback called when the dbus proxy is created.
- */
-static void on_proxy_created(GDBusProxy *new_proxy, GAsyncResult *result, gpointer data)
-{
- GDBusConnection *connection;
- GDBusProxy *proxy;
- GError *error = NULL;
-
- proxy = g_dbus_proxy_new_finish(result, &error);
- connection = g_dbus_proxy_get_connection(proxy);
-
- if (!proxy) {
- g_warning("Error creating web extension proxy: %s", error->message);
- g_error_free(error);
- return;
- }
- g_dbus_proxy_set_default_timeout(proxy, 100);
- g_dbus_connection_signal_subscribe(
- connection,
- NULL,
- VB_WEBEXTENSION_INTERFACE,
- "PageCreated",
- VB_WEBEXTENSION_OBJECT_PATH,
- NULL,
- G_DBUS_SIGNAL_FLAGS_NONE,
- (GDBusSignalCallback)on_web_extension_page_created,
- proxy,
- NULL);
-}
-
/**
* Listen to the VerticalScroll signal of the webextension and set the scroll
* percent value on the client to update the statusbar.
@@ -200,7 +247,7 @@ static void on_web_extension_page_created(GDBusConnection *connection,
if (p) {
/* Set the dbus proxy on the right client based on page id. */
- p->dbusproxy = data;
+ p->dbusproxy = (GDBusProxy*)data;
g_dbus_connection_signal_subscribe(connection, NULL,
VB_WEBEXTENSION_INTERFACE, "VerticalScroll",
diff --git a/src/ext-proxy.h b/src/ext-proxy.h
index 3d6ae141..8258df9d 100644
--- a/src/ext-proxy.h
+++ b/src/ext-proxy.h
@@ -22,8 +22,8 @@
#include "main.h"
+const char *ext_proxy_init(void);
void ext_proxy_focus_input(Client *c);
-void ext_proxy_init(const char *id);
void ext_proxy_set_header(Client *c, const char *headers);
#endif /* end of include guard: _EXT_PROXY_H */
diff --git a/src/main.c b/src/main.c
index d3588d79..f7187ce3 100644
--- a/src/main.c
+++ b/src/main.c
@@ -754,20 +754,15 @@ static void on_webctx_download_started(WebKitWebContext *webctx,
*/
static void on_webctx_init_web_extension(WebKitWebContext *webctx, gpointer data)
{
- char *name;
- static guint ext_count = 0;
+ const char *name;
GVariant *vdata;
/* Setup the extension directory. */
webkit_web_context_set_web_extensions_directory(webctx, EXTPREFIX);
- name = g_strdup_printf("%u-%u", getpid(), ++ext_count);
- ext_proxy_init(name);
-
- vdata = g_variant_new("(s)", name);
+ name = ext_proxy_init();
+ vdata = g_variant_new("(ms)", name);
webkit_web_context_set_web_extensions_initialization_user_data(webctx, vdata);
-
- g_free(name);
}
/**
diff --git a/src/main.h b/src/main.h
index 9b93c6a2..212cd38e 100644
--- a/src/main.h
+++ b/src/main.h
@@ -219,6 +219,7 @@ struct Client {
guint64 page_id; /* page id of the webview */
GtkTextBuffer *buffer;
GDBusProxy *dbusproxy;
+ GDBusServer *dbusserver;
struct {
/* TODO split in global setting definitions and set values on a per
* client base. */
diff --git a/src/webextension/ext-main.c b/src/webextension/ext-main.c
index a3a8a838..cfc8e01e 100644
--- a/src/webextension/ext-main.c
+++ b/src/webextension/ext-main.c
@@ -27,19 +27,26 @@
#include "ext-dom.h"
#include "ext-util.h"
-static void add_onload_event_observers(WebKitDOMDocument *doc);
-static void dbus_emit_signal(const char *name, GVariant *data);
+static gboolean on_authorize_authenticated_peer(GDBusAuthObserver *observer,
+ GIOStream *stream, GCredentials *credentials, gpointer extension);
+static void on_dbus_connection_created(GObject *source_object,
+ GAsyncResult *result, gpointer data);
+static void add_onload_event_observers(WebKitDOMDocument *doc,
+ WebKitWebExtension *extension);
+static void emit_page_created(GDBusConnection *connection, guint64 pageid);
+static void emit_page_created_pending(GDBusConnection *connection);
+static void queue_page_created_signal(guint64 pageid);
+static void dbus_emit_signal(const char *name, WebKitWebExtension* extension,
+ GVariant *data);
static void dbus_handle_method_call(GDBusConnection *conn, const char *sender,
const char *object_path, const char *interface_name, const char *method,
GVariant *parameters, GDBusMethodInvocation *invocation, gpointer data);
-static gboolean dbus_own_name_sync(GDBusConnection *connection, const char *name,
- GBusNameOwnerFlags flags);
-static void on_dbus_name_acquire(GDBusConnection *connection, const char *name, gpointer data);
-static void on_editable_change_focus(WebKitDOMEventTarget *target, WebKitDOMEvent *event);
-static void on_page_created(WebKitWebExtension *ext, WebKitWebPage *page, gpointer data);
-static void on_web_page_document_loaded(WebKitWebPage *page, gpointer data);
-static gboolean on_web_page_send_request(WebKitWebPage *page, WebKitURIRequest *request,
- WebKitURIResponse *response, gpointer data);
+static void on_editable_change_focus(WebKitDOMEventTarget *target,
+ WebKitDOMEvent *event, WebKitWebExtension *extension);
+static void on_page_created(WebKitWebExtension *ext, WebKitWebPage *webpage, gpointer data);
+static void on_web_page_document_loaded(WebKitWebPage *webpage, gpointer extension);
+static gboolean on_web_page_send_request(WebKitWebPage *webpage, WebKitURIRequest *request,
+ WebKitURIResponse *response, gpointer extension);
static const GDBusInterfaceVTable interface_vtable = {
dbus_handle_method_call,
@@ -73,6 +80,7 @@ struct Ext {
GHashTable *headers;
GHashTable *documents;
gboolean input_focus;
+ GArray *page_created_signals;
};
struct Ext ext = {0};
@@ -83,32 +91,79 @@ struct Ext ext = {0};
G_MODULE_EXPORT
void webkit_web_extension_initialize_with_user_data(WebKitWebExtension *extension, GVariant *data)
{
- char *extid, *service_name;
- g_variant_get(data, "(s)", &extid);
+ char *server_address;
+ GDBusAuthObserver *observer;
- /* Get the DBus connection for the bus type. It would be a better to use
- * the async g_bus_own_name for this, but this leads to cases where pages
- * are created and documents are loaded before we get a name and are able
- * to call to the UI process. */
- ext.connection = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, NULL);
+ g_variant_get(data, "(ms)", &server_address);
+ if (!server_address) {
+ g_warning("UI process did not start D-Bus server");
+ return;
+ }
+
+ g_signal_connect(extension, "page-created", G_CALLBACK(on_page_created), NULL);
+
+ observer = g_dbus_auth_observer_new();
+ g_signal_connect(observer, "authorize-authenticated-peer",
+ G_CALLBACK(on_authorize_authenticated_peer), extension);
+
+ g_dbus_connection_new_for_address(server_address,
+ G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT, observer, NULL,
+ (GAsyncReadyCallback)on_dbus_connection_created, extension);
+ g_object_unref(observer);
+}
+
+static gboolean on_authorize_authenticated_peer(GDBusAuthObserver *observer,
+ GIOStream *stream, GCredentials *credentials, gpointer extension)
+{
+ /* FIXME require authentication logic */
+ return TRUE;
+}
- service_name = g_strdup_printf("%s-%s", VB_WEBEXTENSION_SERVICE_NAME, extid);
+static void on_dbus_connection_created(GObject *source_object,
+ GAsyncResult *result, gpointer data)
+{
+ static GDBusNodeInfo *node_info = NULL;
+ GDBusConnection *connection;
+ GError *error = NULL;
- /* Try to own name synchronously. */
- if (ext.connection && dbus_own_name_sync(ext.connection, service_name, G_BUS_NAME_OWNER_FLAGS_NONE)) {
- on_dbus_name_acquire(ext.connection, service_name, extension);
+ if (!node_info) {
+ node_info = g_dbus_node_info_new_for_xml(introspection_xml, NULL);
}
- g_free(service_name);
+ connection = g_dbus_connection_new_for_address_finish(result, &error);
+ if (error) {
+ g_warning("Failed to connect to UI process: %s", error->message);
+ g_error_free(error);
+ return;
+ }
- g_signal_connect(extension, "page-created", G_CALLBACK(on_page_created), NULL);
+ /* register the webextension object */
+ ext.regid = g_dbus_connection_register_object(
+ connection,
+ VB_WEBEXTENSION_OBJECT_PATH,
+ node_info->interfaces[0],
+ &interface_vtable,
+ WEBKIT_WEB_EXTENSION(data),
+ NULL,
+ &error);
+
+ if (!ext.regid) {
+ g_warning("Failed to register web extension object: %s", error->message);
+ g_error_free(error);
+ g_object_unref(connection);
+ return;
+ }
+
+ emit_page_created_pending(connection);
+ ext.connection = connection;
}
/**
* Add observers to doc event for given document and all the contained iframes
* too.
*/
-static void add_onload_event_observers(WebKitDOMDocument *doc)
+static void add_onload_event_observers(WebKitDOMDocument *doc,
+ WebKitWebExtension *extension)
{
WebKitDOMEventTarget *target;
@@ -117,20 +172,72 @@ static void add_onload_event_observers(WebKitDOMDocument *doc)
if (!g_hash_table_add(ext.documents, doc)) {
return;
}
-
+
/* We have to use default view instead of the document itself in case this
* function is called with content document of an iframe. Else the event
* observing does not work. */
- target = WEBKIT_DOM_EVENT_TARGET(webkit_dom_document_get_default_view(doc));
+ target = WEBKIT_DOM_EVENT_TARGET(webkit_dom_document_get_default_view(doc));
webkit_dom_event_target_add_event_listener(target, "focus",
- G_CALLBACK(on_editable_change_focus), TRUE, NULL);
+ G_CALLBACK(on_editable_change_focus), TRUE, extension);
webkit_dom_event_target_add_event_listener(target, "blur",
- G_CALLBACK(on_editable_change_focus), TRUE, NULL);
+ G_CALLBACK(on_editable_change_focus), TRUE, extension);
/* Check for focused editable elements also if they where focused before
* the event observer where set up. */
/* TODO this is not needed for strict-focus=on */
- on_editable_change_focus(target, NULL);
+ on_editable_change_focus(target, NULL, extension);
+}
+
+/**
+ * Emit the page created signal that is used in the ui process to finish the
+ * dbus proxy connection.
+ */
+static void emit_page_created(GDBusConnection *connection, guint64 pageid)
+{
+ GError *error = NULL;
+
+ /* propagate the signal over dbus */
+ g_dbus_connection_emit_signal(G_DBUS_CONNECTION(connection), NULL,
+ VB_WEBEXTENSION_OBJECT_PATH, VB_WEBEXTENSION_INTERFACE,
+ "PageCreated", g_variant_new("(t)", pageid), &error);
+
+ if (error) {
+ g_warning("Failed to emit signal PageCreated: %s", error->message);
+ g_error_free(error);
+ }
+}
+
+/**
+ * Emit queued page created signals.
+ */
+static void emit_page_created_pending(GDBusConnection *connection)
+{
+ int i;
+ guint64 pageid;
+
+ if (!ext.page_created_signals) {
+ return;
+ }
+
+ for (i = 0; i < ext.page_created_signals->len; i++) {
+ pageid = g_array_index(ext.page_created_signals, guint64, i);
+ emit_page_created(connection, pageid);
+ }
+
+ g_array_free(ext.page_created_signals, TRUE);
+ ext.page_created_signals = NULL;
+}
+
+/**
+ * Write the page id of the created page to a queue to send them to the ui
+ * process when the dbus connection is established.
+ */
+static void queue_page_created_signal(guint64 pageid)
+{
+ if (!ext.page_created_signals) {
+ ext.page_created_signals = g_array_new(FALSE, FALSE, sizeof(guint64));
+ }
+ ext.page_created_signals = g_array_append_val(ext.page_created_signals, pageid);
}
/**
@@ -139,11 +246,11 @@ static void add_onload_event_observers(WebKitDOMDocument *doc)
* @name: Signal name to emit.
* @data: GVariant value used as value for the signal or NULL.
*/
-static void dbus_emit_signal(const char *name, GVariant *data)
+static void dbus_emit_signal(const char *name, WebKitWebExtension* extension,
+ GVariant *data)
{
GError *error = NULL;
- /* Don't do anythings if the dbus connection was not established. */
if (!ext.connection) {
return;
}
@@ -152,8 +259,6 @@ static void dbus_emit_signal(const char *name, GVariant *data)
g_dbus_connection_emit_signal(ext.connection, NULL,
VB_WEBEXTENSION_OBJECT_PATH, VB_WEBEXTENSION_INTERFACE, name,
data, &error);
-
- /* check for error */
if (error) {
g_warning("Failed to emit signal '%s': %s", name, error->message);
g_error_free(error);
@@ -165,7 +270,7 @@ static void dbus_emit_signal(const char *name, GVariant *data)
*/
static void dbus_handle_method_call(GDBusConnection *conn, const char *sender,
const char *object_path, const char *interface_name, const char *method,
- GVariant *parameters, GDBusMethodInvocation *invocation, gpointer data)
+ GVariant *parameters, GDBusMethodInvocation *invocation, gpointer extension)
{
char *value;
@@ -184,84 +289,13 @@ static void dbus_handle_method_call(GDBusConnection *conn, const char *sender,
}
}
-/**
- * The synchronous and blocking pendent to the g_bus_own_name().
- *
- * @bus_type: The type of bus to own a name on.
- * @name: The well-known name to own.
- * @flags: A set of flags from the #GBusNameOwnerFlags enumeration.
- */
-static gboolean dbus_own_name_sync(GDBusConnection *connection, const char *name,
- GBusNameOwnerFlags flags)
-{
- GError *error = NULL;
- guint32 request_name_reply = 0;
- GVariant *result;
-
- result = g_dbus_connection_call_sync(
- connection,
- "org.freedesktop.DBus",
- "/org/freedesktop/DBus",
- "org.freedesktop.DBus",
- "RequestName",
- g_variant_new("(su)", name, flags),
- G_VARIANT_TYPE("(u)"),
- G_DBUS_CALL_FLAGS_NONE,
- -1,
- NULL,
- &error);
-
- if (result) {
- g_variant_get(result, "(u)", &request_name_reply);
- g_variant_unref(result);
-
- if (1 == request_name_reply) {
- return TRUE;
- }
- } else {
- g_warning("Failed to acquire DBus name: %s", error->message);
- g_error_free(error);
- }
- return FALSE;
-}
-
-/**
- * Called when the dbus name is aquired and registers our object.
- */
-static void on_dbus_name_acquire(GDBusConnection *connection, const char *name, gpointer data)
-{
- GError *error = NULL;
- static GDBusNodeInfo *node_info = NULL;
-
- g_return_if_fail(G_IS_DBUS_CONNECTION(connection));
-
- if (!node_info) {
- node_info = g_dbus_node_info_new_for_xml(introspection_xml, NULL);
- }
-
- /* register the webextension object */
- ext.connection = connection;
- ext.regid = g_dbus_connection_register_object(
- connection,
- VB_WEBEXTENSION_OBJECT_PATH,
- node_info->interfaces[0],
- &interface_vtable,
- WEBKIT_WEB_EXTENSION(data),
- NULL,
- &error);
-
- if (!ext.regid) {
- g_warning("Failed to register web extension object: %s", error->message);
- g_error_free(error);
- }
-}
-
/**
* Callback called if a editable element changes it focus state.
* Event target may be a WebKitDOMDocument (in case of iframe) or a
* WebKitDOMDOMWindow.
*/
-static void on_editable_change_focus(WebKitDOMEventTarget *target, WebKitDOMEvent *event)
+static void on_editable_change_focus(WebKitDOMEventTarget *target,
+ WebKitDOMEvent *event, WebKitWebExtension *extension)
{
gboolean input_focus;
WebKitDOMDocument *doc;
@@ -285,7 +319,7 @@ static void on_editable_change_focus(WebKitDOMEventTarget *target, WebKitDOMEven
iframe = WEBKIT_DOM_HTML_IFRAME_ELEMENT(active);
subdoc = webkit_dom_html_iframe_element_get_content_document(iframe);
- add_onload_event_observers(subdoc);
+ add_onload_event_observers(subdoc, extension);
return;
}
@@ -296,30 +330,36 @@ static void on_editable_change_focus(WebKitDOMEventTarget *target, WebKitDOMEven
if (input_focus != ext.input_focus) {
ext.input_focus = input_focus;
- dbus_emit_signal("EditableChangeFocus", g_variant_new("(b)", input_focus));
+ dbus_emit_signal("EditableChangeFocus", extension,
+ g_variant_new("(b)", input_focus));
}
}
/**
* Callback for web extensions page-created signal.
*/
-static void on_page_created(WebKitWebExtension *extension, WebKitWebPage *page, gpointer data)
+static void on_page_created(WebKitWebExtension *extension, WebKitWebPage *webpage, gpointer data)
{
+ guint64 pageid = webkit_web_page_get_id(webpage);
+
/* Save the new created page in the extension data for later use. */
- ext.webpage = page;
+ ext.webpage = webpage;
+ if (ext.connection) {
+ emit_page_created(ext.connection, pageid);
+ } else {
+ queue_page_created_signal(pageid);
+ }
- g_object_connect(page,
- "signal::send-request", G_CALLBACK(on_web_page_send_request), NULL,
- "signal::document-loaded", G_CALLBACK(on_web_page_document_loaded), NULL,
+ g_object_connect(webpage,
+ "signal::send-request", G_CALLBACK(on_web_page_send_request), extension,
+ "signal::document-loaded", G_CALLBACK(on_web_page_document_loaded), extension,
NULL);
-
- dbus_emit_signal("PageCreated", g_variant_new("(t)", webkit_web_page_get_id(page)));
}
/**
* Callback for web pages document-loaded signal.
*/
-static void on_web_page_document_loaded(WebKitWebPage *page, gpointer data)
+static void on_web_page_document_loaded(WebKitWebPage *webpage, gpointer extension)
{
/* If there is a hashtable of known document - detroy this and create a
* new hashtable. */
@@ -328,31 +368,38 @@ static void on_web_page_document_loaded(WebKitWebPage *page, gpointer data)
}
ext.documents = g_hash_table_new(g_direct_hash, g_direct_equal);
- add_onload_event_observers(webkit_web_page_get_dom_document(page));
+ add_onload_event_observers(webkit_web_page_get_dom_document(webpage),
+ WEBKIT_WEB_EXTENSION(extension));
}
/**
* Callback for web pages send-request signal.
*/
-static gboolean on_web_page_send_request(WebKitWebPage *page, WebKitURIRequest *request,
- WebKitURIResponse *response, gpointer data)
+static gboolean on_web_page_send_request(WebKitWebPage *webpage, WebKitURIRequest *request,
+ WebKitURIResponse *response, gpointer extension)
{
+ char *name, *value;
+ SoupMessageHeaders *headers;
+ GHashTableIter iter;
+
+ if (!ext.headers) {
+ return FALSE;
+ }
+
/* Change request headers according to the users preferences. */
- if (ext.headers) {
- char *name, *value;
- SoupMessageHeaders *headers;
- GHashTableIter iter;
-
- headers = webkit_uri_request_get_http_headers(request);
- g_hash_table_iter_init(&iter, ext.headers);
- while (g_hash_table_iter_next(&iter, (gpointer*)&name, (gpointer*)&value)) {
- /* Null value is used to indicate that the header should be
- * removed completely. */
- if (value == NULL) {
- soup_message_headers_remove(headers, name);
- } else {
- soup_message_headers_replace(headers, name, value);
- }
+ headers = webkit_uri_request_get_http_headers(request);
+ if (!headers) {
+ return FALSE;
+ }
+
+ g_hash_table_iter_init(&iter, ext.headers);
+ while (g_hash_table_iter_next(&iter, (gpointer*)&name, (gpointer*)&value)) {
+ /* Null value is used to indicate that the header should be
+ * removed completely. */
+ if (value == NULL) {
+ soup_message_headers_remove(headers, name);
+ } else {
+ soup_message_headers_replace(headers, name, value);
}
}
From fa619c8886e78ac0108217f9884ed4ba1ad25a52 Mon Sep 17 00:00:00 2001
From: Daniel Carl
Date: Tue, 31 Jan 2017 23:37:57 +0100
Subject: [PATCH 038/201] Set minimum webkit version to support to 2.3.5.
This version allowed to initialize the webextension with user data which
is essential to setup the dbus connection.
---
config.mk | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/config.mk b/config.mk
index 2bf9eed8..c445f5ad 100644
--- a/config.mk
+++ b/config.mk
@@ -14,7 +14,7 @@ DOCDIR = doc
SUBDIRS = $(SRCDIR)/scripts $(SRCDIR)/webextension $(SRCDIR)
# used libs
-LIBS = gtk+-3.0 webkit2gtk-4.0
+LIBS = gtk+-3.0 'webkit2gtk-4.0 >= 2.3.5'
# setup general used CFLAGS
CFLAGS += -std=c99 -pipe -Wall
From 9ead350f88b734b55002e92e887a7821bb951660 Mon Sep 17 00:00:00 2001
From: Daniel Carl
Date: Tue, 31 Jan 2017 23:39:37 +0100
Subject: [PATCH 039/201] Show linker action during make.
---
src/Makefile | 2 +-
src/scripts/Makefile | 1 -
2 files changed, 1 insertion(+), 2 deletions(-)
diff --git a/src/Makefile b/src/Makefile
index e4e2faea..ddf3d153 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -10,7 +10,7 @@ clean:
vimb: $(OBJ)
@echo "$(CC) $@"
- @$(CC) $(LDFLAGS) $(OBJ) -o $@
+ $(CC) $(LDFLAGS) $(OBJ) -o $@
$(OBJ): config.h $(BASEDIR)/config.mk
diff --git a/src/scripts/Makefile b/src/scripts/Makefile
index 32af1912..93f242d6 100644
--- a/src/scripts/Makefile
+++ b/src/scripts/Makefile
@@ -10,7 +10,6 @@ clean:
scripts.h: $(JSFILES)
@echo "create $@ from *.js"
- @echo > $@
@for file in $(JSFILES); do \
./js2h.sh $$file >> $@; \
done
From a825ba97de3af8d315b79717dad4cdafe9ab5d00 Mon Sep 17 00:00:00 2001
From: Daniel Carl
Date: Wed, 1 Feb 2017 00:33:22 +0100
Subject: [PATCH 040/201] Added real auth observer to webextension too.
---
src/Makefile | 3 +--
src/webextension/ext-main.c | 20 ++++++++++++++++++--
2 files changed, 19 insertions(+), 4 deletions(-)
diff --git a/src/Makefile b/src/Makefile
index ddf3d153..b1bd8be9 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -9,8 +9,7 @@ clean:
$(RM) vimb *.o
vimb: $(OBJ)
- @echo "$(CC) $@"
- $(CC) $(LDFLAGS) $(OBJ) -o $@
+ $(CC) $(LDFLAGS) $^ -o $@
$(OBJ): config.h $(BASEDIR)/config.mk
diff --git a/src/webextension/ext-main.c b/src/webextension/ext-main.c
index cfc8e01e..f2d5d751 100644
--- a/src/webextension/ext-main.c
+++ b/src/webextension/ext-main.c
@@ -115,8 +115,23 @@ void webkit_web_extension_initialize_with_user_data(WebKitWebExtension *extensio
static gboolean on_authorize_authenticated_peer(GDBusAuthObserver *observer,
GIOStream *stream, GCredentials *credentials, gpointer extension)
{
- /* FIXME require authentication logic */
- return TRUE;
+ static GCredentials *own_credentials = NULL;
+ GError *error = NULL;
+
+ if (!own_credentials) {
+ own_credentials = g_credentials_new();
+ }
+
+ if (credentials && g_credentials_is_same_user(credentials, own_credentials, &error)) {
+ return TRUE;
+ }
+
+ if (error) {
+ g_warning("Failed to authorize connection to ui: %s", error->message);
+ g_error_free(error);
+ }
+
+ return FALSE;
}
static void on_dbus_connection_created(GObject *source_object,
@@ -126,6 +141,7 @@ static void on_dbus_connection_created(GObject *source_object,
GDBusConnection *connection;
GError *error = NULL;
+ g_message("on_dbus_connection_created");
if (!node_info) {
node_info = g_dbus_node_info_new_for_xml(introspection_xml, NULL);
}
From cf94439378b6bcaead3d4d25c529f52449742977 Mon Sep 17 00:00:00 2001
From: Daniel Carl
Date: Wed, 1 Feb 2017 00:46:57 +0100
Subject: [PATCH 041/201] Removed debug message.
---
src/webextension/ext-main.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/src/webextension/ext-main.c b/src/webextension/ext-main.c
index f2d5d751..ae1fe72c 100644
--- a/src/webextension/ext-main.c
+++ b/src/webextension/ext-main.c
@@ -141,7 +141,6 @@ static void on_dbus_connection_created(GObject *source_object,
GDBusConnection *connection;
GError *error = NULL;
- g_message("on_dbus_connection_created");
if (!node_info) {
node_info = g_dbus_node_info_new_for_xml(introspection_xml, NULL);
}
From 1d405d6e20b5bf0a67bec5270d02123c3dfd2e94 Mon Sep 17 00:00:00 2001
From: Daniel Carl
Date: Wed, 1 Feb 2017 00:57:02 +0100
Subject: [PATCH 042/201] Add new task to README.
---
README.md | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 3b4d73fa..ca560715 100644
--- a/README.md
+++ b/README.md
@@ -85,7 +85,9 @@ project directory.
this is now available with the `RUNPREFIX` option for the make
- [x] establish communication channel between the vimb instance and the now
required webextension (dbus)
- - [ ] use propper authorization for dbus peers
+ - [x] use propper authorization for dbus peers
+ - [ ] queue settings that needs to be pushed to the webextension until the
+ dbus connection is established.
2. migrate as many of the features of the webkit1 vimb
- [x] starting with custom config file `--config,-c` option
- [ ] running multiple ex-commands during startup `--cmd,-C` options
From b4a2118a7b27a6502afee957dde089b84ca26427 Mon Sep 17 00:00:00 2001
From: Robert Timm
Date: Fri, 17 Feb 2017 23:42:18 +0100
Subject: [PATCH 043/201] makes font sizes match webkit2 defaults
---
src/config.def.h | 3 ++-
src/setting.c | 2 +-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/config.def.h b/src/config.def.h
index d73d4806..1f55e240 100644
--- a/src/config.def.h
+++ b/src/config.def.h
@@ -45,7 +45,8 @@
#define GUI_STYLE_CSS_BASE "#input text{background-color:inherit;color:inherit;caret-color:@color;font:inherit;}"
/* default font size for fonts in webview */
-#define SETTING_DEFAULT_FONT_SIZE 10
+#define SETTING_DEFAULT_FONT_SIZE 16
+#define SETTING_DEFAULT_MONOSPACE_FONT_SIZE 13
#define SETTING_GUI_FONT_NORMAL "10px monospace"
#define SETTING_GUI_FONT_EMPH "bold 10px monospace"
#define SETTING_HOME_PAGE "about:blank"
diff --git a/src/setting.c b/src/setting.c
index 4a6a41bd..ef23eb75 100644
--- a/src/setting.c
+++ b/src/setting.c
@@ -102,7 +102,7 @@ void setting_init(Client *c)
i = 5;
setting_add(c, "minimumfontsize", TYPE_INTEGER, &i, webkit, 0, "minimum-font-size");
setting_add(c, "monofont", TYPE_CHAR, &"monospace", webkit, 0, "monospace-font-family");
- i = SETTING_DEFAULT_FONT_SIZE;
+ i = SETTING_DEFAULT_MONOSPACE_FONT_SIZE;
setting_add(c, "monofontsize", TYPE_INTEGER, &i, webkit, 0, "default-monospace-font-size");
setting_add(c, "offlinecache", TYPE_BOOLEAN, &on, webkit, 0, "enable-offline-web-application-cache");
setting_add(c, "plugins", TYPE_BOOLEAN, &on, webkit, 0, "enable-plugins");
From 248147537c0306ca0209956a079795772322d2e2 Mon Sep 17 00:00:00 2001
From: Robert Timm
Date: Fri, 17 Feb 2017 23:43:36 +0100
Subject: [PATCH 044/201] changes default gui font to 10pt
---
src/config.def.h | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/config.def.h b/src/config.def.h
index 1f55e240..8b2d27b8 100644
--- a/src/config.def.h
+++ b/src/config.def.h
@@ -47,6 +47,6 @@
/* default font size for fonts in webview */
#define SETTING_DEFAULT_FONT_SIZE 16
#define SETTING_DEFAULT_MONOSPACE_FONT_SIZE 13
-#define SETTING_GUI_FONT_NORMAL "10px monospace"
-#define SETTING_GUI_FONT_EMPH "bold 10px monospace"
-#define SETTING_HOME_PAGE "about:blank"
+#define SETTING_GUI_FONT_NORMAL "10pt monospace"
+#define SETTING_GUI_FONT_EMPH "bold 10pt monospace"
+#define SETTING_HOME_PAGE "about:blank"
From aca5b9b088285244ab0258c30246844a4164230f Mon Sep 17 00:00:00 2001
From: Robert Timm
Date: Mon, 20 Feb 2017 23:49:57 +0100
Subject: [PATCH 045/201] implements ex_shortcut()
---
src/ex.c | 35 +++++++++++++++++++++++++++++++++--
1 file changed, 33 insertions(+), 2 deletions(-)
diff --git a/src/ex.c b/src/ex.c
index d1d38c5a..e9b1c641 100644
--- a/src/ex.c
+++ b/src/ex.c
@@ -35,6 +35,7 @@
#include "main.h"
#include "map.h"
#include "setting.h"
+#include "shortcut.h"
#include "util.h"
typedef enum {
@@ -966,8 +967,38 @@ static VbCmdResult ex_handlers(Client *c, const ExArg *arg)
static VbCmdResult ex_shortcut(Client *c, const ExArg *arg)
{
- /* TODO no implemented yet */
- return CMD_SUCCESS;
+ char *key, *uri;
+ gboolean res = CMD_ERROR;
+
+ if (!c) {
+ return CMD_ERROR;
+ }
+
+ if (!arg || !arg->name) {
+ return CMD_ERROR;
+ }
+
+ if (!arg->rhs || !arg->rhs->str || !*arg->rhs->str) {
+ return CMD_ERROR;
+ }
+
+ if (strstr(arg->name, "shortcut-add")) {
+ if ((uri = strchr(arg->rhs->str, '='))) {
+ key = arg->rhs->str;
+ *uri++ = '\0'; /* devide key and uri */
+ g_strstrip(key);
+ g_strstrip(uri);
+ res = shortcut_add(c, key, uri);
+ }
+ } else if (strstr(arg->name, "shortcut-remove")) {
+ g_strstrip(arg->rhs->str);
+ res = shortcut_remove(c, arg->rhs->str);
+ } else if (strstr(arg->name, "shortcut-default")) {
+ g_strstrip(arg->rhs->str);
+ res = shortcut_set_default(c, arg->rhs->str);
+ }
+
+ return res;
}
/**
From bfe8ad4672d81fe2c247e4210b5448a70579ffe5 Mon Sep 17 00:00:00 2001
From: Robert Timm
Date: Thu, 23 Feb 2017 10:46:21 +0100
Subject: [PATCH 046/201] improves ex_shortcut() inspired by master branch
---
src/ex.c | 46 +++++++++++++++++++++++++---------------------
1 file changed, 25 insertions(+), 21 deletions(-)
diff --git a/src/ex.c b/src/ex.c
index e9b1c641..7f779507 100644
--- a/src/ex.c
+++ b/src/ex.c
@@ -967,38 +967,42 @@ static VbCmdResult ex_handlers(Client *c, const ExArg *arg)
static VbCmdResult ex_shortcut(Client *c, const ExArg *arg)
{
- char *key, *uri;
- gboolean res = CMD_ERROR;
+ gchar *uri;
+ gboolean success = false;
if (!c) {
return CMD_ERROR;
}
- if (!arg || !arg->name) {
- return CMD_ERROR;
- }
-
if (!arg->rhs || !arg->rhs->str || !*arg->rhs->str) {
return CMD_ERROR;
}
- if (strstr(arg->name, "shortcut-add")) {
- if ((uri = strchr(arg->rhs->str, '='))) {
- key = arg->rhs->str;
- *uri++ = '\0'; /* devide key and uri */
- g_strstrip(key);
- g_strstrip(uri);
- res = shortcut_add(c, key, uri);
- }
- } else if (strstr(arg->name, "shortcut-remove")) {
- g_strstrip(arg->rhs->str);
- res = shortcut_remove(c, arg->rhs->str);
- } else if (strstr(arg->name, "shortcut-default")) {
- g_strstrip(arg->rhs->str);
- res = shortcut_set_default(c, arg->rhs->str);
+ switch(arg->code) {
+ case EX_SCA:
+ if ((uri = strchr(arg->rhs->str, '='))) {
+ *uri++ = '\0'; /* devide key and uri */
+ g_strstrip(arg->rhs->str);
+ g_strstrip(uri);
+ success = shortcut_add(c, arg->rhs->str, uri);
+ }
+ break;
+
+ case EX_SCR:
+ g_strstrip(arg->rhs->str);
+ success = shortcut_remove(c, arg->rhs->str);
+ break;
+
+ case EX_SCD:
+ g_strstrip(arg->rhs->str);
+ success = shortcut_set_default(c, arg->rhs->str);
+ break;
+
+ default:
+ break;
}
- return res;
+ return success ? CMD_SUCCESS : CMD_ERROR;
}
/**
From 495727fb19cc83289fa4ba90c91590d28ea7e740 Mon Sep 17 00:00:00 2001
From: Robert Timm
Date: Sun, 26 Feb 2017 00:29:12 +0100
Subject: [PATCH 047/201] fixes (shift)tab cycling through editable elements
---
src/input.c | 3 ++-
src/normal.c | 2 +-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/input.c b/src/input.c
index afa93606..6236c9d7 100644
--- a/src/input.c
+++ b/src/input.c
@@ -38,6 +38,7 @@ void input_enter(Client *c)
* disturbing the user */
gtk_widget_grab_focus(GTK_WIDGET(c->webview));
vb_modelabel_update(c, "-- INPUT --");
+ webkit_web_view_run_javascript(c->webview, "var vimb_input_mode_element = document.activeElement;", NULL, NULL, NULL);
}
/**
@@ -45,7 +46,7 @@ void input_enter(Client *c)
*/
void input_leave(Client *c)
{
- webkit_web_view_run_javascript(c->webview, "document.activeElement.blur();", NULL, NULL, NULL);
+ webkit_web_view_run_javascript(c->webview, "vimb_input_mode_element.blur();", NULL, NULL, NULL);
vb_modelabel_update(c, "");
}
diff --git a/src/normal.c b/src/normal.c
index 7410fb9e..e92de75c 100644
--- a/src/normal.c
+++ b/src/normal.c
@@ -215,7 +215,6 @@ extern struct Vimb vb;
*/
void normal_enter(Client *c)
{
- webkit_web_view_run_javascript(c->webview, "document.activeElement.blur();", NULL, NULL, NULL);
/* Make sure that when the browser area becomes visible, it will get mouse
* and keyboard events */
gtk_widget_grab_focus(GTK_WIDGET(c->webview));
@@ -322,6 +321,7 @@ void pass_enter(Client *c)
*/
void pass_leave(Client *c)
{
+ webkit_web_view_run_javascript(c->webview, "document.activeElement.blur();", NULL, NULL, NULL);
vb_modelabel_update(c, "");
}
From fdb7d1fda3e34590c86579a635da1deafed32307 Mon Sep 17 00:00:00 2001
From: Daniel Carl
Date: Mon, 27 Feb 2017 22:58:24 +0100
Subject: [PATCH 048/201] Don't sort url history completion list.
Also made sorting the default be cause it's less code.
---
src/ex.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/src/ex.c b/src/ex.c
index 7f779507..c3acc0af 100644
--- a/src/ex.c
+++ b/src/ex.c
@@ -1093,31 +1093,27 @@ static gboolean complete(Client *c, short direction)
case EX_OPEN:
case EX_TABOPEN:
/* TODO add bookmark completion if *token == '!' */
+ sort = FALSE;
found = history_fill_completion(store, HISTORY_URL, token);
break;
case EX_SET:
- sort = TRUE;
found = setting_fill_completion(c, store, token);
break;
case EX_BMA:
- sort = TRUE;
/* TODO fill bookmark completion */
break;
case EX_SCR:
- sort = TRUE;
/* TODO fill shortcut completion */
break;
case EX_HANDREM:
- sort = TRUE;
/* TODO fill handler completion */
break;
case EX_SAVE:
- sort = TRUE;
found = util_filename_fill_completion(c, store, token);
break;
@@ -1136,7 +1132,6 @@ static gboolean complete(Client *c, short direction)
if (ex_fill_completion(store, in)) {
OVERWRITE_STRING(excomp.prefix, ":");
found = TRUE;
- sort = FALSE;
}
}
free_cmdarg(arg);
@@ -1145,6 +1140,7 @@ static gboolean complete(Client *c, short direction)
OVERWRITE_STRING(excomp.token, in + 1);
OVERWRITE_NSTRING(excomp.prefix, in, 1);
found = TRUE;
+ sort = FALSE;
}
}
From 2a50746f179af391f6a74c474eecadeed2300e80 Mon Sep 17 00:00:00 2001
From: Robert Timm
Date: Mon, 27 Feb 2017 23:13:40 +0100
Subject: [PATCH 049/201] changes enable-tabs-to-links setting name for
consistency
---
src/setting.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/setting.c b/src/setting.c
index ef23eb75..e45dea3e 100644
--- a/src/setting.c
+++ b/src/setting.c
@@ -116,7 +116,7 @@ void setting_init(Client *c)
setting_add(c, "smooth-scrolling", TYPE_BOOLEAN, &off, webkit, 0, "enable-smooth-scrolling");
#endif
setting_add(c, "spacial-navigation", TYPE_BOOLEAN, &off, webkit, 0, "enable-spatial-navigation");
- setting_add(c, "enable-tabs-to-links", TYPE_BOOLEAN, &on, webkit, 0, "enable-tabs-to-links");
+ setting_add(c, "tabs-to-links", TYPE_BOOLEAN, &on, webkit, 0, "enable-tabs-to-links");
setting_add(c, "webaudio", TYPE_BOOLEAN, &off, webkit, 0, "enable-webaudio");
setting_add(c, "webgl", TYPE_BOOLEAN, &off, webkit, 0, "enable-webgl");
setting_add(c, "webinspector", TYPE_BOOLEAN, &on, webkit, 0, "enable-developer-extras");
From 8b6a89dc070dd33c85eade752eb492bbae6bce89 Mon Sep 17 00:00:00 2001
From: Robert Timm
Date: Mon, 27 Feb 2017 23:26:37 +0100
Subject: [PATCH 050/201] adds ctrl+p and ctrl+n for ex history movement
---
src/ex.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/ex.c b/src/ex.c
index 7f779507..65126fa1 100644
--- a/src/ex.c
+++ b/src/ex.c
@@ -262,11 +262,13 @@ VbResult ex_keypress(Client *c, int key)
complete(c, -1);
break;
- case KEY_UP:
+ case KEY_UP: /* fall through */
+ case CTRL('P'):
history(c, TRUE);
break;
- case KEY_DOWN:
+ case KEY_DOWN: /* fall through */
+ case CTRL('N'):
history(c, FALSE);
break;
From ca8dfe7dee5f4c7474f0723ec65cf9a3978f083e Mon Sep 17 00:00:00 2001
From: Daniel Carl
Date: Tue, 28 Feb 2017 00:09:19 +0100
Subject: [PATCH 051/201] Allow to manage bookmarks and queue.
---
README.md | 12 +-
src/bookmark.c | 329 +++++++++++++++++++++++++++++++++++++++++++++++
src/bookmark.h | 37 ++++++
src/command.c | 45 ++++++-
src/config.def.h | 2 +
src/ex.c | 59 ++++++++-
src/normal.c | 4 +-
src/util.c | 101 +++++++++++++++
src/util.h | 3 +
9 files changed, 578 insertions(+), 14 deletions(-)
create mode 100644 src/bookmark.c
create mode 100644 src/bookmark.h
diff --git a/README.md b/README.md
index ca560715..2eee22ea 100644
--- a/README.md
+++ b/README.md
@@ -104,13 +104,21 @@ project directory.
- [ ] hinting
- [x] searching and matching of search results
- [x] navigation j, k, h, l, ...
- - [ ] history and history lookup
+ - [x] history and history lookup
- [ ] completion
+ - [ ] augroup
+ - [ ] autocmd
+ - [x] bookmarks
+ - [ ] file paths for :source and :save
+ - [x] search phrases
+ - [x] settings
+ - [ ] url handler
+ - [x] url history
- [ ] HSTS
- [ ] auto-response-header
- [x] cookies support
- [x] register support and `:register` command
- - [ ] read it later queue
+ - [x] read it later queue
- [ ] show scroll indicator in statusbar as top, x%, bottom or all
how can we get this information from webview easily?
- [x] find a way to disable the scrollbars on the main frame
diff --git a/src/bookmark.c b/src/bookmark.c
new file mode 100644
index 00000000..110d72d5
--- /dev/null
+++ b/src/bookmark.c
@@ -0,0 +1,329 @@
+/**
+ * vimb - a webkit based vim like browser.
+ *
+ * Copyright (C) 2012-2017 Daniel Carl
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see http://www.gnu.org/licenses/.
+ */
+
+#include
+
+#include "config.h"
+#include "main.h"
+#include "bookmark.h"
+#include "util.h"
+#include "completion.h"
+
+typedef struct {
+ char *uri;
+ char *title;
+ char *tags;
+} Bookmark;
+
+extern struct Vimb vb;
+
+static GList *load(const char *file);
+static gboolean bookmark_contains_all_tags(Bookmark *bm, char **query,
+ unsigned int qlen);
+static Bookmark *line_to_bookmark(const char *uri, const char *data);
+static void free_bookmark(Bookmark *bm);
+
+/**
+ * Write a new bookmark entry to the end of bookmark file.
+ */
+gboolean bookmark_add(const char *uri, const char *title, const char *tags)
+{
+ const char *file = vb.files[FILES_BOOKMARK];
+ if (tags) {
+ return util_file_append(file, "%s\t%s\t%s\n", uri, title ? title : "", tags);
+ }
+ if (title) {
+ return util_file_append(file, "%s\t%s\n", uri, title);
+ }
+ return util_file_append(file, "%s\n", uri);
+}
+
+gboolean bookmark_remove(const char *uri)
+{
+ char **lines, *line, *p;
+ int len, i;
+ GString *new;
+ gboolean removed = false;
+
+ if (!uri) {
+ return false;
+ }
+
+ lines = util_get_lines(vb.files[FILES_BOOKMARK]);
+ if (lines) {
+ new = g_string_new(NULL);
+ len = g_strv_length(lines) - 1;
+ for (i = 0; i < len; i++) {
+ line = lines[i];
+ g_strstrip(line);
+ /* ignore the title or bookmark tags and test only the uri */
+ if ((p = strchr(line, '\t'))) {
+ *p = '\0';
+ if (!strcmp(uri, line)) {
+ removed = true;
+ continue;
+ } else {
+ /* reappend the tags */
+ *p = '\t';
+ }
+ }
+ if (!strcmp(uri, line)) {
+ removed = true;
+ continue;
+ }
+ g_string_append_printf(new, "%s\n", line);
+ }
+ g_strfreev(lines);
+ g_file_set_contents(vb.files[FILES_BOOKMARK], new->str, -1, NULL);
+ g_string_free(new, true);
+ }
+
+ return removed;
+}
+
+gboolean bookmark_fill_completion(GtkListStore *store, const char *input)
+{
+ gboolean found = false;
+ char **parts;
+ unsigned int len;
+ GtkTreeIter iter;
+ GList *src = NULL;
+ Bookmark *bm;
+
+ src = load(vb.files[FILES_BOOKMARK]);
+ src = g_list_reverse(src);
+ if (!input || !*input) {
+ /* without any tags return all bookmarked items */
+ for (GList *l = src; l; l = l->next) {
+ bm = (Bookmark*)l->data;
+ gtk_list_store_append(store, &iter);
+ gtk_list_store_set(
+ store, &iter,
+ COMPLETION_STORE_FIRST, bm->uri,
+#ifdef FEATURE_TITLE_IN_COMPLETION
+ COMPLETION_STORE_SECOND, bm->title,
+#endif
+ -1
+ );
+ found = true;
+ }
+ } else {
+ parts = g_strsplit(input, " ", 0);
+ len = g_strv_length(parts);
+
+ for (GList *l = src; l; l = l->next) {
+ bm = (Bookmark*)l->data;
+ if (bookmark_contains_all_tags(bm, parts, len)) {
+ gtk_list_store_append(store, &iter);
+ gtk_list_store_set(
+ store, &iter,
+ COMPLETION_STORE_FIRST, bm->uri,
+#ifdef FEATURE_TITLE_IN_COMPLETION
+ COMPLETION_STORE_SECOND, bm->title,
+#endif
+ -1
+ );
+ found = true;
+ }
+ }
+ g_strfreev(parts);
+ }
+
+ g_list_free_full(src, (GDestroyNotify)free_bookmark);
+
+ return found;
+}
+
+gboolean bookmark_fill_tag_completion(GtkListStore *store, const char *input)
+{
+ gboolean found;
+ unsigned int len, i;
+ char **tags, *tag;
+ GList *src = NULL, *taglist = NULL;
+ Bookmark *bm;
+
+ /* get all distinct tags from bookmark file */
+ src = load(vb.files[FILES_BOOKMARK]);
+ for (GList *l = src; l; l = l->next) {
+ bm = (Bookmark*)l->data;
+ /* if bookmark contains no tags we can go to the next bookmark */
+ if (!bm->tags) {
+ continue;
+ }
+
+ tags = g_strsplit(bm->tags, " ", -1);
+ len = g_strv_length(tags);
+ for (i = 0; i < len; i++) {
+ tag = tags[i];
+ /* add tag only if it isn't already in the list */
+ if (!g_list_find_custom(taglist, tag, (GCompareFunc)strcmp)) {
+ taglist = g_list_prepend(taglist, g_strdup(tag));
+ }
+ }
+ g_strfreev(tags);
+ }
+
+ /* generate the completion with the found tags */
+ found = util_fill_completion(store, input, taglist);
+
+ g_list_free_full(src, (GDestroyNotify)free_bookmark);
+ g_list_free_full(taglist, (GDestroyNotify)g_free);
+
+ return found;
+}
+
+#ifdef FEATURE_QUEUE
+/**
+ * Push a uri to the end of the queue.
+ *
+ * @uri: URI to put into the queue
+ */
+gboolean bookmark_queue_push(const char *uri)
+{
+ return util_file_append(vb.files[FILES_QUEUE], "%s\n", uri);
+}
+
+/**
+ * Push a uri to the beginning of the queue.
+ *
+ * @uri: URI to put into the queue
+ */
+gboolean bookmark_queue_unshift(const char *uri)
+{
+ return util_file_prepend(vb.files[FILES_QUEUE], "%s\n", uri);
+}
+
+/**
+ * Retrieves the oldest entry from queue.
+ *
+ * @item_count: will be filled with the number of remaining items in queue.
+ * Returned uri must be freed with g_free.
+ */
+char *bookmark_queue_pop(int *item_count)
+{
+ return util_file_pop_line(vb.files[FILES_QUEUE], item_count);
+}
+
+/**
+ * Removes all contents from the queue file.
+ */
+gboolean bookmark_queue_clear(void)
+{
+ FILE *f;
+ if ((f = fopen(vb.files[FILES_QUEUE], "w"))) {
+ fclose(f);
+ return true;
+ }
+ return false;
+}
+#endif /* FEATURE_QUEUE */
+
+static GList *load(const char *file)
+{
+ return util_file_to_unique_list(file, (Util_Content_Func)line_to_bookmark, 0);
+}
+
+/**
+ * Checks if the given bookmark matches all given query strings as prefix. If
+ * the bookmark has no tags, the matching is done on the '/' splited URL.
+ *
+ * @bm: bookmark to test if it matches
+ * @query: char array with tags to search for
+ * @qlen: length of given query char array
+ *
+ * Return: true if the bookmark contained all tags
+ */
+static gboolean bookmark_contains_all_tags(Bookmark *bm, char **query,
+ unsigned int qlen)
+{
+ const char *separators;
+ char *cursor;
+ unsigned int i;
+ gboolean found;
+
+ if (!qlen) {
+ return true;
+ }
+
+ if (bm->tags) {
+ /* If there are tags - use them for matching. */
+ separators = " ";
+ cursor = bm->tags;
+ } else {
+ /* No tags available - matching is based on the path parts of the URL. */
+ separators = "./";
+ cursor = bm->uri;
+ }
+
+ /* iterate over all query parts */
+ for (i = 0; i < qlen; i++) {
+ found = false;
+
+ /* we want to do a prefix match on all bookmark tags - so we check for
+ * a match on string begin - if this fails we move the cursor to the
+ * next space and do the test again */
+ while (cursor && *cursor) {
+ /* match was not found at current cursor position */
+ if (g_str_has_prefix(cursor, query[i])) {
+ found = true;
+ break;
+ }
+ /* If match was not found at the cursor position - move cursor
+ * behind the next separator char. */
+ if ((cursor = strpbrk(cursor, separators))) {
+ cursor++;
+ }
+ }
+
+ if (!found) {
+ return false;
+ }
+ }
+
+ return true;
+}
+
+static Bookmark *line_to_bookmark(const char *uri, const char *data)
+{
+ char *p;
+ Bookmark *bm;
+
+ /* data part may consist of title or titletags */
+ bm = g_slice_new(Bookmark);
+ bm->uri = g_strdup(uri);
+ if (data && (p = strchr(data, '\t'))) {
+ *p = '\0';
+ bm->title = g_strdup(data);
+ bm->tags = g_strdup(p + 1);
+ } else {
+ bm->title = g_strdup(data);
+ bm->tags = NULL;
+ }
+
+ return bm;
+}
+
+static void free_bookmark(Bookmark *bm)
+{
+ g_free(bm->uri);
+ g_free(bm->title);
+ g_free(bm->tags);
+ g_slice_free(Bookmark, bm);
+}
+
diff --git a/src/bookmark.h b/src/bookmark.h
new file mode 100644
index 00000000..dea45568
--- /dev/null
+++ b/src/bookmark.h
@@ -0,0 +1,37 @@
+/**
+ * vimb - a webkit based vim like browser.
+ *
+ * Copyright (C) 2012-2017 Daniel Carl
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see http://www.gnu.org/licenses/.
+ */
+
+#ifndef _BOOKMARK_H
+#define _BOOKMARK_H
+
+#include "main.h"
+
+gboolean bookmark_add(const char *uri, const char *title, const char *tags);
+gboolean bookmark_remove(const char *uri);
+gboolean bookmark_fill_completion(GtkListStore *store, const char *input);
+gboolean bookmark_fill_tag_completion(GtkListStore *store, const char *input);
+#ifdef FEATURE_QUEUE
+gboolean bookmark_queue_push(const char *uri);
+gboolean bookmark_queue_unshift(const char *uri);
+char *bookmark_queue_pop(int *item_count);
+gboolean bookmark_queue_clear(void);
+#endif
+
+#endif /* end of include guard: _BOOKMARK_H */
+
diff --git a/src/command.c b/src/command.c
index 700bd2ce..7fbc8785 100644
--- a/src/command.c
+++ b/src/command.c
@@ -21,11 +21,15 @@
* This file contains functions that are used by normal mode and command mode
* together.
*/
-#include "command.h"
+#include
+
#include "config.h"
+#ifdef FEATURE_QUEUE
+#include "bookmark.h"
+#endif
+#include "command.h"
#include "history.h"
#include "main.h"
-#include
extern struct Vimb vb;
@@ -164,7 +168,40 @@ gboolean command_save(Client *c, const Arg *arg)
#ifdef FEATURE_QUEUE
gboolean command_queue(Client *c, const Arg *arg)
{
- /* TODO no implemented yet */
- return TRUE;
+ gboolean res = FALSE;
+ int count = 0;
+ char *uri;
+
+ switch (arg->i) {
+ case COMMAND_QUEUE_POP:
+ if ((uri = bookmark_queue_pop(&count))) {
+ res = vb_load_uri(c, &(Arg){TARGET_CURRENT, uri});
+ g_free(uri);
+ }
+ vb_echo(c, MSG_NORMAL, FALSE, "Queue length %d", count);
+ break;
+
+ case COMMAND_QUEUE_PUSH:
+ res = bookmark_queue_push(arg->s ? arg->s : c->state.uri);
+ if (res) {
+ vb_echo(c, MSG_NORMAL, FALSE, "Pushed to queue");
+ }
+ break;
+
+ case COMMAND_QUEUE_UNSHIFT:
+ res = bookmark_queue_unshift(arg->s ? arg->s : c->state.uri);
+ if (res) {
+ vb_echo(c, MSG_NORMAL, FALSE, "Pushed to queue");
+ }
+ break;
+
+ case COMMAND_QUEUE_CLEAR:
+ if (bookmark_queue_clear()) {
+ vb_echo(c, MSG_NORMAL, FALSE, "Queue cleared");
+ }
+ break;
+ }
+
+ return res;
}
#endif
diff --git a/src/config.def.h b/src/config.def.h
index 8b2d27b8..37874b7f 100644
--- a/src/config.def.h
+++ b/src/config.def.h
@@ -28,6 +28,8 @@
#define FEATURE_TITLE_IN_COMPLETION
/* support gui style settings compatible with vimb2 */
#define FEATURE_GUI_STYLE_VIMB2_COMPAT
+/* enable the read it later queue */
+#define FEATURE_QUEUE
#ifdef FEATURE_WGET_PROGRESS_BAR
/* chars to use for the progressbar */
diff --git a/src/ex.c b/src/ex.c
index c3acc0af..4ca91530 100644
--- a/src/ex.c
+++ b/src/ex.c
@@ -27,6 +27,7 @@
#include
#include "ascii.h"
+#include "bookmark.h"
#include "command.h"
#include "completion.h"
#include "config.h"
@@ -745,8 +746,19 @@ static void free_cmdarg(ExArg *arg)
static VbCmdResult ex_bookmark(Client *c, const ExArg *arg)
{
- /* TODO no implemented yet */
- return CMD_SUCCESS;
+ if (arg->code == EX_BMR) {
+ if (bookmark_remove(*arg->rhs->str ? arg->rhs->str : c->state.uri)) {
+ vb_echo_force(c, MSG_NORMAL, TRUE, " Bookmark removed");
+
+ return CMD_SUCCESS | CMD_KEEPINPUT;
+ }
+ } else if (bookmark_add(c->state.uri, c->state.title, arg->rhs->str)) {
+ vb_echo_force(c, MSG_NORMAL, TRUE, " Bookmark added");
+
+ return CMD_SUCCESS | CMD_KEEPINPUT;
+ }
+
+ return CMD_ERROR;
}
static VbCmdResult ex_eval(Client *c, const ExArg *arg)
@@ -855,8 +867,38 @@ static VbCmdResult ex_open(Client *c, const ExArg *arg)
#ifdef FEATURE_QUEUE
static VbCmdResult ex_queue(Client *c, const ExArg *arg)
{
- /* TODO no implemented yet */
- return CMD_SUCCESS;
+ Arg a = {0};
+
+ switch (arg->code) {
+ case EX_QPUSH:
+ a.i = COMMAND_QUEUE_PUSH;
+ break;
+
+ case EX_QUNSHIFT:
+ a.i = COMMAND_QUEUE_UNSHIFT;
+ break;
+
+ case EX_QPOP:
+ a.i = COMMAND_QUEUE_POP;
+ break;
+
+ case EX_QCLEAR:
+ a.i = COMMAND_QUEUE_CLEAR;
+ break;
+
+ default:
+ return CMD_ERROR;
+ }
+
+ /* if no argument is found in rhs, keep the uri in arg null to force
+ * command_queue() to use current URI */
+ if (arg->rhs->len) {
+ a.s = arg->rhs->str;
+ }
+
+ return command_queue(c, &a)
+ ? CMD_SUCCESS | CMD_KEEPINPUT
+ : CMD_ERROR | CMD_KEEPINPUT;
}
#endif
@@ -1092,9 +1134,12 @@ static gboolean complete(Client *c, short direction)
switch (arg->code) {
case EX_OPEN:
case EX_TABOPEN:
- /* TODO add bookmark completion if *token == '!' */
sort = FALSE;
- found = history_fill_completion(store, HISTORY_URL, token);
+ if (*token == '!') {
+ found = bookmark_fill_completion(store, token + 1);
+ } else {
+ found = history_fill_completion(store, HISTORY_URL, token);
+ }
break;
case EX_SET:
@@ -1102,7 +1147,7 @@ static gboolean complete(Client *c, short direction)
break;
case EX_BMA:
- /* TODO fill bookmark completion */
+ found = bookmark_fill_tag_completion(store, token);
break;
case EX_SCR:
diff --git a/src/normal.c b/src/normal.c
index e92de75c..faa57331 100644
--- a/src/normal.c
+++ b/src/normal.c
@@ -633,7 +633,9 @@ static VbResult normal_prevnext(Client *c, const NormalCmdInfo *info)
static VbResult normal_queue(Client *c, const NormalCmdInfo *info)
{
- /* TODO run next uri from queu and remove it from */
+#ifdef FEATURE_QUEUE
+ command_queue(c, &((Arg){COMMAND_QUEUE_POP}));
+#endif
return RESULT_COMPLETE;
}
diff --git a/src/util.c b/src/util.c
index be48e711..29557f2b 100644
--- a/src/util.c
+++ b/src/util.c
@@ -104,6 +104,79 @@ gboolean util_file_append(const char *file, const char *format, ...)
return FALSE;
}
+/**
+ * Prepend new data to file.
+ *
+ * @file: File to prepend the data
+ * @format: Format string used to process va_list
+ */
+gboolean util_file_prepend(const char *file, const char *format, ...)
+{
+ gboolean res = false;
+ va_list args;
+ char *content;
+ FILE *f;
+
+ content = util_get_file_contents(file, NULL);
+ if ((f = fopen(file, "w"))) {
+ flock(fileno(f), LOCK_EX);
+
+ va_start(args, format);
+ /* write new content to the file */
+ vfprintf(f, format, args);
+ va_end(args);
+
+ /* append previous file content */
+ fputs(content, f);
+
+ flock(fileno(f), LOCK_UN);
+ fclose(f);
+
+ res = true;
+ }
+ g_free(content);
+
+ return res;
+}
+
+
+/**
+ * Retrieves the first line from file and delete it from file.
+ *
+ * @file: file to read from
+ * @item_count: will be filled with the number of remaining lines in file if it
+ * is not NULL.
+ *
+ * Returned string must be freed with g_free.
+ */
+char *util_file_pop_line(const char *file, int *item_count)
+{
+ char **lines = util_get_lines(file);
+ char *new,
+ *line = NULL;
+ int len,
+ count = 0;
+
+ if (lines) {
+ len = g_strv_length(lines);
+ if (len) {
+ line = g_strdup(lines[0]);
+ /* minus one for last empty item and one for popped item */
+ count = len - 2;
+ new = g_strjoinv("\n", lines + 1);
+ g_file_set_contents(file, new, -1, NULL);
+ g_free(new);
+ }
+ g_strfreev(lines);
+ }
+
+ if (item_count) {
+ *item_count = count;
+ }
+
+ return line;
+}
+
/**
* Retrieves the config directory path.
* Returnes string must be freed.
@@ -259,6 +332,34 @@ GList *util_file_to_unique_list(const char *filename, Util_Content_Func func,
return gl;
}
+/**
+ * Fills the given list store by matching data of also given src list.
+ */
+gboolean util_fill_completion(GtkListStore *store, const char *input, GList *src)
+{
+ gboolean found = false;
+ GtkTreeIter iter;
+
+ if (!input || !*input) {
+ for (GList *l = src; l; l = l->next) {
+ gtk_list_store_append(store, &iter);
+ gtk_list_store_set(store, &iter, COMPLETION_STORE_FIRST, l->data, -1);
+ found = true;
+ }
+ } else {
+ for (GList *l = src; l; l = l->next) {
+ char *value = (char*)l->data;
+ if (g_str_has_prefix(value, input)) {
+ gtk_list_store_append(store, &iter);
+ gtk_list_store_set(store, &iter, COMPLETION_STORE_FIRST, l->data, -1);
+ found = true;
+ }
+ }
+ }
+
+ return found;
+}
+
/**
* Fills file path completion entries into given list store for also given
* input.
diff --git a/src/util.h b/src/util.h
index 94a60ca7..ca9ba68c 100644
--- a/src/util.h
+++ b/src/util.h
@@ -33,12 +33,15 @@ typedef void *(*Util_Content_Func)(const char*, const char*);
void util_cleanup(void);
char *util_expand(Client *c, const char *src, int expflags);
gboolean util_file_append(const char *file, const char *format, ...);
+gboolean util_file_prepend(const char *file, const char *format, ...);
+char *util_file_pop_line(const char *file, int *item_count);
char *util_get_config_dir(void);
char *util_get_file_contents(const char *filename, gsize *length);
char *util_get_filepath(const char *dir, const char *filename, gboolean create);
char **util_get_lines(const char *filename);
GList *util_file_to_unique_list(const char *filename, Util_Content_Func func,
guint max_items);
+gboolean util_fill_completion(GtkListStore *store, const char *input, GList *src);
gboolean util_filename_fill_completion(Client *c, GtkListStore *store, const char *input);
gboolean util_parse_expansion(Client *c, const char **input, GString *str,
int flags, const char *quoteable);
From 9bac99eb3a6f818aee67ef37573a7fdc2a73661d Mon Sep 17 00:00:00 2001
From: Joachim Desroches
Date: Tue, 28 Feb 2017 16:38:58 +0100
Subject: [PATCH 052/201] Add :source command back.
---
src/ex.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/src/ex.c b/src/ex.c
index 5e1afcea..42438cef 100644
--- a/src/ex.c
+++ b/src/ex.c
@@ -72,6 +72,7 @@ typedef enum {
EX_SCR,
EX_SET,
EX_SHELLCMD,
+ EX_SOURCE,
EX_TABOPEN,
} ExCode;
@@ -140,6 +141,7 @@ static VbCmdResult ex_save(Client *c, const ExArg *arg);
static VbCmdResult ex_set(Client *c, const ExArg *arg);
static VbCmdResult ex_shellcmd(Client *c, const ExArg *arg);
static VbCmdResult ex_shortcut(Client *c, const ExArg *arg);
+static VbCmdResult ex_source(Client *c, const ExArg *arg);
static VbCmdResult ex_handlers(Client *c, const ExArg *arg);
static gboolean complete(Client *c, short direction);
@@ -186,6 +188,7 @@ static ExInfo commands[] = {
{"shortcut-add", EX_SCA, ex_shortcut, EX_FLAG_RHS},
{"shortcut-default", EX_SCD, ex_shortcut, EX_FLAG_RHS},
{"shortcut-remove", EX_SCR, ex_shortcut, EX_FLAG_RHS},
+ {"source", EX_SOURCE, ex_source, EX_FLAG_RHS|EX_FLAG_EXP},
{"tabopen", EX_TABOPEN, ex_open, EX_FLAG_CMD},
};
@@ -1049,6 +1052,11 @@ static VbCmdResult ex_shortcut(Client *c, const ExArg *arg)
return success ? CMD_SUCCESS : CMD_ERROR;
}
+static VbCmdResult ex_source(Client *c, const ExArg *arg)
+{
+ return ex_run_file(c, arg->rhs->str);
+}
+
/**
* Manage the generation and stepping through completions.
* This function prepared some prefix and suffix string that are required to
@@ -1160,7 +1168,8 @@ static gboolean complete(Client *c, short direction)
/* TODO fill handler completion */
break;
- case EX_SAVE:
+ case EX_SAVE: /* Fallthrough */
+ case EX_SOURCE:
found = util_filename_fill_completion(c, store, token);
break;
From 650561c71a7cd8a19d6a231e5c31e993b061ada8 Mon Sep 17 00:00:00 2001
From: Joachim Desroches
Date: Tue, 28 Feb 2017 16:39:38 +0100
Subject: [PATCH 053/201] Add documentation for the :source command back.
---
doc/vimb.1 | 3 +++
1 file changed, 3 insertions(+)
diff --git a/doc/vimb.1 b/doc/vimb.1
index bf780c60..e3b9dee6 100644
--- a/doc/vimb.1
+++ b/doc/vimb.1
@@ -517,6 +517,9 @@ If \fIpath\fP is given, download under this file name or path.
\fIpath\fP is expanded and can therefore contain '~/', '${ENV}'
and '~user' pattern.
.TP
+.BI ":so[urce] [" file "]"
+Read ex commands from \fIfile\fP.
+.TP
.B :q[uit]
Close the browser.
This will be refused if there are running downloads.
From 13b0f1b3b43a609177c7822da6c3f713de52ec0f Mon Sep 17 00:00:00 2001
From: Daniel Carl
Date: Wed, 1 Mar 2017 23:24:16 +0100
Subject: [PATCH 054/201] Marked file path completion as done.
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 2eee22ea..f04c8603 100644
--- a/README.md
+++ b/README.md
@@ -109,7 +109,7 @@ project directory.
- [ ] augroup
- [ ] autocmd
- [x] bookmarks
- - [ ] file paths for :source and :save
+ - [x] file paths for :source and :save
- [x] search phrases
- [x] settings
- [ ] url handler
From 32052a688b646ab4a18c7fb7987c1f1025257d54 Mon Sep 17 00:00:00 2001
From: Daniel Carl
Date: Thu, 2 Mar 2017 00:01:42 +0100
Subject: [PATCH 055/201] Cleanup settings on quit.
---
src/main.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/main.c b/src/main.c
index f7187ce3..904bf19a 100644
--- a/src/main.c
+++ b/src/main.c
@@ -485,6 +485,7 @@ static void client_destroy(Client *c)
completion_cleanup(c);
map_cleanup(c);
register_cleanup(c);
+ setting_cleanup(c);
g_slice_free(Client, c);
From af741e150987c1e5ce04a0c6c875b7e629b3b48a Mon Sep 17 00:00:00 2001
From: Daniel Carl
Date: Thu, 2 Mar 2017 00:54:22 +0100
Subject: [PATCH 056/201] Added url file handlers.
Allow to set protocol handlers via :handler-add that process url
protocol like mailto: by using a specific tool.
---
README.md | 4 +--
doc/vimb.1 | 22 ++++++++++++
src/ex.c | 25 +++++++++++--
src/handler.c | 99 +++++++++++++++++++++++++++++++++++++++++++++++++++
src/handler.h | 31 ++++++++++++++++
src/main.c | 32 +++++++++++------
src/main.h | 3 ++
7 files changed, 200 insertions(+), 16 deletions(-)
create mode 100644 src/handler.c
create mode 100644 src/handler.h
diff --git a/README.md b/README.md
index f04c8603..e9494210 100644
--- a/README.md
+++ b/README.md
@@ -112,7 +112,7 @@ project directory.
- [x] file paths for :source and :save
- [x] search phrases
- [x] settings
- - [ ] url handler
+ - [x] url handler
- [x] url history
- [ ] HSTS
- [ ] auto-response-header
@@ -131,7 +131,7 @@ project directory.
- [x] default zoom
- [x] yanking
- [x] keymapping
- - [ ] URL handler
+ - [x] URL handler
- [x] shortcuts
- [ ] autocommands and augroups
3. documentation
diff --git a/doc/vimb.1 b/doc/vimb.1
index e3b9dee6..92f64798 100644
--- a/doc/vimb.1
+++ b/doc/vimb.1
@@ -396,6 +396,28 @@ Save the current opened URI with \fItags\fP to the bookmark file.
.BI ":bmr [" URI ]
Removes all bookmarks for given \fIURI\fP or, if not given, the current opened
page.
+.SS Handlers
+Handlers allow specifying external scripts to handle alternative URI methods.
+.TP
+.BI ":handler-add " "handler" "=" "cmd"
+Adds a handler to direct \fIhandler\fP links to the external \fIcmd\fP.
+The \fIcmd\fP can contain one placeholder `%s` that will be filled by the
+full URI given when the command is called.
+.RS
+.P
+Examples:
+.PD 0
+.IP ":handler-add mailto=urxvt -e mutt %s"
+to start email client for mailto links.
+.IP ":handler-add magnet=xdg-open %s"
+to open magnet links with xdg-open.
+.IP ":handler-add ftp=urxvt -e wget %s -P ~/ftp-downloads"
+to handle ftp downloads via wget.
+.PD
+.RE
+.TP
+.BI ":handler-remove " "handler"
+Remove the handler for the given URI \fIhandler\fP.
.SS Shortcuts
Shortcuts allow the opening of an URI built up from a named template with additional
parameters.
diff --git a/src/ex.c b/src/ex.c
index 42438cef..eaa97cb1 100644
--- a/src/ex.c
+++ b/src/ex.c
@@ -32,6 +32,7 @@
#include "completion.h"
#include "config.h"
#include "ex.h"
+#include "handler.h"
#include "history.h"
#include "main.h"
#include "map.h"
@@ -1008,8 +1009,26 @@ static VbCmdResult ex_shellcmd(Client *c, const ExArg *arg)
static VbCmdResult ex_handlers(Client *c, const ExArg *arg)
{
- /* TODO no implemented yet */
- return CMD_SUCCESS;
+ char *p;
+ gboolean res = FALSE;
+
+ switch (arg->code) {
+ case EX_HANDADD:
+ if (arg->rhs->len && (p = strchr(arg->rhs->str, '='))) {
+ *p++ = '\0';
+ res = handler_add(c, arg->rhs->str, p);
+ }
+ break;
+
+ case EX_HANDREM:
+ res = handler_remove(c, arg->rhs->str);
+ break;
+
+ default:
+ break;
+ }
+
+ return res ? CMD_SUCCESS : CMD_ERROR;
}
static VbCmdResult ex_shortcut(Client *c, const ExArg *arg)
@@ -1165,7 +1184,7 @@ static gboolean complete(Client *c, short direction)
break;
case EX_HANDREM:
- /* TODO fill handler completion */
+ found = handler_fill_completion(c, store, token);
break;
case EX_SAVE: /* Fallthrough */
diff --git a/src/handler.c b/src/handler.c
new file mode 100644
index 00000000..6cde8888
--- /dev/null
+++ b/src/handler.c
@@ -0,0 +1,99 @@
+/**
+ * vimb - a webkit based vim like browser.
+ *
+ * Copyright (C) 2012-2017 Daniel Carl
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see http://www.gnu.org/licenses/.
+ */
+
+#include
+
+#include "main.h"
+#include "handler.h"
+#include "util.h"
+
+extern struct Vimb vb;
+
+static char *handler_lookup(Client *c, const char *uri);
+
+void handler_init(Client *c)
+{
+ c->handlers.table = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
+}
+
+void handler_cleanup(Client *c)
+{
+ if (c->handlers.table) {
+ g_hash_table_destroy(c->handlers.table);
+ c->handlers.table = NULL;
+ }
+}
+
+gboolean handler_add(Client *c, const char *key, const char *cmd)
+{
+ g_hash_table_insert(c->handlers.table, g_strdup(key), g_strdup(cmd));
+
+ return true;
+}
+
+gboolean handler_remove(Client *c, const char *key)
+{
+ return g_hash_table_remove(c->handlers.table, key);
+}
+
+gboolean handler_handle_uri(Client *c, const char *uri)
+{
+ char *handler, *cmd;
+ GError *error = NULL;
+ gboolean res;
+
+ if (!(handler = handler_lookup(c, uri))) {
+ return FALSE;
+ }
+
+ cmd = g_strdup_printf(handler, uri);
+ if (!g_spawn_command_line_async(cmd, &error)) {
+ g_warning("Can't run '%s': %s", cmd, error->message);
+ g_clear_error(&error);
+ res = FALSE;
+ } else {
+ res = TRUE;
+ }
+
+ g_free(cmd);
+ return res;
+}
+
+gboolean handler_fill_completion(Client *c, GtkListStore *store, const char *input)
+{
+ GList *src = g_hash_table_get_keys(c->handlers.table);
+ gboolean found = util_fill_completion(store, input, src);
+ g_list_free(src);
+
+ return found;
+}
+
+static char *handler_lookup(Client *c, const char *uri)
+{
+ char *p, *schema, *handler = NULL;
+
+ if ((p = strchr(uri, ':'))) {
+ schema = g_strndup(uri, p - uri);
+ handler = g_hash_table_lookup(c->handlers.table, schema);
+ g_free(schema);
+ }
+
+ return handler;
+}
+
diff --git a/src/handler.h b/src/handler.h
new file mode 100644
index 00000000..ce16bdf4
--- /dev/null
+++ b/src/handler.h
@@ -0,0 +1,31 @@
+/**
+ * vimb - a webkit based vim like browser.
+ *
+ * Copyright (C) 2012-2017 Daniel Carl
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see http://www.gnu.org/licenses/.
+ */
+
+#ifndef _HANDLERS_H
+#define _HANDLERS_H
+
+void handler_init(Client *c);
+void handler_cleanup(Client *c);
+gboolean handler_add(Client *c, const char *key, const char *cmd);
+gboolean handler_remove(Client *c, const char *key);
+gboolean handler_handle_uri(Client *c, const char *uri);
+gboolean handler_fill_completion(Client *c, GtkListStore *store, const char *input);
+
+#endif /* end of include guard: _HANDLERS_H */
+
diff --git a/src/main.c b/src/main.c
index 904bf19a..53fbc154 100644
--- a/src/main.c
+++ b/src/main.c
@@ -32,6 +32,7 @@
#include "config.h"
#include "ex.h"
#include "ext-proxy.h"
+#include "handler.h"
#include "input.h"
#include "js.h"
#include "main.h"
@@ -486,6 +487,7 @@ static void client_destroy(Client *c)
map_cleanup(c);
register_cleanup(c);
setting_cleanup(c);
+ handler_cleanup(c);
g_slice_free(Client, c);
@@ -586,6 +588,9 @@ static Client *client_new(WebKitWebView *webview)
/* initialize the settings */
setting_init(c);
+ /* initialize the url handlers */
+ handler_init(c);
+
/* start client in normal mode */
vb_enter(c, 'n');
@@ -956,24 +961,29 @@ static WebKitWebView *on_webview_create(WebKitWebView *webview,
static gboolean on_webview_decide_policy(WebKitWebView *webview,
WebKitPolicyDecision *dec, WebKitPolicyDecisionType type, Client *c)
{
- guint status;
+ guint status, button, mod;
WebKitNavigationAction *a;
WebKitURIRequest *req;
WebKitURIResponse *res;
switch (type) {
case WEBKIT_POLICY_DECISION_TYPE_NAVIGATION_ACTION:
- a = webkit_navigation_policy_decision_get_navigation_action(WEBKIT_NAVIGATION_POLICY_DECISION(dec));
- req = webkit_navigation_action_get_request(a);
+ a = webkit_navigation_policy_decision_get_navigation_action(WEBKIT_NAVIGATION_POLICY_DECISION(dec));
+ req = webkit_navigation_action_get_request(a);
+ button = webkit_navigation_action_get_mouse_button(a);
+ mod = webkit_navigation_action_get_modifiers(a);
- if (webkit_navigation_action_get_navigation_type(a) == WEBKIT_NAVIGATION_TYPE_LINK_CLICKED) {
- if (webkit_navigation_action_get_mouse_button(a) == 2
- || (webkit_navigation_action_get_mouse_button(a) == 1
- && webkit_navigation_action_get_modifiers(a) & GDK_CONTROL_MASK)) {
- webkit_policy_decision_ignore(dec);
- spawn_new_instance(webkit_uri_request_get_uri(req), TRUE);
- return TRUE;
- }
+ /* Try to handle with specific protocol handler. */
+ if (handler_handle_uri(c, webkit_uri_request_get_uri(req))) {
+ webkit_policy_decision_ignore(dec);
+ return TRUE;
+ }
+ if (webkit_navigation_action_get_navigation_type(a) == WEBKIT_NAVIGATION_TYPE_LINK_CLICKED
+ && (button == 2 || (button == 1 && mod & GDK_CONTROL_MASK))) {
+
+ webkit_policy_decision_ignore(dec);
+ spawn_new_instance(webkit_uri_request_get_uri(req), TRUE);
+ return TRUE;
}
return FALSE;
diff --git a/src/main.h b/src/main.h
index 212cd38e..59e1fbbc 100644
--- a/src/main.h
+++ b/src/main.h
@@ -244,6 +244,9 @@ struct Client {
GHashTable *table;
char *fallback; /* default shortcut to use if none given in request */
} shortcut;
+ struct {
+ GHashTable *table; /* holds the protocol handlers */
+ } handlers;
};
struct Vimb {
From 5bd0cba16eade607ff6298e2ff8ab6511defca7c Mon Sep 17 00:00:00 2001
From: Daniel Carl
Date: Thu, 2 Mar 2017 01:10:12 +0100
Subject: [PATCH 057/201] Added completion for shortcuts.
Completion for shortcuts are now available for :shortcut-remove and
:shortcut-default.
---
src/ex.c | 5 +++--
src/shortcut.c | 4 +---
src/shortcut.h | 2 +-
3 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/src/ex.c b/src/ex.c
index eaa97cb1..cc4bdbe9 100644
--- a/src/ex.c
+++ b/src/ex.c
@@ -1179,8 +1179,9 @@ static gboolean complete(Client *c, short direction)
found = bookmark_fill_tag_completion(store, token);
break;
- case EX_SCR:
- /* TODO fill shortcut completion */
+ case EX_SCR: /* Fallthrough */
+ case EX_SCD:
+ found = shortcut_fill_completion(c, store, token);
break;
case EX_HANDREM:
diff --git a/src/shortcut.c b/src/shortcut.c
index 7545037e..af858ab0 100644
--- a/src/shortcut.c
+++ b/src/shortcut.c
@@ -157,8 +157,7 @@ char *shortcut_get_uri(Client *c, const char *string)
return uri;
}
-#if 0
-gboolean shortcut_fill_completion(GtkListStore *store, const char *input)
+gboolean shortcut_fill_completion(Client *c, GtkListStore *store, const char *input)
{
GList *src = g_hash_table_get_keys(c->shortcut.table);
gboolean found = util_fill_completion(store, input, src);
@@ -166,7 +165,6 @@ gboolean shortcut_fill_completion(GtkListStore *store, const char *input)
return found;
}
-#endif
/**
* Retrieves th highest placeholder number used in given string.
diff --git a/src/shortcut.h b/src/shortcut.h
index 9b44e29f..21e21ff1 100644
--- a/src/shortcut.h
+++ b/src/shortcut.h
@@ -26,7 +26,7 @@ gboolean shortcut_add(Client *c, const char *key, const char *uri);
gboolean shortcut_remove(Client *c, const char *key);
gboolean shortcut_set_default(Client *c, const char *key);
char *shortcut_get_uri(Client *c, const char *key);
-/*gboolean shortcut_fill_completion(Client *c, GtkListStore *store, const char *input);*/
+gboolean shortcut_fill_completion(Client *c, GtkListStore *store, const char *input);
#endif /* end of include guard: _SHORTCUT_H */
From 9e050c62475775d53d6d3ded39dee66e72f9eb68 Mon Sep 17 00:00:00 2001
From: Daniel Carl
Date: Thu, 2 Mar 2017 21:33:41 +0100
Subject: [PATCH 058/201] Added manual test pages for focus/blur issues.
---
tests/manual/editable-focus-in-iframe.html | 9 +++++
tests/manual/editable-focus.html | 41 ++++++++++++++++++++++
2 files changed, 50 insertions(+)
create mode 100644 tests/manual/editable-focus-in-iframe.html
create mode 100644 tests/manual/editable-focus.html
diff --git a/tests/manual/editable-focus-in-iframe.html b/tests/manual/editable-focus-in-iframe.html
new file mode 100644
index 00000000..46fffe0b
--- /dev/null
+++ b/tests/manual/editable-focus-in-iframe.html
@@ -0,0 +1,9 @@
+
+
+Track Focu/Blur also within iFrames
+
+
+
+
+
+
diff --git a/tests/manual/editable-focus.html b/tests/manual/editable-focus.html
new file mode 100644
index 00000000..e3cc0f55
--- /dev/null
+++ b/tests/manual/editable-focus.html
@@ -0,0 +1,41 @@
+
+
+Input mode Switching
+
+
+
+
+ Run with scripts=on and strict-focus=off
+
+
If page is loade, vimb should be in input mode.
+
Set strict-focus=on and reload page. Vimb should keep
+ in normal mode
+
Independent from the strict-focus should vimb switch
+ to input mode if the button is clicked
+
+
+
+
+ Also the following element using contenteditable="true"
+ should switch vimb into input mode on click.
+
+
+ Clicking this element using contenteditable="true" should
+ switch vimb into input mode too.
+
+
+
+
From 94f67dc4468f3d1151d5174b8af9d5c5bcc760a8 Mon Sep 17 00:00:00 2001
From: Daniel Carl
Date: Thu, 2 Mar 2017 21:40:56 +0100
Subject: [PATCH 059/201] Simplified test page javascript.
---
tests/manual/editable-focus.html | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tests/manual/editable-focus.html b/tests/manual/editable-focus.html
index e3cc0f55..5c0d123c 100644
--- a/tests/manual/editable-focus.html
+++ b/tests/manual/editable-focus.html
@@ -24,7 +24,7 @@