1
0
mirror of https://github.com/rkd77/elinks.git synced 2025-01-03 14:57:44 -05:00

[remote] Now addBookmark takes two parameters URL and title. Refs #227

title must be passed without quotes. Example:
elinks --remote 'addBookmark(https://www.example.com/forum, Forum Example)'

Implementation note: uri->post was reused and is title here.
This commit is contained in:
Witold Filipczyk 2023-04-30 20:14:33 +02:00
parent ac7132bda5
commit c8e0dd9e47
3 changed files with 18 additions and 5 deletions

View File

@ -74,7 +74,7 @@ xfeDoCommand(openBrowser) Opens an ELinks instance in a new window. \
`-------------------------------`---------------------------------------------- `-------------------------------`----------------------------------------------
Command Description Command Description
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
addBookmark(URL) Bookmarks the passed URL. addBookmark(URL, title) Bookmarks the passed URL and set title.
infoBox(text) Show text in a message box. infoBox(text) Show text in a message box.
reload() Reload the document in the current tab. reload() Reload the document in the current tab.
search(string) Search for the string in the current tab search(string) Search for the string in the current tab

View File

@ -405,7 +405,11 @@ remote_cmd(struct option *o, char ***argv, int *argc)
case REMOTE_METHOD_ADDBOOKMARK: case REMOTE_METHOD_ADDBOOKMARK:
if (remote_argc < 1) if (remote_argc < 1)
break; break;
remote_url = stracpy(remote_argv[0]); if (remote_argc == 2) {
remote_url = straconcat(remote_argv[0], POST_CHAR_S, remote_argv[1], NULL);
} else {
remote_url = stracpy(remote_argv[0]);
}
remote_session_flags = SES_REMOTE_ADD_BOOKMARK; remote_session_flags = SES_REMOTE_ADD_BOOKMARK;
break; break;
@ -960,7 +964,7 @@ union option_info cmdline_options_info[] = {
"\topenURL(URL) : open URL in current tab\n" "\topenURL(URL) : open URL in current tab\n"
"\topenURL(URL, new-tab) : open URL in new tab\n" "\topenURL(URL, new-tab) : open URL in new tab\n"
"\topenURL(URL, new-window) : open URL in new window\n" "\topenURL(URL, new-window) : open URL in new window\n"
"\taddBookmark(URL) : bookmark URL\n" "\taddBookmark(URL, title) : bookmark URL with title\n"
"\tinfoBox(text) : show text in a message box\n" "\tinfoBox(text) : show text in a message box\n"
"\treload() : reload the document in the current tab\n" "\treload() : reload the document in the current tab\n"
"\tsearch(string) : search in the current tab\n" "\tsearch(string) : search in the current tab\n"

View File

@ -1144,9 +1144,18 @@ init_remote_session(struct session *ses, remote_session_flags_T *remote_ptr,
* then have a function that reversibly converts them * then have a function that reversibly converts them
* to IRIs for display in a given encoding. */ * to IRIs for display in a given encoding. */
uri_cp = get_cp_index("System"); uri_cp = get_cp_index("System");
add_bookmark_cp(NULL, 1, uri_cp, struri(uri), struri(uri));
#endif
if (uri->post) {
char *title = stracpy(uri->post);
char *url = get_uri_string(uri, URI_ORIGINAL);
add_bookmark_cp(NULL, 1, uri_cp, title, url);
mem_free_if(url);
mem_free_if(title);
} else {
add_bookmark_cp(NULL, 1, uri_cp, struri(uri), struri(uri));
}
#endif
} else if (remote & SES_REMOTE_INFO_BOX) { } else if (remote & SES_REMOTE_INFO_BOX) {
char *text; char *text;