-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.cpp
More file actions
152 lines (138 loc) · 3.48 KB
/
test.cpp
File metadata and controls
152 lines (138 loc) · 3.48 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
//
// Created by 909 DL on 2025/7/20.
//
/*
* Copyright (C) 2025 DL909 - This file has been modified from its original version.
*
* Licensed under the MIT License.
* https://opensource.org/licenses/MIT
*/
#include <iostream>
#include <pugixml.hpp>
#include <ncurses.h>
#include "Tasks/Task.h"
#include "fuzzy_match.h"
#include "Util/util.h"
void create_xml()
{
pugi::xml_document doc;
pugi::xml_node root = doc.append_child("root");
pugi::xml_node task = root.append_child("task");
pugi::xml_node type = task.append_child("type");
type.text().set("one_line_task");
pugi::xml_node index = task.append_child("index");
index.text().set(0);
pugi::xml_node data = task.append_child("data");
pugi::xml_node command = data.append_child("command");
command.text().set("ls");
pugi::xml_node directory = data.append_child("path");
directory.text().set("/Users/909dl/myProgramming");
// 保存到文件
if (doc.save_file("/Users/909dl/.command_mark.xml")) {
std::cout << "XML saved successfully." << std::endl;
} else {
std::cerr << "Failed to save XML file." << std::endl;
}
}
// test for Task/Task.h TaskFactory::get_task_type_list()
void test1()
{
for (const auto& t : TaskFactory::get_task_type_list())
{
std::cout << t << std::endl;
}
}
// test for activate curses for several times
void test2()
{
initscr();
noecho();
cbreak();
mvprintw(0,0,"Hello World");
char c = getch();
echo();
endwin();
std::cout << static_cast<int>(c) << std::endl;
c = getchar();
std::cout << static_cast<int>(c) << std::endl;
initscr();
noecho();
cbreak();
mvprintw(1,0,"Hello World2");
c = getch();
echo();
endwin();
std::cout << static_cast<int>(c) << std::endl;
}
void test3()
{
pugi::xml_document doc;
doc.load_file("/Users/909dl/myProgramming/programming/cpp/ClionProject/CppCommandMark/test.xml");
pugi::xml_node root = doc.child("root");
if (root.empty())
{
root = doc.append_child("root");
}
root.append_child("task");
if (UserTaskFactory::create("one_line_task",0, root) == EXIT_SUCCESS)
{
print_doc(doc,"title");
}else
{
std::cout << "t" << std::endl;
}
}
void test4()
{
std::cout << begin_with_part_of("tm experiment","tmux") << std::endl;
}
void test5()
{
int score = 0;
std::string new_input = "tm experiment";
new_input = new_input.substr(first_not_space_in_text(new_input));
int a = begin_with_part_of(new_input, "tmux");
new_input = new_input.substr(a);
a = first_not_space_in_text(new_input);
new_input = new_input.substr(a);
std::cout << new_input << std::endl;
}
int main() {
test5();
return 0;
}
// int main()
// {
// initscr();
// noecho();
// cbreak();
// mvprintw(0,0,"Hello World");
// const char c = getch();
// echo();
// endwin();
// std::cout << static_cast<int>(c) << std::endl;
// return 0;
// }
// int main()
// {
// std::cout << fuzzy_match("tt","tt t") << std::endl;
// const node * p = match_end;
// int index = -1;
// std::vector<int> array;
// if (p == nullptr)
// {
// std::cout << "t" << std::endl;
// }
// while (p != nullptr)
// {
// index += p->number + 1;
// array.push_back(index);
// p = p->next;
// }
// for (const auto i : array)
// {
// std::cout << i << std::endl;
// }
// recursive_delete(match_end);
//
// }