Ejemplo n.º 1
0
/* Navigates the view to given mark if it's valid.  Returns new value for
 * save_msg flag. */
static int
navigate_to_bookmark(FileView *view, char mark)
{
	const bookmark_t *const bmark = get_bookmark(mark);

	if(is_bmark_valid(bmark))
	{
		if(change_directory(view, bmark->directory) >= 0)
		{
			load_dir_list(view, 1);
			(void)ensure_file_is_selected(view, bmark->file);
		}
	}
	else
	{
		if(!char_is_one_of(valid_bookmarks, mark))
			status_bar_message("Invalid mark name");
		else if(is_bmark_empty(bmark))
			status_bar_message("Mark is not set");
		else
			status_bar_message("Mark is invalid");

		move_to_list_pos(view, view->list_pos);
		return 1;
	}
	return 0;
}
Ejemplo n.º 2
0
int
is_valid_bookmark(const int bmark_index)
{
	const char mark = index2mark(bmark_index);
	const bookmark_t *const bmark = get_bookmark(mark);
	return is_bmark_valid(bmark);
}
Ejemplo n.º 3
0
void
html_a(struct html_context *html_context, unsigned char *a,
       unsigned char *xxx3, unsigned char *xxx4, unsigned char **xxx5)
{
	unsigned char *href;

	href = get_url_val(a, (unsigned char *)"href", html_context->doc_cp);
	if (href) {
		unsigned char *target;

		mem_free_set(&format.link,
			     join_urls(html_context->base_href,
				       trim_chars(href, ' ', 0)));

		mem_free(href);

		target = get_target(html_context->options, a);
		if (target) {
			mem_free_set(&format.target, target);
		} else {
			mem_free_set(&format.target, stracpy(html_context->base_target));
		}

		if (0) {
			; /* Shut up compiler */
#ifdef CONFIG_GLOBHIST
		} else if (get_global_history_item(format.link)) {
			format.style.color.foreground = format.color.vlink;
			html_top->pseudo_class &= ~ELEMENT_LINK;
			html_top->pseudo_class |= ELEMENT_VISITED;
#endif
#ifdef CONFIG_BOOKMARKS
		} else if (get_bookmark(format.link)) {
			format.style.color.foreground = format.color.bookmark_link;
			html_top->pseudo_class &= ~ELEMENT_VISITED;
			/* XXX: Really set ELEMENT_LINK? --pasky */
			html_top->pseudo_class |= ELEMENT_LINK;
#endif
		} else {
			format.style.color.foreground = format.color.clink;
			html_top->pseudo_class &= ~ELEMENT_VISITED;
			html_top->pseudo_class |= ELEMENT_LINK;
		}

		mem_free_set(&format.title,
		             get_attr_val(a, (unsigned char *)"title", html_context->doc_cp));

		html_focusable(html_context, a);

	} else {
		pop_html_element(html_context);
	}

	set_fragment_identifier(html_context, a, (unsigned char *)"name");
}
Ejemplo n.º 4
0
/* Sets values of the mark.  The force parameter controls whether bookmark is
 * updated even when it already points to the specified directory-file pair. */
static void
set_mark(const char mark, const char directory[], const char file[],
		time_t timestamp, int force)
{
	bookmark_t *const bmark = get_bookmark(mark);
	if(bmark != NULL && (force || !is_bmark_points_to(bmark, directory, file)))
	{
		clear_mark(bmark);

		bmark->directory = strdup(directory);
		bmark->file = strdup(file);
		bmark->timestamp = timestamp;
	}
}
Ejemplo n.º 5
0
int
check_mark_directory(FileView *view, char mark)
{
	const bookmark_t *const bmark = get_bookmark(mark);

	if(!is_bmark_empty(bmark))
	{
		if(stroscmp(view->curr_dir, bmark->directory) == 0)
		{
			return find_file_pos_in_list(view, bmark->file);
		}
	}

	return -1;
}
Ejemplo n.º 6
0
int
is_bookmark_older(const char mark, const time_t than)
{
	const bookmark_t *const bmark = get_bookmark(mark);
	if(bmark != NULL)
	{
		static const time_t undef_time = (time_t)-1;
		if(bmark->timestamp == undef_time || than == undef_time)
		{
			return bmark->timestamp == undef_time;
		}
		return bmark->timestamp < than;
	}
	return 1;
}
Ejemplo n.º 7
0
int
init_active_bookmarks(const char marks[], int active_bookmarks[])
{
	int i, x;

	i = 0;
	for(x = 0; x < NUM_BOOKMARKS; ++x)
	{
		if(!char_is_one_of(marks, index2mark(x)))
			continue;
		if(is_bmark_empty(get_bookmark(x)))
			continue;
		active_bookmarks[i++] = x;
	}
	return i;
}
Ejemplo n.º 8
0
void
clear_bookmark(const int mark)
{
	bookmark_t *const bmark = get_bookmark(mark);
	clear_mark(bmark);
}
Ejemplo n.º 9
0
int
is_bookmark_empty(const char mark)
{
	const bookmark_t *const bmark = get_bookmark(mark);
	return is_bmark_empty(bmark);
}