|
@@ -1,14 +1,10 @@
|
|
|
#include "timer.hpp"
|
|
#include "timer.hpp"
|
|
|
-#include <algorithm>
|
|
|
|
|
#include <chrono>
|
|
#include <chrono>
|
|
|
#include <clocale>
|
|
#include <clocale>
|
|
|
#include <cstdio>
|
|
#include <cstdio>
|
|
|
#include <ctime>
|
|
#include <ctime>
|
|
|
-#include <functional>
|
|
|
|
|
-#include <iostream>
|
|
|
|
|
#include <memory>
|
|
#include <memory>
|
|
|
#include <ncurses.h>
|
|
#include <ncurses.h>
|
|
|
-#include <string>
|
|
|
|
|
#include <thread>
|
|
#include <thread>
|
|
|
#include <unistd.h>
|
|
#include <unistd.h>
|
|
|
#include <utility>
|
|
#include <utility>
|
|
@@ -17,7 +13,6 @@
|
|
|
/*
|
|
/*
|
|
|
todo
|
|
todo
|
|
|
figure out namespaces, using, and auto
|
|
figure out namespaces, using, and auto
|
|
|
- formalize timer struct
|
|
|
|
|
read about std function and std bind
|
|
read about std function and std bind
|
|
|
try to do with objects / classes instead
|
|
try to do with objects / classes instead
|
|
|
centralize into event sender and subscriber
|
|
centralize into event sender and subscriber
|
|
@@ -29,63 +24,51 @@ void myupdatedisplay(const timer &timer_input) {
|
|
|
"test: █");
|
|
"test: █");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-std::vector<int> mynumbers = {1, 2, 3, 4, 5, 6, 7, 8, 9};
|
|
|
|
|
-
|
|
|
|
|
-void swapnumbers(std::vector<int> &input_numbers) {
|
|
|
|
|
- for (size_t i = 0; i < input_numbers.size() / 2; ++i) {
|
|
|
|
|
- int temp = input_numbers[i];
|
|
|
|
|
- input_numbers[i] = input_numbers[input_numbers.size() -1 - i];
|
|
|
|
|
- input_numbers[input_numbers.size() -1 - i] = temp;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+void createbalk(const timer &timer_input, cchar_t &input_char) {
|
|
|
|
|
+ int ticnt = timer_input.triggercounter;
|
|
|
|
|
+ mvwvline_set(stdscr, LINES - ticnt, ticnt, &input_char, ticnt);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-void displaynumbers(int myy, std::vector<int> &input_numbers){
|
|
|
|
|
|
|
+std::vector<int> mynumbers = {1, 2, 3, 4, 5, 6, 7, 8, 9};
|
|
|
|
|
+
|
|
|
|
|
+void displaynumbers(int myy, std::vector<int> &input_numbers) {
|
|
|
for (size_t i = 0; i < input_numbers.size(); i++) {
|
|
for (size_t i = 0; i < input_numbers.size(); i++) {
|
|
|
- mvprintw(myy, 10+i, "%d,", input_numbers[i]);
|
|
|
|
|
|
|
+ mvprintw(myy, 10 + i, "%d,", input_numbers[i]);
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
-void createbalk(const timer &timer_input, cchar_t &input_char) {
|
|
|
|
|
- int ticnt = timer_input.triggercounter;
|
|
|
|
|
- mvwvline_set(stdscr, LINES - ticnt, ticnt, &input_char, ticnt);
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-void myinitialize(){
|
|
|
|
|
|
|
+void myinitialize() {
|
|
|
setlocale(LC_ALL, "");
|
|
setlocale(LC_ALL, "");
|
|
|
initscr();
|
|
initscr();
|
|
|
nodelay(stdscr, FALSE);
|
|
nodelay(stdscr, FALSE);
|
|
|
refresh();
|
|
refresh();
|
|
|
start_color();
|
|
start_color();
|
|
|
- init_pair(1, COLOR_BLUE, COLOR_WHITE);
|
|
|
|
|
|
|
+ init_pair(1, COLOR_RED, COLOR_GREEN);
|
|
|
attron(COLOR_PAIR(1));
|
|
attron(COLOR_PAIR(1));
|
|
|
printw("Hello World! 🌍 テスト 测试");
|
|
printw("Hello World! 🌍 テスト 测试");
|
|
|
- }
|
|
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
|
|
|
int main() {
|
|
int main() {
|
|
|
myinitialize();
|
|
myinitialize();
|
|
|
- const wchar_t mywch = L'█';
|
|
|
|
|
- cchar_t myc_char;
|
|
|
|
|
- setcchar(&myc_char, &mywch, A_NORMAL, 0, NULL);
|
|
|
|
|
- // printf("verification\n");
|
|
|
|
|
- auto starttime = std::chrono::steady_clock::now(); // initial starttime
|
|
|
|
|
|
|
+ cchar_t my_c_char = {.attr= A_NORMAL, .chars={L'█'}, .ext_color = 0};
|
|
|
|
|
|
|
|
auto myaction = std::make_unique<swapaction>(mynumbers);
|
|
auto myaction = std::make_unique<swapaction>(mynumbers);
|
|
|
- auto clocktimer = std::make_unique<timer>(
|
|
|
|
|
- "secondsprinter", 1, 10,
|
|
|
|
|
- std::move(myaction));
|
|
|
|
|
|
|
+ auto clocktimer = std::make_unique<timer>("secondsprinter", 1, 10, std::move(myaction));
|
|
|
timermanager mytimermanager;
|
|
timermanager mytimermanager;
|
|
|
mytimermanager.addtimer(std::move(clocktimer));
|
|
mytimermanager.addtimer(std::move(clocktimer));
|
|
|
- //swapnumbers(mynumbers);
|
|
|
|
|
- displaynumbers(2,mynumbers);
|
|
|
|
|
- mvprintw(5, 5, "timer added");
|
|
|
|
|
|
|
+ displaynumbers(2, mynumbers);
|
|
|
|
|
+
|
|
|
// calculate delta between current and previous time
|
|
// calculate delta between current and previous time
|
|
|
while (true) {
|
|
while (true) {
|
|
|
- auto currenttime = std::chrono::steady_clock::now();
|
|
|
|
|
- std::chrono::duration<double> myDeltaTime = currenttime - starttime;
|
|
|
|
|
- double dtime = myDeltaTime.count();
|
|
|
|
|
- mytimermanager.updatetimers(dtime);
|
|
|
|
|
- displaynumbers(3,mynumbers);
|
|
|
|
|
- starttime = currenttime;
|
|
|
|
|
|
|
+ erase();
|
|
|
|
|
+
|
|
|
|
|
+ mytimermanager.updatetimers();
|
|
|
|
|
+
|
|
|
|
|
+ displaynumbers(3, mynumbers);
|
|
|
|
|
+
|
|
|
|
|
+ refresh();
|
|
|
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
|
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
|
|
}
|
|
}
|
|
|
|
|
|