mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
Added support for label_key in references of dumps.
Added base parameter to dec2qwerty and qwerty2dec to avoid strlen calls im dumps.
This commit is contained in:
parent
69986f1bd1
commit
4efea7e314
@ -1505,10 +1505,9 @@ put_chars_conv(struct html_context *html_context,
|
|||||||
* represented by key. I the trivial case, key="0123456789". A more homerow
|
* represented by key. I the trivial case, key="0123456789". A more homerow
|
||||||
* friendly key="gfdsahjkl;trewqyuiopvcxznm". Returns the length of link_sym.
|
* friendly key="gfdsahjkl;trewqyuiopvcxznm". Returns the length of link_sym.
|
||||||
*/
|
*/
|
||||||
static int
|
int
|
||||||
dec2qwerty(int num, char *link_sym, const char *key)
|
dec2qwerty(int num, unsigned char *link_sym, const unsigned char *key, int base)
|
||||||
{
|
{
|
||||||
int base = strlen(key);
|
|
||||||
int newlen, i, pow;
|
int newlen, i, pow;
|
||||||
|
|
||||||
if (base < 2) return 0;
|
if (base < 2) return 0;
|
||||||
@ -1528,10 +1527,9 @@ dec2qwerty(int num, char *link_sym, const char *key)
|
|||||||
* Returns the value of link_sym in decimal according to key.
|
* Returns the value of link_sym in decimal according to key.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
qwerty2dec(const char *link_sym, const char *key)
|
qwerty2dec(const unsigned char *link_sym, const unsigned char *key, int base)
|
||||||
{
|
{
|
||||||
int z = 0;
|
int z = 0;
|
||||||
int base = strlen(key);
|
|
||||||
int symlen = strlen(link_sym);
|
int symlen = strlen(link_sym);
|
||||||
int i;
|
int i;
|
||||||
int pow;
|
int pow;
|
||||||
@ -1555,12 +1553,13 @@ put_link_number(struct html_context *html_context)
|
|||||||
unsigned char *fi = format.image;
|
unsigned char *fi = format.image;
|
||||||
struct form_control *ff = format.form;
|
struct form_control *ff = format.form;
|
||||||
int slen = 0;
|
int slen = 0;
|
||||||
|
int base = strlen(symkey);
|
||||||
|
|
||||||
format.link = format.target = format.image = NULL;
|
format.link = format.target = format.image = NULL;
|
||||||
format.form = NULL;
|
format.form = NULL;
|
||||||
|
|
||||||
s[slen++] = '[';
|
s[slen++] = '[';
|
||||||
slen += dec2qwerty(part->link_num, s + 1, symkey);
|
slen += dec2qwerty(part->link_num, s + 1, symkey, base);
|
||||||
s[slen++] = ']';
|
s[slen++] = ']';
|
||||||
s[slen] = '\0';
|
s[slen] = '\0';
|
||||||
|
|
||||||
|
@ -68,5 +68,6 @@ void free_table_cache(void);
|
|||||||
|
|
||||||
struct part *format_html_part(struct html_context *html_context, unsigned char *, unsigned char *, int, int, int, struct document *, int, int, unsigned char *, int);
|
struct part *format_html_part(struct html_context *html_context, unsigned char *, unsigned char *, int, int, int, struct document *, int, int, unsigned char *, int);
|
||||||
|
|
||||||
int qwerty2dec(const char *link_sym, const char *key);
|
int dec2qwerty(int num, unsigned char *link_sym, const unsigned char *key, int base);
|
||||||
|
int qwerty2dec(const unsigned char *link_sym, const unsigned char *key, int base);
|
||||||
#endif
|
#endif
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#include "cache/cache.h"
|
#include "cache/cache.h"
|
||||||
#include "config/options.h"
|
#include "config/options.h"
|
||||||
#include "document/document.h"
|
#include "document/document.h"
|
||||||
|
#include "document/html/renderer.h"
|
||||||
#include "document/options.h"
|
#include "document/options.h"
|
||||||
#include "document/renderer.h"
|
#include "document/renderer.h"
|
||||||
#include "document/view.h"
|
#include "document/view.h"
|
||||||
@ -326,9 +327,12 @@ dump_references(struct document *document, int fd, unsigned char buf[D_BUF])
|
|||||||
{
|
{
|
||||||
if (document->nlinks
|
if (document->nlinks
|
||||||
&& get_opt_bool("document.dump.references", NULL)) {
|
&& get_opt_bool("document.dump.references", NULL)) {
|
||||||
|
unsigned char key_sym[64] = {0};
|
||||||
int x;
|
int x;
|
||||||
unsigned char *header = "\nReferences\n\n Visible links\n";
|
unsigned char *header = "\nReferences\n\n Visible links\n";
|
||||||
|
const unsigned char *label_key = get_opt_str("document.browse.links.label_key", NULL);
|
||||||
int headlen = strlen(header);
|
int headlen = strlen(header);
|
||||||
|
int base = strlen(label_key);
|
||||||
|
|
||||||
if (hard_write(fd, header, headlen) != headlen)
|
if (hard_write(fd, header, headlen) != headlen)
|
||||||
return -1;
|
return -1;
|
||||||
@ -341,12 +345,15 @@ dump_references(struct document *document, int fd, unsigned char buf[D_BUF])
|
|||||||
if (!where) continue;
|
if (!where) continue;
|
||||||
|
|
||||||
if (document->options.links_numbering) {
|
if (document->options.links_numbering) {
|
||||||
|
|
||||||
|
dec2qwerty(x + 1, key_sym, label_key, base);
|
||||||
|
|
||||||
if (link->title && *link->title)
|
if (link->title && *link->title)
|
||||||
snprintf(buf, D_BUF, "%4d. %s\n\t%s\n",
|
snprintf(buf, D_BUF, "%4s. %s\n\t%s\n",
|
||||||
x + 1, link->title, where);
|
key_sym, link->title, where);
|
||||||
else
|
else
|
||||||
snprintf(buf, D_BUF, "%4d. %s\n",
|
snprintf(buf, D_BUF, "%4s. %s\n",
|
||||||
x + 1, where);
|
key_sym, where);
|
||||||
} else {
|
} else {
|
||||||
if (link->title && *link->title)
|
if (link->title && *link->title)
|
||||||
snprintf(buf, D_BUF, " . %s\n\t%s\n",
|
snprintf(buf, D_BUF, " . %s\n\t%s\n",
|
||||||
|
@ -1223,13 +1223,14 @@ goto_link_symbol(struct session *ses, unsigned char *sym)
|
|||||||
char *symkey = get_opt_str("document.browse.links.label_key", ses);
|
char *symkey = get_opt_str("document.browse.links.label_key", ses);
|
||||||
struct document_view *doc_view;
|
struct document_view *doc_view;
|
||||||
int num;
|
int num;
|
||||||
|
int base = strlen(symkey);
|
||||||
|
|
||||||
assert(ses && sym);
|
assert(ses && sym);
|
||||||
if_assert_failed return;
|
if_assert_failed return;
|
||||||
doc_view = current_frame(ses);
|
doc_view = current_frame(ses);
|
||||||
assert(doc_view);
|
assert(doc_view);
|
||||||
if_assert_failed return;
|
if_assert_failed return;
|
||||||
num = qwerty2dec(sym, symkey);
|
num = qwerty2dec(sym, symkey, base);
|
||||||
goto_link_number_do(ses, doc_view, num - 1);
|
goto_link_number_do(ses, doc_view, num - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user