<commit_before>#include <feedlist.h>
#include <itemlist.h>
#include <itemview.h>
#include <help.h>
#include <filebrowser.h>
#include <urlview.h>
#include <selecttag.h>

#include <logger.h>
#include <reloadthread.h>

#include <iostream>
#include <iomanip>
#include <fstream>

#include <assert.h>
#include <libgen.h>
#include <sys/types.h>
#include <dirent.h>
#include <grp.h>
#include <pwd.h>
#include <unistd.h>
#include <config.h>
#include <sys/param.h>
#include <string.h>


extern "C" {
#include <stfl.h>
}

#include <view.h>
#include <rss.h>
#include <htmlrenderer.h>
#include <cstring>
#include <cstdio>
#include <iostream>
#include <sstream>

using namespace newsbeuter;

view::view(controller * c) : ctrl(c), cfg(0), keys(0), mtx(0),
		feedlist_form(feedlist_str), itemlist_form(itemlist_str), itemview_form(itemview_str), 
		help_form(help_str), filebrowser_form(filebrowser_str), urlview_form(urlview_str), selecttag_form(selecttag_str) { 
	mtx = new mutex();
}

view::~view() {
	stfl::reset();
	delete mtx;
}

void view::set_config_container(configcontainer * cfgcontainer) {
	cfg = cfgcontainer;	
}

void view::set_keymap(keymap * k) {
	keys = k;
}

void view::set_status(const char * msg) {
	mtx->lock();
	stfl::form * form = *(view_stack.begin());
	if (form) {
		form->set("msg",msg);
		form->run(-1);
	}
	mtx->unlock();
}

void view::show_error(const char * msg) {
	set_status(msg);
}

void view::run_feedlist(const std::vector<std::string>& tags) {
	bool quit = false;
	bool update = false;
	bool zero_feedpos = false;

	view_stack.push_front(&feedlist_form);
	
	set_feedlist_keymap_hint();

	if(ctrl->get_refresh_on_start()) {
		feedlist_form.run(-1);
		ctrl->start_reload_all_thread();
	}

	unsigned int reload_cycle = 60 * static_cast<unsigned int>(cfg->get_configvalue_as_int("reload-time"));
	reloadthread rt(ctrl, reload_cycle);
	if (cfg->get_configvalue_as_bool("auto-reload") == true)
		rt.start();

	do {

		if (update) {<commit_msg><NAME>: 	fixed a crash when "q" was pressed immediately after program start.<commit_after>#include <feedlist.h>
#include <itemlist.h>
#include <itemview.h>
#include <help.h>
#include <filebrowser.h>
#include <urlview.h>
#include <selecttag.h>

#include <logger.h>
#include <reloadthread.h>

#include <iostream>
#include <iomanip>
#include <fstream>

#include <assert.h>
#include <libgen.h>
#include <sys/types.h>
#include <dirent.h>
#include <grp.h>
#include <pwd.h>
#include <unistd.h>
#include <config.h>
#include <sys/param.h>
#include <string.h>


extern "C" {
#include <stfl.h>
}

#include <view.h>
#include <rss.h>
#include <htmlrenderer.h>
#include <cstring>
#include <cstdio>
#include <iostream>
#include <sstream>

using namespace newsbeuter;

view::view(controller * c) : ctrl(c), cfg(0), keys(0), mtx(0),
		feedlist_form(feedlist_str), itemlist_form(itemlist_str), itemview_form(itemview_str), 
		help_form(help_str), filebrowser_form(filebrowser_str), urlview_form(urlview_str), selecttag_form(selecttag_str) { 
	mtx = new mutex();
}

view::~view() {
	stfl::reset();
	delete mtx;
}

void view::set_config_container(configcontainer * cfgcontainer) {
	cfg = cfgcontainer;	
}

void view::set_keymap(keymap * k) {
	keys = k;
}

void view::set_status(const char * msg) {
	mtx->lock();
	if (view_stack.size() > 0) {
		stfl::form * form = *(view_stack.begin());
		if (form) {
			form->set("msg",msg);
			form->run(-1);
		}
	}
	mtx->unlock();
}

void view::show_error(const char * msg) {
	set_status(msg);
}

void view::run_feedlist(const std::vector<std::string>& tags) {
	bool quit = false;
	bool update = false;
	bool zero_feedpos = false;

	view_stack.push_front(&feedlist_form);
	
	set_feedlist_keymap_hint();

	if(ctrl->get_refresh_on_start()) {
		feedlist_form.run(-1);
		ctrl->start_reload_all_thread();
	}

	unsigned int reload_cycle = 60 * static_cast<unsigned int>(cfg->get_configvalue_as_int("reload-time"));
	reloadthread rt(ctrl, reload_cycle);
	if (cfg->get_configvalue_as_bool("auto-reload") == true)
		rt.start();

	do {

		if (update) {
{'fraction_non_alphanumeric': 0.17036114570361147, 'fraction_numerical': 0.0037359900373599006, 'mean_word_length': 5.67109634551495, 'pattern_counts': {'":': 0, '<': 68, '<?xml version=': 0, '>': 85, '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': '1943335', 'n_tokens_mistral': 1620, 'n_tokens_neox': 1571, 'n_words': 308}