Compare commits
No commits in common. "8d871b20b8af79d380a55e7c2f2e79eb5314d6aa" and "9a843e614d27c3aaf6e25974cfb5d1229bc2b968" have entirely different histories.
8d871b20b8
...
9a843e614d
26
command.fnl
26
command.fnl
@ -5,36 +5,22 @@
|
|||||||
|
|
||||||
(local Buffer (require :buffer))
|
(local Buffer (require :buffer))
|
||||||
|
|
||||||
(fn by-pairs [a]
|
(fn define-command [name function params]
|
||||||
(let [iter (fn [_ a]
|
|
||||||
(match a
|
|
||||||
[k v & rest] (values rest k v)
|
|
||||||
_ nil))]
|
|
||||||
(values iter a a)))
|
|
||||||
|
|
||||||
(fn define-command [name function ordered-params]
|
|
||||||
;; required parameter names and default arguments
|
;; required parameter names and default arguments
|
||||||
(let [param-names (icollect [_ name val (by-pairs ordered-params)]
|
(let [v {:name name :function function :params params}]
|
||||||
name)
|
|
||||||
params (collect [_ name val (by-pairs ordered-params)]
|
|
||||||
(values name val))
|
|
||||||
v {: name
|
|
||||||
: function
|
|
||||||
: param-names
|
|
||||||
: params}]
|
|
||||||
(tset commands name v)))
|
(tset commands name v)))
|
||||||
|
|
||||||
(define-command
|
(define-command
|
||||||
"quit-browser"
|
"quit-browser"
|
||||||
#(Gtk.main_quit) [])
|
#(Gtk.main_quit) {})
|
||||||
|
|
||||||
(define-command
|
(define-command
|
||||||
"visit-location"
|
"visit-location"
|
||||||
(fn [{:url url :buffer buffer}]
|
(fn [{:url url :buffer buffer}]
|
||||||
(let [b (Buffer.find buffer)] (: b :visit url)))
|
(let [b (Buffer.find buffer)] (: b :visit url)))
|
||||||
[:buffer (fn [] (. (Buffer.current) :name))
|
{:buffer (fn [] (. (Buffer.current) :name))
|
||||||
:url #(do "http://www.example.com")
|
:url #(do "http://www.example.com")
|
||||||
])
|
})
|
||||||
|
|
||||||
(fn find-command [name]
|
(fn find-command [name]
|
||||||
(. commands name))
|
(. commands name))
|
||||||
@ -52,7 +38,7 @@
|
|||||||
|
|
||||||
(fn next-param [command params]
|
(fn next-param [command params]
|
||||||
(accumulate [v nil
|
(accumulate [v nil
|
||||||
_ k (ipairs command.param-names)
|
k _ (pairs command.params)
|
||||||
&until v]
|
&until v]
|
||||||
(if (. params k) nil k)))
|
(if (. params k) nil k)))
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
}:
|
}:
|
||||||
let pname = "dunlin";
|
let pname = "dunlin";
|
||||||
lua = lua5_3.withPackages (ps: with ps; [
|
lua = lua5_3.withPackages (ps: with ps; [
|
||||||
|
inspect
|
||||||
lgi
|
lgi
|
||||||
luafilesystem
|
luafilesystem
|
||||||
luaposix
|
luaposix
|
||||||
@ -32,7 +33,7 @@ in stdenv.mkDerivation rec {
|
|||||||
fennel = fennel_;
|
fennel = fennel_;
|
||||||
|
|
||||||
version = "0.1";
|
version = "0.1";
|
||||||
src = lib.sources.cleanSource ./.;
|
src =./.;
|
||||||
|
|
||||||
GIO_EXTRA_MODULES = glib_networking_gio;
|
GIO_EXTRA_MODULES = glib_networking_gio;
|
||||||
|
|
||||||
|
@ -22,9 +22,8 @@ like:
|
|||||||
* watch a local html file and reload when it changes
|
* watch a local html file and reload when it changes
|
||||||
* find the open tab for my home Fediverse instance (or open one if
|
* find the open tab for my home Fediverse instance (or open one if
|
||||||
needed) and post a message/share a link to what I'm looking at
|
needed) and post a message/share a link to what I'm looking at
|
||||||
* search the {Lua reference, Ruby docs, GTK docs} for a given term
|
* search the {Lua reference, Ruby docs, GTK docs} for term instead of
|
||||||
instead of wading through the SEO cesspool that is the internet in
|
wading through the SEO cesspool that is the internet in 2022
|
||||||
2022
|
|
||||||
* search in previously "liked" pages for the thing I found three weeks
|
* search in previously "liked" pages for the thing I found three weeks
|
||||||
ago, instead of ... ditto
|
ago, instead of ... ditto
|
||||||
* find the tab that's playing music and pause the player (instead of
|
* find the tab that's playing music and pause the player (instead of
|
||||||
|
@ -27,6 +27,14 @@
|
|||||||
:orientation Gtk.Orientation.VERTICAL
|
:orientation Gtk.Orientation.VERTICAL
|
||||||
})
|
})
|
||||||
]
|
]
|
||||||
|
(tset Command.widget :on_activate
|
||||||
|
(fn [event]
|
||||||
|
(let [result (Command.on-input event.text)]
|
||||||
|
(set Command.widget.placeholder_text
|
||||||
|
(or result.prompt ""))
|
||||||
|
(set Command.widget.sensitive result.active)
|
||||||
|
(set Command.widget.text
|
||||||
|
(or result.default result.error "")))))
|
||||||
|
|
||||||
(tset window :on_key_release_event
|
(tset window :on_key_release_event
|
||||||
(fn [window event]
|
(fn [window event]
|
||||||
|
63
musing.md
63
musing.md
@ -1,10 +1,41 @@
|
|||||||
# Braindump
|
what if ... a web browser, but tabs were more like emacs buffers?
|
||||||
|
|
||||||
This is a combination of a thinking-out-loud document and a TODO list.
|
buffer attributes:
|
||||||
It is not a document of record. You should not expect to derive value
|
- url
|
||||||
from reading it
|
- viewport (this is a departure from the emacs buffer)
|
||||||
|
|
||||||
tl;dr what if ... a web browser, but tabs were more like emacs buffers?
|
## commands
|
||||||
|
|
||||||
|
A command is a description of a function that may be invoked
|
||||||
|
interactively, and the parameters it expects.
|
||||||
|
|
||||||
|
```fennel
|
||||||
|
(define-command "visit-location"
|
||||||
|
visit-location
|
||||||
|
{:url Type.Url input-from-minibuffer})
|
||||||
|
|
||||||
|
;; hit "g" and then enter the location in the minibuffer
|
||||||
|
(bind-key "g" (command "visit-location"))
|
||||||
|
;; hit "h" to go straight to your home page
|
||||||
|
(bind-key "h" (command "visit-location")
|
||||||
|
{:url (Type.Url "https://home.example.com")})
|
||||||
|
;; left mouse click on minibuffer hit "h" to go straight to your home page
|
||||||
|
(bind-event Dunlin.minibuffer :button-1-click (command "visit-location"))
|
||||||
|
```
|
||||||
|
|
||||||
|
when it is run from the command prompt, each parameter is
|
||||||
|
prompted, with appropriate defaults.
|
||||||
|
|
||||||
|
when it is bound to a key chord/sequence, the binding may specify
|
||||||
|
where it gets its parameters from - otherise
|
||||||
|
|
||||||
|
visit-location
|
||||||
|
visit-location-in-new-buffer
|
||||||
|
run-command
|
||||||
|
back
|
||||||
|
switch-to-buffer
|
||||||
|
save-file
|
||||||
|
save-link
|
||||||
|
|
||||||
## objects/data types
|
## objects/data types
|
||||||
|
|
||||||
@ -16,8 +47,6 @@ buffer
|
|||||||
add some kind of webview reuse so that invisible and old buffers
|
add some kind of webview reuse so that invisible and old buffers
|
||||||
don't need to have a webview until needed.
|
don't need to have a webview until needed.
|
||||||
|
|
||||||
I seem to be using "buffer" and "tab" mostly synonymously
|
|
||||||
|
|
||||||
frame
|
frame
|
||||||
Frame.the-frame
|
Frame.the-frame
|
||||||
frame.set-buffer (buffer)
|
frame.set-buffer (buffer)
|
||||||
@ -25,25 +54,15 @@ frame
|
|||||||
frame.commander - text entry widget
|
frame.commander - text entry widget
|
||||||
frame.actions - container of toolbar buttons
|
frame.actions - container of toolbar buttons
|
||||||
|
|
||||||
in future we may be able to split a frame into multiple windows
|
|
||||||
which show different buffers
|
|
||||||
|
|
||||||
location (url)
|
location (url)
|
||||||
document
|
document
|
||||||
document element(?)
|
document element(?)
|
||||||
webview
|
webview
|
||||||
lua's standard types
|
lua's standard types
|
||||||
|
|
||||||
## next steps
|
|
||||||
|
|
||||||
* change define-command so that the parameters are ordered
|
# getting started
|
||||||
* display unbound key error
|
|
||||||
* ESC to cancel interactive command
|
gtk stuffz for frame/commander/initial buffer
|
||||||
* autocomplete command name
|
command parser hooked to commander
|
||||||
* parameters with non-string values (e.g. buffer)
|
visit-location command
|
||||||
* show current url when command inactive
|
|
||||||
* show prompts for parameter
|
|
||||||
* multiple buffers
|
|
||||||
- create buffer
|
|
||||||
- list buffers (where does the output go?)
|
|
||||||
- find and switch to buffer
|
|
||||||
|
@ -5,12 +5,12 @@
|
|||||||
(var happened false)
|
(var happened false)
|
||||||
(fn before [] (set happened false) (Command.reset-state))
|
(fn before [] (set happened false) (Command.reset-state))
|
||||||
|
|
||||||
(Command.define-command "no-args-command" #(set happened true) [])
|
(Command.define-command "no-args-command" #(set happened true))
|
||||||
|
|
||||||
(Command.define-command
|
(Command.define-command
|
||||||
"multiply"
|
"multiply"
|
||||||
(fn [{: a : b }] (set happened (* (tonumber a) (tonumber b))))
|
(fn [{: a : b }] (set happened (* (tonumber a) (tonumber b))))
|
||||||
[:a #(do "3") :b #(do "2")])
|
{:a #(do "3") :b #(do "2")})
|
||||||
|
|
||||||
(before)
|
(before)
|
||||||
(let [(ok err)
|
(let [(ok err)
|
||||||
|
Loading…
Reference in New Issue
Block a user