1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-06-24 00:56:14 +00:00

Merge pull request #41 from sgerwk/master

add -remote 'search(string)'
This commit is contained in:
rkd77 2020-04-26 11:32:40 +02:00 committed by GitHub
commit 36fc784212
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 27 additions and 3 deletions

View File

@ -205,6 +205,7 @@ enum remote_method_enum {
REMOTE_METHOD_ADDBOOKMARK,
REMOTE_METHOD_INFOBOX,
REMOTE_METHOD_RELOAD,
REMOTE_METHOD_SEARCH,
REMOTE_METHOD_NOT_SUPPORTED,
};
@ -223,6 +224,7 @@ remote_cmd(struct option *o, unsigned char ***argv, int *argc)
{ "infoBox", REMOTE_METHOD_INFOBOX },
{ "xfeDoCommand", REMOTE_METHOD_XFEDOCOMMAND },
{ "reload", REMOTE_METHOD_RELOAD },
{ "search", REMOTE_METHOD_SEARCH },
{ NULL, REMOTE_METHOD_NOT_SUPPORTED },
};
unsigned char *command, *arg, *argend, *argstring;
@ -392,6 +394,16 @@ remote_cmd(struct option *o, unsigned char ***argv, int *argc)
remote_session_flags = SES_REMOTE_RELOAD;
break;
case REMOTE_METHOD_SEARCH:
if (remote_argc < 1)
remote_url = stracpy("");
else
remote_url = stracpy(remote_argv[0]);
insert_in_string(&remote_url, 0,
"search:", sizeof("search:") - 1);
remote_session_flags = SES_REMOTE_SEARCH;
break;
case REMOTE_METHOD_NOT_SUPPORTED:
break;
}

View File

@ -55,6 +55,7 @@
#include "viewer/text/form.h"
#include "viewer/text/link.h"
#include "viewer/text/view.h"
#include "viewer/text/search.h"
struct file_to_load {
@ -1052,9 +1053,19 @@ init_remote_session(struct session *ses, enum remote_session_flags *remote_ptr,
} else if (remote & SES_REMOTE_PROMPT_URL) {
dialog_goto_url_open(ses);
} else if (remote & SES_REMOTE_RELOAD) {
reload(ses, CACHE_MODE_FORCE_RELOAD);
} else if (remote & SES_REMOTE_SEARCH) {
if (!uri)
return;
if (strncmp(uri->string, "search:", sizeof("search:") - 1)) {
info_box(ses->tab->term, MSGBOX_FREE_TEXT,
N_("Incorrect search uri"), ALIGN_CENTER,
uri->string);
return;
}
search_for(ses, uri->data);
}
}

View File

@ -36,6 +36,7 @@ enum remote_session_flags {
SES_REMOTE_ADD_BOOKMARK = 32,
SES_REMOTE_INFO_BOX = 64,
SES_REMOTE_RELOAD = 128,
SES_REMOTE_SEARCH = 256,
};
/** This is generic frame descriptor, meaningful mainly for ses_*_frame*(). */

View File

@ -1032,7 +1032,7 @@ search_for_back(struct session *ses, unsigned char *str)
search_for_do(ses, str, -1, 1);
}
static void
void
search_for(struct session *ses, unsigned char *str)
{
assert(ses && str);

View File

@ -18,7 +18,7 @@ enum frame_event_status find_next(struct session *ses, struct document_view *doc
enum frame_event_status move_search_next(struct session *ses, struct document_view *doc_view);
enum frame_event_status move_search_prev(struct session *ses, struct document_view *doc_view);
void search_for(struct session *ses, unsigned char *str);
enum frame_event_status search_dlg(struct session *ses, struct document_view *doc_view, int direction);
enum frame_event_status search_typeahead(struct session *ses, struct document_view *doc_view, action_id_T action_id);