summaryrefslogtreecommitdiffstats
path: root/include/stflpp.h
blob: dba7aa9684ad7ec3a1d8c532e6f0d610c9949c3d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#ifndef NEWSBOAT_STFLPP_H_
#define NEWSBOAT_STFLPP_H_

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

#include <string>

namespace newsboat {

class Stfl {
public:
	class Form {
	public:
		explicit Form(const std::string& text);
		~Form();

		// Make sure this class cannot accidentally get copied.
		// Copying this class would be bad because the `f` and `ipool` member
		// variables are managed manually.
		Form(const Form&) = delete;
		Form& operator=(const Form&) = delete;
		// The move operations are not needed at the moment but can be added when necessary.
		Form(Form&&) = delete;
		Form& operator=(Form&&) = delete;

		std::string run(int timeout);

		std::string get(const std::string& name);
		void set(const std::string& name, const std::string& value);

		std::string get_focus();
		void set_focus(const std::string& name);

		std::string dump(const std::string& name,
			const std::string& prefix,
			int focus);
		void modify(const std::string& name,
			const std::string& mode,
			const std::string& text);

	private:
		stfl_form* f;
		stfl_ipool* ipool;
	};

	static void reset();
	static std::string quote(const std::string& text);
};

} // namespace newsboat

#endif /* NEWSBOAT_STFLPP_H_ */