<commit_before>#include <urlview_formaction.h>
#include <formatstring.h>
#include <view.h>
#include <config.h>
#include <utils.h>
#include <strprintf.h>
#include <listformatter.h>

#include <sstream>

namespace newsboat {

/*
 * The urlview_formaction is probably the simplest dialog of all. It
 * displays a list of URLs, and makes it possible to open the URLs
 * in a browser or to bookmark them.
 */

urlview_formaction::urlview_formaction(view * vv, std::shared_ptr<rss_feed>& feed, std::string formstr)
	: formaction(vv, formstr), quit(false), feed(feed) { }

urlview_formaction::~urlview_formaction() {
}

void urlview_formaction::process_operation(operation op, bool /* automatic */, std::vector<std::string> * /* args */) {
	bool hardquit = false;
	switch (op) {
	case OP_OPEN: {
		std::string posstr = f->get("feedpos");
		if (posstr.length() > 0) {
			unsigned int idx = utils::to_u(posstr, 0);
			v->set_status(_("Starting browser..."));
			v->open_in_browser(links[idx].first);
			v->set_status("");
		} else {
			v->show_error(_("No link selected!"));
		}
	}
	break;
	case OP_BOOKMARK: {
		std::string posstr = f->get("feedpos");
		if (posstr.length() > 0) {
			unsigned int idx = utils::to_u(posstr, 0);

			this->start_bookmark_qna("", links[idx].first, "", feed->title());

		} else {
			v->show_error(_("No link selected!"));
		}
	}
	break;
	case OP_1:
	case OP_2:
	case OP_3:
	case OP_4:
	case OP_5:
	case OP_6:
	case OP_7:<commit_msg>Add "open-in-browser" action to urlview_formaction<commit_after>#include <urlview_formaction.h>
#include <formatstring.h>
#include <view.h>
#include <config.h>
#include <utils.h>
#include <strprintf.h>
#include <listformatter.h>

#include <sstream>

namespace newsboat {

/*
 * The urlview_formaction is probably the simplest dialog of all. It
 * displays a list of URLs, and makes it possible to open the URLs
 * in a browser or to bookmark them.
 */

urlview_formaction::urlview_formaction(view * vv, std::shared_ptr<rss_feed>& feed, std::string formstr)
	: formaction(vv, formstr), quit(false), feed(feed) { }

urlview_formaction::~urlview_formaction() {
}

void urlview_formaction::process_operation(operation op, bool /* automatic */, std::vector<std::string> * /* args */) {
	bool hardquit = false;
	switch (op) {
	case OP_OPENINBROWSER:
	case OP_OPEN: {
		std::string posstr = f->get("feedpos");
		if (posstr.length() > 0) {
			unsigned int idx = utils::to_u(posstr, 0);
			v->set_status(_("Starting browser..."));
			v->open_in_browser(links[idx].first);
			v->set_status("");
		} else {
			v->show_error(_("No link selected!"));
		}
	}
	break;
	case OP_BOOKMARK: {
		std::string posstr = f->get("feedpos");
		if (posstr.length() > 0) {
			unsigned int idx = utils::to_u(posstr, 0);

			this->start_bookmark_qna("", links[idx].first, "", feed->title());

		} else {
			v->show_error(_("No link selected!"));
		}
	}
	break;
	case OP_1:
	case OP_2:
	case OP_3:
	case OP_4:
	case OP_5:
	case OP_6:
	case OP_7:
{'fraction_non_alphanumeric': 0.16346477923828784, 'fraction_numerical': 0.00741489720256151, 'mean_word_length': 4.496296296296296, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 45, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5752778', 'n_tokens_mistral': 1165, 'n_tokens_neox': 1099, 'n_words': 261}