about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--doc/config.md22
-rw-r--r--res/config.toml6
-rw-r--r--src/local/pager.nim19
3 files changed, 36 insertions, 11 deletions
diff --git a/doc/config.md b/doc/config.md
index e0208e16..64ed6a44 100644
--- a/doc/config.md
+++ b/doc/config.md
@@ -879,13 +879,29 @@ from the document's last line.</td>
 
 <tr>
 <td>`pager.load(url)`</td>
-<td>Go to the specified URL. Opens a prompt with the current URL when no
-parameters are specified; otherwise, the string passed is displayed in
-the prompt. If this string ends with a newline
+<td>Put the specified address into the URL bar, and optionally load it.<br>
+Note that this performs auto-expansion of URLs, so Chawan will expand any
+matching omni-rules (e.g. search), try to open schemeless URLs with the default
+scheme/local files, etc.<br>
+Opens a prompt with the current URL when no parameters are specified; otherwise,
+the string passed is displayed in the prompt. If this string ends with a newline
 (e.g. `pager.load("about:chawan\n")`), the URL is loaded directly.</td>
 </tr>
 
 <tr>
+<td>`pager.loadSubmit(url)`</td>
+<td>Act as if `url` had been input into the address bar.<br>
+Same as `pager.load(url + "\n")`.</td>
+</tr>
+
+<tr>
+<td>`pager.gotoURL(url)`</td>
+<td>Go to the specified URL immediately (without a prompt). This differs from
+`load` and `loadSubmit` in that it *does not* try to correct the URL.<br>
+Use this for loading automatically retrieved (i.e. non-user-provided) URLs.</td>
+</tr>
+
+<tr>
 <td>`pager.dupeBuffer()`</td>
 <td>Duplicate the current buffer by loading its source to a new buffer.</td>
 </tr>
diff --git a/res/config.toml b/res/config.toml
index 7fed5b93..f4787eed 100644
--- a/res/config.toml
+++ b/res/config.toml
@@ -150,11 +150,11 @@ K = 'n => pager.scrollUp(n)'
 ')' = 'n => pager.scrollRight(n)'
 C-m = 'pager.click()'
 C-j = 'pager.click()'
-I = 'pager.load(pager.hoverImage + "\n")'
+I = 'pager.gotoURL(pager.hoverImage)'
 M-u = 'pager.dupeBuffer()'
 C-l = 'pager.load()'
 C-k = 'pager.load("ddg:")'
-M-b = 'pager.load("~/.w3m/bookmark.html\n")'
+M-b = 'pager.loadSubmit("~/.w3m/bookmark.html")'
 U = 'pager.reload()'
 r = 'pager.redraw()'
 R = 'pager.reshape()'
@@ -246,7 +246,7 @@ M-p = '''
 	if (s === null)
 		pager.alert("Failed to read URL from clipboard. (Is xsel installed?)");
 	else
-		pager.load(s + '\n');
+		pager.loadSubmit(s);
 }
 '''
 
diff --git a/src/local/pager.nim b/src/local/pager.nim
index a1ebaeb8..f74cf798 100644
--- a/src/local/pager.nim
+++ b/src/local/pager.nim
@@ -23,6 +23,7 @@ import extern/stdio
 import extern/tempfile
 import io/promise
 import io/socketstream
+import js/error
 import js/javascript
 import js/jstypes
 import js/regex
@@ -886,15 +887,23 @@ proc updateReadLine*(pager: Pager) =
     if pager.lineedit.get == lineedit:
       pager.clearLineEdit()
 
+# Same as load(s + '\n')
+proc loadSubmit(pager: Pager, s: string) {.jsfunc.} =
+  pager.loadURL(s)
+
 # Open a URL prompt and visit the specified URL.
 proc load(pager: Pager, s = "") {.jsfunc.} =
   if s.len > 0 and s[^1] == '\n':
-    pager.loadURL(s[0..^2])
+    if s.len > 1:
+      pager.loadURL(s[0..^2])
+  elif s == "":
+    pager.setLineEdit("URL: ", LOCATION, $pager.container.location)
   else:
-    var url = s
-    if url == "":
-      url = pager.container.location.serialize()
-    pager.setLineEdit("URL: ", LOCATION, url)
+    pager.setLineEdit("URL: ", LOCATION, s)
+
+# Go to specific URL (for JS)
+proc jsGotoURL(pager: Pager, s: string): JSResult[void] {.jsfunc: "gotoURL".} =
+  pager.gotoURL(newRequest(?newURL(s)))
 
 # Reload the page in a new buffer, then kill the previous buffer.
 proc reload(pager: Pager) {.jsfunc.} =