From ef94e58fa6f8079c8117c426702119d66c5895b8 Mon Sep 17 00:00:00 2001 From: Tristan Krause Date: Fri, 7 Jun 2019 14:50:16 +0200 Subject: [PATCH] doc update --- control/examples/transistor/main.cpp | 9 +++ docs/html/annotated.html | 2 +- docs/html/b15f_8cpp_source.html | 2 +- docs/html/b15f_8h_source.html | 2 +- docs/html/classB15F-members.html | 2 +- docs/html/classB15F.html | 2 +- docs/html/classDot-members.html | 2 +- docs/html/classDot.html | 2 +- docs/html/classDriverException-members.html | 2 +- docs/html/classDriverException.html | 2 +- docs/html/classPlottyFile-members.html | 2 +- docs/html/classPlottyFile.html | 2 +- docs/html/classTimeoutException-members.html | 2 +- docs/html/classTimeoutException.html | 2 +- docs/html/classUSART-members.html | 2 +- docs/html/classUSART.html | 2 +- docs/html/classUSARTException-members.html | 2 +- docs/html/classUSARTException.html | 2 +- docs/html/classView-members.html | 2 +- docs/html/classView.html | 2 +- docs/html/classViewInfo-members.html | 2 +- docs/html/classViewInfo.html | 2 +- docs/html/classViewMonitor-members.html | 2 +- docs/html/classViewMonitor.html | 2 +- docs/html/classViewPromt-members.html | 2 +- docs/html/classViewPromt.html | 2 +- docs/html/classViewSelection-members.html | 2 +- docs/html/classViewSelection.html | 2 +- docs/html/classes.html | 2 +- docs/html/cli_8cpp_source.html | 2 +- .../dir_1788f8309b1a812dcb800a185471cf6c.html | 2 +- .../dir_587c94d866dbb2f408f78cf41f9b2f8d.html | 2 +- docs/html/dot_8cpp_source.html | 2 +- docs/html/dot_8h_source.html | 2 +- docs/html/driverexception_8h_source.html | 2 +- docs/html/files.html | 66 ++++++++----------- docs/html/functions.html | 2 +- docs/html/functions_func.html | 2 +- docs/html/functions_vars.html | 2 +- docs/html/hierarchy.html | 2 +- docs/html/index.html | 6 +- docs/html/plottyfile_8cpp_source.html | 2 +- docs/html/plottyfile_8h_source.html | 2 +- docs/html/timeoutexception_8h_source.html | 2 +- docs/html/ui_8cpp_source.html | 2 +- docs/html/ui_8h_source.html | 2 +- docs/html/usart_8cpp_source.html | 2 +- docs/html/usart_8h_source.html | 2 +- docs/html/usartexception_8h_source.html | 2 +- docs/html/view_8cpp_source.html | 2 +- docs/html/view_8h_source.html | 2 +- docs/html/view__info_8cpp_source.html | 2 +- docs/html/view__info_8h_source.html | 2 +- docs/html/view__monitor_8cpp_source.html | 2 +- docs/html/view__monitor_8h_source.html | 2 +- docs/html/view__promt_8cpp_source.html | 2 +- docs/html/view__promt_8h_source.html | 2 +- docs/html/view__selection_8cpp_source.html | 2 +- docs/html/view__selection_8h_source.html | 2 +- 59 files changed, 96 insertions(+), 97 deletions(-) diff --git a/control/examples/transistor/main.cpp b/control/examples/transistor/main.cpp index cdfc5c2..7073c9d 100644 --- a/control/examples/transistor/main.cpp +++ b/control/examples/transistor/main.cpp @@ -4,6 +4,15 @@ #include #include +/* + * Erfasse die Kennlinien des ersten und zweiten Quadrants eines FETs. + * Anschlüsse: + * ADC0: U_out (über 100Ohm an Drain) + * ADC1: U_drain (Drain) + * DAC0: U_out (über 100Ohm an Drain) + * DAC1: U_GS (über 1K an Gate) + */ + const char PLOT_FILE[] = "plot.bin"; void printProgress(double p) diff --git a/docs/html/annotated.html b/docs/html/annotated.html index deff929..ed147b7 100644 --- a/docs/html/annotated.html +++ b/docs/html/annotated.html @@ -85,7 +85,7 @@ $(function() { diff --git a/docs/html/b15f_8cpp_source.html b/docs/html/b15f_8cpp_source.html index 4201243..0fe9585 100644 --- a/docs/html/b15f_8cpp_source.html +++ b/docs/html/b15f_8cpp_source.html @@ -112,7 +112,7 @@ $(function() { diff --git a/docs/html/b15f_8h_source.html b/docs/html/b15f_8h_source.html index 9729432..94f18fa 100644 --- a/docs/html/b15f_8h_source.html +++ b/docs/html/b15f_8h_source.html @@ -107,7 +107,7 @@ $(function() {
bool testIntConv(void)
Definition: b15f.cpp:114
diff --git a/docs/html/classB15F-members.html b/docs/html/classB15F-members.html index e88d578..9e8e5a6 100644 --- a/docs/html/classB15F-members.html +++ b/docs/html/classB15F-members.html @@ -105,7 +105,7 @@ $(function() { diff --git a/docs/html/classB15F.html b/docs/html/classB15F.html index 18bb42a..cedba6f 100644 --- a/docs/html/classB15F.html +++ b/docs/html/classB15F.html @@ -1030,7 +1030,7 @@ constexpr static uint32_t  diff --git a/docs/html/classDot-members.html b/docs/html/classDot-members.html index b493400..e9ea78c 100644 --- a/docs/html/classDot-members.html +++ b/docs/html/classDot-members.html @@ -76,7 +76,7 @@ $(function() { diff --git a/docs/html/classDot.html b/docs/html/classDot.html index 4d8cd1d..c34b193 100644 --- a/docs/html/classDot.html +++ b/docs/html/classDot.html @@ -196,7 +196,7 @@ Public Member Functions diff --git a/docs/html/classDriverException-members.html b/docs/html/classDriverException-members.html index 385458a..5a87189 100644 --- a/docs/html/classDriverException-members.html +++ b/docs/html/classDriverException-members.html @@ -77,7 +77,7 @@ $(function() { diff --git a/docs/html/classDriverException.html b/docs/html/classDriverException.html index b3dd57e..70d005a 100644 --- a/docs/html/classDriverException.html +++ b/docs/html/classDriverException.html @@ -109,7 +109,7 @@ std::string msg_< diff --git a/docs/html/classPlottyFile-members.html b/docs/html/classPlottyFile-members.html index 69c5b8a..50f2516 100644 --- a/docs/html/classPlottyFile-members.html +++ b/docs/html/classPlottyFile-members.html @@ -100,7 +100,7 @@ $(function() { diff --git a/docs/html/classPlottyFile.html b/docs/html/classPlottyFile.html index 3eb73ca..366171f 100644 --- a/docs/html/classPlottyFile.html +++ b/docs/html/classPlottyFile.html @@ -811,7 +811,7 @@ Public Member Functions diff --git a/docs/html/classTimeoutException-members.html b/docs/html/classTimeoutException-members.html index 15cc27f..dab11c7 100644 --- a/docs/html/classTimeoutException-members.html +++ b/docs/html/classTimeoutException-members.html @@ -77,7 +77,7 @@ $(function() { diff --git a/docs/html/classTimeoutException.html b/docs/html/classTimeoutException.html index 015849c..04ac72e 100644 --- a/docs/html/classTimeoutException.html +++ b/docs/html/classTimeoutException.html @@ -239,7 +239,7 @@ std::string  diff --git a/docs/html/classUSART-members.html b/docs/html/classUSART-members.html index 56759ff..4cfc52c 100644 --- a/docs/html/classUSART-members.html +++ b/docs/html/classUSART-members.html @@ -86,7 +86,7 @@ $(function() { diff --git a/docs/html/classUSART.html b/docs/html/classUSART.html index 556dd16..3ea130e 100644 --- a/docs/html/classUSART.html +++ b/docs/html/classUSART.html @@ -523,7 +523,7 @@ Public Member Functions diff --git a/docs/html/classUSARTException-members.html b/docs/html/classUSARTException-members.html index b634feb..37ed7e0 100644 --- a/docs/html/classUSARTException-members.html +++ b/docs/html/classUSARTException-members.html @@ -77,7 +77,7 @@ $(function() { diff --git a/docs/html/classUSARTException.html b/docs/html/classUSARTException.html index 83a3239..6de1381 100644 --- a/docs/html/classUSARTException.html +++ b/docs/html/classUSARTException.html @@ -239,7 +239,7 @@ std::string  diff --git a/docs/html/classView-members.html b/docs/html/classView-members.html index d7b06ee..fa30cbf 100644 --- a/docs/html/classView-members.html +++ b/docs/html/classView-members.html @@ -89,7 +89,7 @@ $(function() { diff --git a/docs/html/classView.html b/docs/html/classView.html index 38d7d02..2220220 100644 --- a/docs/html/classView.html +++ b/docs/html/classView.html @@ -157,7 +157,7 @@ constexpr static int KEY_E diff --git a/docs/html/classViewInfo-members.html b/docs/html/classViewInfo-members.html index fee337a..bb74edc 100644 --- a/docs/html/classViewInfo-members.html +++ b/docs/html/classViewInfo-members.html @@ -99,7 +99,7 @@ $(function() { diff --git a/docs/html/classViewInfo.html b/docs/html/classViewInfo.html index d5f9b57..363a8ea 100644 --- a/docs/html/classViewInfo.html +++ b/docs/html/classViewInfo.html @@ -185,7 +185,7 @@ static std::vector< std::string >  diff --git a/docs/html/classViewMonitor-members.html b/docs/html/classViewMonitor-members.html index 2cbdf4c..c0cbf16 100644 --- a/docs/html/classViewMonitor-members.html +++ b/docs/html/classViewMonitor-members.html @@ -103,7 +103,7 @@ $(function() { diff --git a/docs/html/classViewMonitor.html b/docs/html/classViewMonitor.html index d7bef95..9ed69cd 100644 --- a/docs/html/classViewMonitor.html +++ b/docs/html/classViewMonitor.html @@ -197,7 +197,7 @@ constexpr static int KEY_E diff --git a/docs/html/classViewPromt-members.html b/docs/html/classViewPromt-members.html index 53bea32..fe3bc38 100644 --- a/docs/html/classViewPromt-members.html +++ b/docs/html/classViewPromt-members.html @@ -105,7 +105,7 @@ $(function() { diff --git a/docs/html/classViewPromt.html b/docs/html/classViewPromt.html index fe120e6..0f89cdf 100644 --- a/docs/html/classViewPromt.html +++ b/docs/html/classViewPromt.html @@ -205,7 +205,7 @@ static std::vector< std::string >  diff --git a/docs/html/classViewSelection-members.html b/docs/html/classViewSelection-members.html index a8ee44d..46c9b30 100644 --- a/docs/html/classViewSelection-members.html +++ b/docs/html/classViewSelection-members.html @@ -94,7 +94,7 @@ $(function() { diff --git a/docs/html/classViewSelection.html b/docs/html/classViewSelection.html index 4f5f2af..8038f35 100644 --- a/docs/html/classViewSelection.html +++ b/docs/html/classViewSelection.html @@ -172,7 +172,7 @@ static std::vector< std::string >  diff --git a/docs/html/classes.html b/docs/html/classes.html index 30c2f63..a343f10 100644 --- a/docs/html/classes.html +++ b/docs/html/classes.html @@ -105,7 +105,7 @@ $(function() { diff --git a/docs/html/cli_8cpp_source.html b/docs/html/cli_8cpp_source.html index a829e2a..95f4154 100644 --- a/docs/html/cli_8cpp_source.html +++ b/docs/html/cli_8cpp_source.html @@ -72,7 +72,7 @@ $(function() {
static void setAbortHandler(errorhandler_t func)
Definition: b15f.cpp:485
diff --git a/docs/html/dir_1788f8309b1a812dcb800a185471cf6c.html b/docs/html/dir_1788f8309b1a812dcb800a185471cf6c.html index df74479..c168027 100644 --- a/docs/html/dir_1788f8309b1a812dcb800a185471cf6c.html +++ b/docs/html/dir_1788f8309b1a812dcb800a185471cf6c.html @@ -73,7 +73,7 @@ $(function() { diff --git a/docs/html/dir_587c94d866dbb2f408f78cf41f9b2f8d.html b/docs/html/dir_587c94d866dbb2f408f78cf41f9b2f8d.html index d4aae6d..d182bb5 100644 --- a/docs/html/dir_587c94d866dbb2f408f78cf41f9b2f8d.html +++ b/docs/html/dir_587c94d866dbb2f408f78cf41f9b2f8d.html @@ -73,7 +73,7 @@ $(function() { diff --git a/docs/html/dot_8cpp_source.html b/docs/html/dot_8cpp_source.html index acf3fde..46d9349 100644 --- a/docs/html/dot_8cpp_source.html +++ b/docs/html/dot_8cpp_source.html @@ -77,7 +77,7 @@ $(function() {
Dot(uint16_t x, uint16_t y, uint8_t curve)
Definition: dot.cpp:3
diff --git a/docs/html/dot_8h_source.html b/docs/html/dot_8h_source.html index 51b1e8c..01ec2ea 100644 --- a/docs/html/dot_8h_source.html +++ b/docs/html/dot_8h_source.html @@ -78,7 +78,7 @@ $(function() {
Dot(uint16_t x, uint16_t y, uint8_t curve)
Definition: dot.cpp:3
diff --git a/docs/html/driverexception_8h_source.html b/docs/html/driverexception_8h_source.html index ee33149..09876bc 100644 --- a/docs/html/driverexception_8h_source.html +++ b/docs/html/driverexception_8h_source.html @@ -74,7 +74,7 @@ $(function() { diff --git a/docs/html/files.html b/docs/html/files.html index 3ad0f6b..6a32b9b 100644 --- a/docs/html/files.html +++ b/docs/html/files.html @@ -67,49 +67,39 @@ $(function() {
Here is a list of all documented files with brief descriptions:
-
[detail level 12345]
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
[detail level 12]
  cmake-build-debug
  CMakeFiles
  3.14.3
  CompilerIdC
 CMakeCCompilerId.c
  CompilerIdCXX
 CMakeCXXCompilerId.cpp
 feature_tests.c
 feature_tests.cxx
  drv
 b15f.cpp
 b15f.h
 backup.cpp
 dot.cpp
 dot.h
 driverexception.h
 plottyfile.cpp
 plottyfile.h
 timeoutexception.h
 usart.cpp
 usart.h
 usartexception.h
  ui
 ui.cpp
 ui.h
 view.cpp
 view.h
 view_info.cpp
 view_info.h
 view_monitor.cpp
 view_monitor.h
 view_promt.cpp
 view_promt.h
 view_selection.cpp
 view_selection.h
 cli.cpp
+ + + + + + + + + + + + + + + + + + + + + + + + + +
  drv
 b15f.cpp
 b15f.h
 dot.cpp
 dot.h
 driverexception.h
 plottyfile.cpp
 plottyfile.h
 timeoutexception.h
 usart.cpp
 usart.h
 usartexception.h
  ui
 ui.cpp
 ui.h
 view.cpp
 view.h
 view_info.cpp
 view_info.h
 view_monitor.cpp
 view_monitor.h
 view_promt.cpp
 view_promt.h
 view_selection.cpp
 view_selection.h
 cli.cpp
diff --git a/docs/html/functions.html b/docs/html/functions.html index 30bdf0a..d76b990 100644 --- a/docs/html/functions.html +++ b/docs/html/functions.html @@ -380,7 +380,7 @@ $(function() { diff --git a/docs/html/functions_func.html b/docs/html/functions_func.html index f5b2bf5..c7f2832 100644 --- a/docs/html/functions_func.html +++ b/docs/html/functions_func.html @@ -347,7 +347,7 @@ $(function() { diff --git a/docs/html/functions_vars.html b/docs/html/functions_vars.html index ae7d02a..801bbbd 100644 --- a/docs/html/functions_vars.html +++ b/docs/html/functions_vars.html @@ -92,7 +92,7 @@ $(function() { diff --git a/docs/html/hierarchy.html b/docs/html/hierarchy.html index 7eaae9a..6ebcf70 100644 --- a/docs/html/hierarchy.html +++ b/docs/html/hierarchy.html @@ -86,7 +86,7 @@ $(function() { diff --git a/docs/html/index.html b/docs/html/index.html index b291453..ae3562a 100644 --- a/docs/html/index.html +++ b/docs/html/index.html @@ -72,7 +72,7 @@ Installation

1. Abhängigkeiten installieren

(a) sudo apt-get update
- (b) sudo apt-get install git avr-libc avrdude libncurses5-dev g++
+ (b) sudo apt-get install git avr-libc avrdude libncurses5-dev g++ astyle

2. Das Repository klonen

@@ -139,14 +139,14 @@ Falls noch keine existiert, wird automatisch eine erzeugt und Verbindung zum Boa Kennlinien mit plottyfile generieren

Die Beschreibung zu Plottyfile befindet sich hier.
Nach dem Include von plottyfile kann ein neues Objekt erzeugt und konfiguriert werden:
-

{C++}
PlottyFile pf;
pf.setUnitX("V");
pf.setUnitY("V");
pf.setUnitPara("V");
pf.setDescX("U_{OUT}");
pf.setDescY("U_{IN}");
pf.setDescPara("");
pf.setRefX(5);
pf.setRefY(5);
pf.setParaFirstCurve(0);
pf.setParaStepWidth(0);

Messpunkte können anschließend hinzugefügt werden.
+

{C++}
PlottyFile pf;
pf.setUnitX("V");
pf.setUnitY("V");
pf.setUnitPara("V");
pf.setDescX("U_{OUT}"); // Markdown wird unterstuetzt
pf.setDescY("U_{IN}");
pf.setDescPara("");
pf.setRefX(5);
pf.setRefY(5);
pf.setParaFirstCurve(0);
pf.setParaStepWidth(0);

Messpunkte können anschließend hinzugefügt werden.
Dabei gehören Punkte mit dem gleichen Index für curve (uint8_t) zur selben Kurve und erhalten durch Plotty automatisch die gleiche Farbe.

{C++}
pf.addDot(Dot(x, y, curve));

x und y sind uint16_t, also keine Gleitkommazahlen.

diff --git a/docs/html/plottyfile_8cpp_source.html b/docs/html/plottyfile_8cpp_source.html index e22de2c..7c01093 100644 --- a/docs/html/plottyfile_8cpp_source.html +++ b/docs/html/plottyfile_8cpp_source.html @@ -101,7 +101,7 @@ $(function() {
std::string getUnitX(void) const
Definition: plottyfile.cpp:105
diff --git a/docs/html/plottyfile_8h_source.html b/docs/html/plottyfile_8h_source.html index 1f19f61..1c313f9 100644 --- a/docs/html/plottyfile_8h_source.html +++ b/docs/html/plottyfile_8h_source.html @@ -102,7 +102,7 @@ $(function() {
std::string getUnitX(void) const
Definition: plottyfile.cpp:105
diff --git a/docs/html/timeoutexception_8h_source.html b/docs/html/timeoutexception_8h_source.html index d121f28..a37ff55 100644 --- a/docs/html/timeoutexception_8h_source.html +++ b/docs/html/timeoutexception_8h_source.html @@ -79,7 +79,7 @@ $(function() {
TimeoutException(const std::string &message)
diff --git a/docs/html/ui_8cpp_source.html b/docs/html/ui_8cpp_source.html index 3724f29..6d19f10 100644 --- a/docs/html/ui_8cpp_source.html +++ b/docs/html/ui_8cpp_source.html @@ -88,7 +88,7 @@ $(function() {
bool analogWrite0(uint16_t port)
Definition: b15f.cpp:249
diff --git a/docs/html/ui_8h_source.html b/docs/html/ui_8h_source.html index ee5e268..5884250 100644 --- a/docs/html/ui_8h_source.html +++ b/docs/html/ui_8h_source.html @@ -73,7 +73,7 @@ $(function() {
1 #ifndef UI_H
2 #define UI_H
3 
4 #include <vector>
5 #include "view_selection.h"
6 #include "view_info.h"
7 #include "view_monitor.h"
8 #include "view_promt.h"
9 
10 void show_main(int);
11 void input(int);
12 void view_back(int);
13 void finish(int);
14 void cleanup();
15 
16 void show_info(int);
17 void show_monitor(int);
18 void show_invalid_port_input(int);
19 void show_invalid_dac_input(int);
20 void write_digital_output0(int);
21 void write_digital_output1(int);
22 void write_analog_output0(int);
23 void write_analog_output1(int);
24 void show_digital_output0(int);
25 void show_digital_output1(int);
26 void show_analog_output0(int);
27 void show_analog_output1(int);
28 
29 // selftest group
30 void show_selftest_info(int);
31 void start_selftest(int);
32 void stop_selftest(int);
33 
34 
35 extern std::vector<View*> win_stack;
36 extern std::thread t_refresh;
37 
38 #endif // UI_H
diff --git a/docs/html/usart_8cpp_source.html b/docs/html/usart_8cpp_source.html index 2fd9eec..739a946 100644 --- a/docs/html/usart_8cpp_source.html +++ b/docs/html/usart_8cpp_source.html @@ -88,7 +88,7 @@ $(function() { diff --git a/docs/html/usart_8h_source.html b/docs/html/usart_8h_source.html index 7406ff7..514b849 100644 --- a/docs/html/usart_8h_source.html +++ b/docs/html/usart_8h_source.html @@ -88,7 +88,7 @@ $(function() {
void flushOutputBuffer(void)
Definition: usart.cpp:68
diff --git a/docs/html/usartexception_8h_source.html b/docs/html/usartexception_8h_source.html index 11a9fea..2e51cf3 100644 --- a/docs/html/usartexception_8h_source.html +++ b/docs/html/usartexception_8h_source.html @@ -79,7 +79,7 @@ $(function() {
virtual ~USARTException()=default
diff --git a/docs/html/view_8cpp_source.html b/docs/html/view_8cpp_source.html index 229408d..0185f89 100644 --- a/docs/html/view_8cpp_source.html +++ b/docs/html/view_8cpp_source.html @@ -74,7 +74,7 @@ $(function() {
static void abort(std::string msg)
Definition: b15f.cpp:467
diff --git a/docs/html/view_8h_source.html b/docs/html/view_8h_source.html index eb93903..6570136 100644 --- a/docs/html/view_8h_source.html +++ b/docs/html/view_8h_source.html @@ -74,7 +74,7 @@ $(function() {
Definition: view.h:19
diff --git a/docs/html/view__info_8cpp_source.html b/docs/html/view__info_8cpp_source.html index 918aa93..20b0b6d 100644 --- a/docs/html/view__info_8cpp_source.html +++ b/docs/html/view__info_8cpp_source.html @@ -73,7 +73,7 @@ $(function() {
1 #include "view_info.h"
2 
3 ViewInfo::ViewInfo()
4 {
5  calls.push_back(nullptr);
6 }
7 
8 void ViewInfo::setText(std::string text)
9 {
10  this->text = text;
11 }
12 
13 void ViewInfo::setLabelClose(std::string label)
14 {
15  this->label_close = label;
16 }
17 
18 void ViewInfo::setCall(call_t call)
19 {
20  calls[0] = call;
21 }
22 
23 void ViewInfo::draw()
24 {
25  int li = 0;
26  for(std::string line : str_split(text, "\n"))
27  mvwprintw(win, text_offset_y + li++, text_offset_x, "%s", line.c_str());
28 
29  close_offset_x = (width - label_close.length()) / 2;
30  close_offset_y = height - 2;
31 
32  wattron(win, A_REVERSE);
33  mvwprintw(win, close_offset_y, close_offset_x, "%s", label_close.c_str());
34  wattroff(win, A_REVERSE);
35 }
36 
37 call_t ViewInfo::keypress(int& key)
38 {
39  switch(key)
40  {
41 
42  case KEY_MOUSE:
43  {
44  // http://pronix.linuxdelta.de/C/Linuxprogrammierung/Linuxsystemprogrammieren_C_Kurs_Kapitel10b.shtml
45  MEVENT event;
46  if(getmouse(&event) == OK && event.bstate & (BUTTON1_CLICKED | BUTTON1_DOUBLE_CLICKED))
47  {
48  size_t column = start_x + close_offset_x;
49  size_t row = start_y + close_offset_y;
50  size_t mouse_x = event.x, mouse_y = event.y;
51  if(mouse_y == row && mouse_x >= column && mouse_x < column + label_close.length())
52  key = -1; // do return from view
53  }
54  break;
55  }
56  case KEY_ENT:
57  key = -1; // do return from view
58  break;
59  default:
60  break;
61  }
62  return calls[0];
63 }
diff --git a/docs/html/view__info_8h_source.html b/docs/html/view__info_8h_source.html index 512d90e..b4c3bf6 100644 --- a/docs/html/view__info_8h_source.html +++ b/docs/html/view__info_8h_source.html @@ -75,7 +75,7 @@ $(function() {
Definition: view.h:19
diff --git a/docs/html/view__monitor_8cpp_source.html b/docs/html/view__monitor_8cpp_source.html index c1bb49e..17dc66c 100644 --- a/docs/html/view__monitor_8cpp_source.html +++ b/docs/html/view__monitor_8cpp_source.html @@ -84,7 +84,7 @@ $(function() { diff --git a/docs/html/view__monitor_8h_source.html b/docs/html/view__monitor_8h_source.html index 7943b12..36de513 100644 --- a/docs/html/view__monitor_8h_source.html +++ b/docs/html/view__monitor_8h_source.html @@ -75,7 +75,7 @@ $(function() { diff --git a/docs/html/view__promt_8cpp_source.html b/docs/html/view__promt_8cpp_source.html index d091fb4..4f30057 100644 --- a/docs/html/view__promt_8cpp_source.html +++ b/docs/html/view__promt_8cpp_source.html @@ -73,7 +73,7 @@ $(function() {
1 #include "view_promt.h"
2 
3 void ViewPromt::draw()
4 {
5  curs_set(1); // show cursor
6 
7  int li = text_offset_y;
8  int ci = 0;
9  for(std::string line : str_split(message + input, "\n"))
10  {
11  mvwprintw(win, ++li, text_offset_x, "%s", line.c_str());
12  ci = line.length() + text_offset_x;
13  }
14 
15  button_offset_x = (width - label_cancel.length() - sep.length() - label_confirm.length()) / 2;
16  button_offset_y = height - text_offset_y;
17 
18  if(selection == 0)
19  {
20  wattron(win, A_REVERSE);
21  mvwprintw(win, button_offset_y, button_offset_x, "%s", label_cancel.c_str());
22  wattroff(win, A_REVERSE);
23  mvwprintw(win, button_offset_y, button_offset_x + label_cancel.length(), "%s", sep.c_str());
24  mvwprintw(win, button_offset_y, button_offset_x + label_cancel.length() + sep.length(), "%s", label_confirm.c_str());
25  }
26  else
27  {
28  mvwprintw(win, button_offset_y, button_offset_x, "%s", label_cancel.c_str());
29  mvwprintw(win, button_offset_y, button_offset_x + label_cancel.length(), "%s", sep.c_str());
30  wattron(win, A_REVERSE);
31  mvwprintw(win, button_offset_y, button_offset_x + label_cancel.length() + sep.length(), "%s", label_confirm.c_str());
32  wattroff(win, A_REVERSE);
33  }
34  wmove(win, li, ci);
35 }
36 
37 void ViewPromt::setMessage(std::string message)
38 {
39  this->message = message;
40 }
41 
42 void ViewPromt::setConfirm(std::string name, std::function<void(int)> call)
43 {
44  label_confirm = name;
45  call_confirm = call;
46 }
47 
48 void ViewPromt::setCancel(std::string name, bool cancelable)
49 {
50  label_cancel = name;
51  this->cancelable = cancelable;
52 }
53 
54 std::string ViewPromt::getInput()
55 {
56  return input;
57 }
58 
59 std::function<void(int)> ViewPromt::keypress(int& key)
60 {
61  std::function<void(int)> ret = nullptr;
62  switch(key)
63  {
64  case KEY_BACKSPACE:
65  if(input.length())
66  input.pop_back();
67  break;
68  case '\t':
69  case KEY_LEFT:
70  case KEY_RIGHT:
71  selection = (selection + 1 ) % 2;
72  break;
73  case KEY_MOUSE:
74  {
75  // http://pronix.linuxdelta.de/C/Linuxprogrammierung/Linuxsystemprogrammieren_C_Kurs_Kapitel10b.shtml
76  MEVENT event;
77  bool hit = false;
78  if(getmouse(&event) == OK && event.bstate & (BUTTON1_CLICKED | BUTTON1_DOUBLE_CLICKED))
79  {
80  size_t column_start = start_x + button_offset_x;
81  size_t row_start = start_y + button_offset_y;
82  size_t mouse_x = event.x, mouse_y = event.y;
83  if(mouse_y == row_start)
84  {
85  if(cancelable && mouse_x >= column_start && mouse_x < column_start + label_cancel.length())
86  {
87  if(selection == 0 || event.bstate & BUTTON1_DOUBLE_CLICKED)
88  hit = true;
89  selection = 0;
90  }
91  if(mouse_x >= column_start + label_cancel.length() + sep.length() && mouse_x < column_start + label_cancel.length() + sep.length() + label_confirm.length())
92  {
93  if(selection == 1 || event.bstate & BUTTON1_DOUBLE_CLICKED)
94  hit = true;
95  selection = 1;
96  }
97  }
98  }
99  if(!hit)
100  break;
101 
102  // fall through to next case
103  [[fallthrough]];
104  }
105  case KEY_ENT:
106  if(selection == 0) // exit
107  key = -1; // do return from view
108  else
109  ret = call_confirm;
110  break;
111  default:
112  break;
113  }
114 
115  if(key >= ' ' && key <= '~')
116  input += (char) key;
117 
118  if(key != KEY_ENT)
119  repaint();
120  return ret;
121 }
diff --git a/docs/html/view__promt_8h_source.html b/docs/html/view__promt_8h_source.html index af3e350..8302f3e 100644 --- a/docs/html/view__promt_8h_source.html +++ b/docs/html/view__promt_8h_source.html @@ -75,7 +75,7 @@ $(function() { diff --git a/docs/html/view__selection_8cpp_source.html b/docs/html/view__selection_8cpp_source.html index 014a553..2d84693 100644 --- a/docs/html/view__selection_8cpp_source.html +++ b/docs/html/view__selection_8cpp_source.html @@ -73,7 +73,7 @@ $(function() {
1 #include "view_selection.h"
2 
3 void ViewSelection::draw()
4 {
5  //curs_set(0); // hide cursor
6  for(size_t i = 0; i < choices.size(); i++)
7  {
8  if(selection == i)
9  wattron(win, A_REVERSE);
10  mvwprintw(win, i + choice_offset_y, choice_offset_x, "%s", choices[i].c_str());
11  if(selection == i)
12  wattroff(win, A_REVERSE);
13  }
14 }
15 
16 void ViewSelection::addChoice(std::string name, call_t call)
17 {
18  choices.push_back(name);
19  calls.push_back(call);
20 }
21 
22 call_t ViewSelection::keypress(int& key)
23 {
24  call_t ret = nullptr;
25  switch(key)
26  {
27  case KEY_UP:
28  do
29  selection = (selection - 1 + choices.size()) % choices.size();
30  while(!choices[selection].length() && choices.size());
31  break;
32 
33  case '\t':
34  case KEY_DOWN:
35  do
36  selection = (selection + 1) % choices.size();
37  while(!choices[selection].length() && choices.size());
38  break;
39 
40  case KEY_MOUSE:
41  {
42  // http://pronix.linuxdelta.de/C/Linuxprogrammierung/Linuxsystemprogrammieren_C_Kurs_Kapitel10b.shtml
43  MEVENT event;
44  bool hit = false;
45  if(getmouse(&event) == OK && event.bstate & (BUTTON1_CLICKED | BUTTON1_DOUBLE_CLICKED))
46  {
47  size_t column_start = start_x + choice_offset_x;
48  size_t row_start = start_y + choice_offset_y;
49  size_t mouse_x = event.x, mouse_y = event.y;
50  for(size_t i = 0; i < choices.size(); i++)
51  if(choices[i].length() && mouse_y == row_start + i && mouse_x >= column_start && mouse_x < column_start + choices[i].length())
52  {
53  if(selection == i || event.bstate & BUTTON1_DOUBLE_CLICKED)
54  hit = true;
55  selection = i;
56  }
57  }
58  if(!hit)
59  break;
60 
61  // fall through to next case
62  [[fallthrough]];
63  }
64 
65  case KEY_ENT:
66  if(selection == choices.size() - 1) // exit
67  key = -1; // do return from view
68  else
69  ret = calls[selection];
70  break;
71  default:
72  break;
73  }
74  repaint();
75  return ret;
76 }
diff --git a/docs/html/view__selection_8h_source.html b/docs/html/view__selection_8h_source.html index 9d49827..71dc687 100644 --- a/docs/html/view__selection_8h_source.html +++ b/docs/html/view__selection_8h_source.html @@ -75,7 +75,7 @@ $(function() {