highlight
This commit is contained in:
parent
0c4b1154ba
commit
1e0bb72827
5 changed files with 150 additions and 17 deletions
2
Makefile
2
Makefile
|
|
@ -1,7 +1,7 @@
|
||||||
CC = gcc
|
CC = gcc
|
||||||
CXX = g++
|
CXX = g++
|
||||||
|
|
||||||
CPPFLAGS = -std=c++20 -g -Wall -Wextra -Wpedantic #-O3 -ffast-math
|
CPPFLAGS = -std=c++26 -g -Wall -Wextra -Wpedantic #-O3 -ffast-math
|
||||||
CFLAGS = -g -Wall -Wextra -Wpedantic #-O3 -ffast-math
|
CFLAGS = -g -Wall -Wextra -Wpedantic #-O3 -ffast-math
|
||||||
LDFLAGS = -g -Wall -Wextra -Wpedantic #-O3 -ffast-math
|
LDFLAGS = -g -Wall -Wextra -Wpedantic #-O3 -ffast-math
|
||||||
LDLIBS = -lfltk -lcurl -lfltk_images
|
LDLIBS = -lfltk -lcurl -lfltk_images
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
#include <cstddef>
|
||||||
|
|
||||||
unsigned char icon_inspect_file_png[] = {
|
unsigned char icon_inspect_file_png[] = {
|
||||||
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d,
|
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d,
|
||||||
0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x30,
|
0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x30,
|
||||||
|
|
@ -64,4 +66,4 @@ unsigned char icon_inspect_file_png[] = {
|
||||||
0x30, 0x7f, 0x3f, 0xa5, 0xb2, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e,
|
0x30, 0x7f, 0x3f, 0xa5, 0xb2, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e,
|
||||||
0x44, 0xae, 0x42, 0x60, 0x82
|
0x44, 0xae, 0x42, 0x60, 0x82
|
||||||
};
|
};
|
||||||
unsigned int icon_inspect_file_png_len = 761;
|
size_t icon_inspect_file_png_len = 761;
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,8 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
|
||||||
|
#include <cstddef>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
struct Selected {
|
struct Selected {
|
||||||
|
|
@ -203,7 +205,7 @@ void show_callback(Fl_Widget *w, void *data) {
|
||||||
|
|
||||||
for (size_t i = 0; i < s; i++) {
|
for (size_t i = 0; i < s; i++) {
|
||||||
if (rdata->list->selected(i)) {
|
if (rdata->list->selected(i)) {
|
||||||
fl_alert("%s", rdata->list->text(i));
|
//fl_alert("%s", rdata->list->text(i));
|
||||||
auto c = ComplexEntry(rdata->s.entries[ (size_t) rdata->list->data(i)]);
|
auto c = ComplexEntry(rdata->s.entries[ (size_t) rdata->list->data(i)]);
|
||||||
rdata->summaryEditor->addComplex(c);
|
rdata->summaryEditor->addComplex(c);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,24 +10,39 @@
|
||||||
#include <FL/Fl_Window.H>
|
#include <FL/Fl_Window.H>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <regex>
|
||||||
|
#include <sstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <string_view>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
|
|
||||||
Fl_Text_Display::Style_Table_Entry table[] {
|
Fl_Text_Display::Style_Table_Entry table[] {
|
||||||
{ FL_BLACK, FL_COURIER, FL_NORMAL_SIZE },
|
{ FL_BLACK, FL_COURIER, FL_NORMAL_SIZE},
|
||||||
{ FL_RED, FL_COURIER, FL_NORMAL_SIZE },
|
{ FL_RED, FL_COURIER, FL_NORMAL_SIZE },
|
||||||
|
{ FL_GREEN, FL_COURIER, FL_NORMAL_SIZE },
|
||||||
|
{ FL_BLUE, FL_COURIER, FL_NORMAL_SIZE },
|
||||||
|
{ FL_CYAN, FL_COURIER, FL_NORMAL_SIZE },
|
||||||
|
{ FL_MAGENTA, FL_COURIER, FL_NORMAL_SIZE },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
T P(T i) {
|
||||||
|
std::cout << i << std::endl;
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void SummaryCallback(Fl_Widget * w, void * data) {
|
void SummaryCallback(Fl_Widget * w, void * data) {
|
||||||
auto sum = (Summary *) w;
|
auto sum = (Summary *) w;
|
||||||
if (Fl::callback_reason() == FL_REASON_CLOSED) {
|
if (Fl::callback_reason() == FL_REASON_CLOSED) {
|
||||||
std::cout << "CLOSED " << sum->title << std::endl;
|
std::cout << "CLOSED " << sum->title << std::endl;
|
||||||
}
|
auto tabs = w->parent();
|
||||||
Fl::delete_widget(w);
|
Fl::delete_widget(w);
|
||||||
w->parent()->redraw();
|
tabs->redraw();
|
||||||
}
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
SummaryManager::SummaryManager(int x, int y, int w, int h)
|
SummaryManager::SummaryManager(int x, int y, int w, int h)
|
||||||
|
|
@ -69,7 +84,88 @@ SummaryManager::SummaryManager(int x, int y, int w, int h)
|
||||||
box(FL_FLAT_BOX);
|
box(FL_FLAT_BOX);
|
||||||
}
|
}
|
||||||
|
|
||||||
void style_unfinn_cb(int, void* a) {}
|
void style_unfinn_cb(int, void *a) {}
|
||||||
|
|
||||||
|
std::string NumberToStyle(const int n) {
|
||||||
|
const int s = n % 5;
|
||||||
|
switch(s) {
|
||||||
|
case 0: return "B";
|
||||||
|
case 1: return "C";
|
||||||
|
case 2: return "D";
|
||||||
|
case 3: return "E";
|
||||||
|
case 4: return "F";
|
||||||
|
default: throw "err";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string& replaceAllInPlace(std::string& in, std::string_view from, std::string_view to) {
|
||||||
|
size_t pos = in.find(from, 0);
|
||||||
|
|
||||||
|
while(pos != std::string::npos) {
|
||||||
|
in.replace(pos, from.length(), to);
|
||||||
|
|
||||||
|
|
||||||
|
pos = in.find(from, pos);
|
||||||
|
|
||||||
|
}
|
||||||
|
return in;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
std::string htmlCodesToNormal(std::string in) {
|
||||||
|
|
||||||
|
replaceAllInPlace(in, ">", ">");
|
||||||
|
replaceAllInPlace(in, "<", "<");
|
||||||
|
|
||||||
|
return in;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void LoadReport(std::string s, Fl_Text_Buffer * text, Fl_Text_Buffer * style) {
|
||||||
|
std::istringstream stream(s);
|
||||||
|
|
||||||
|
std::string line;
|
||||||
|
|
||||||
|
std::string currentval = "A";
|
||||||
|
|
||||||
|
std::regex startcolorpatt(".*IMG SRC=\"http://moss[.]stanford[.]edu/bitmaps/tm_(\\d+)_(\\d+)[.]gif.*");
|
||||||
|
|
||||||
|
std::regex endcolorpatt("</FONT>(.*)");
|
||||||
|
|
||||||
|
|
||||||
|
while (std::getline(stream, line)) {
|
||||||
|
std::smatch matches;
|
||||||
|
std::string formatted = htmlCodesToNormal(line);
|
||||||
|
|
||||||
|
if(std::regex_search(formatted, matches, startcolorpatt)) {
|
||||||
|
//std::cout << v << std::endl;
|
||||||
|
currentval = NumberToStyle(std::stoi(matches[1]));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(std::regex_search(formatted, matches, endcolorpatt)) {
|
||||||
|
formatted = matches[1];
|
||||||
|
currentval = "A";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
text->append(formatted.c_str());
|
||||||
|
text->append("\n");
|
||||||
|
|
||||||
|
for (size_t i = 0; i < formatted.length()+1; i++) {
|
||||||
|
style->append(currentval.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Summary::Summary(ComplexEntry c, int x, int y, int w, int h) : Fl_Group(x, y, w, h, "Loading...") {
|
Summary::Summary(ComplexEntry c, int x, int y, int w, int h) : Fl_Group(x, y, w, h, "Loading...") {
|
||||||
title = c.basic.A.name + "+" + c.basic.B.name + "(" + std::to_string(c.basic.Apercent) + "%," + std::to_string(c.basic.Bpercent) + "%)";
|
title = c.basic.A.name + "+" + c.basic.B.name + "(" + std::to_string(c.basic.Apercent) + "%," + std::to_string(c.basic.Bpercent) + "%)";
|
||||||
|
|
@ -80,17 +176,33 @@ Summary::Summary(ComplexEntry c, int x, int y, int w, int h) : Fl_Group(x, y, w,
|
||||||
Fl_Group * text_boxes = new Fl_Group(0,0,w,h);
|
Fl_Group * text_boxes = new Fl_Group(0,0,w,h);
|
||||||
|
|
||||||
Fl_Text_Display * s1 = new Fl_Text_Display(0, 0, w/2, h);
|
Fl_Text_Display * s1 = new Fl_Text_Display(0, 0, w/2, h);
|
||||||
Fl_Text_Buffer * s1buff = new Fl_Text_Buffer();
|
s1buff = new Fl_Text_Buffer();
|
||||||
Fl_Text_Buffer * s1style_buff = new Fl_Text_Buffer();
|
s1style_buff = new Fl_Text_Buffer();
|
||||||
s1style_buff->insert(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA");
|
|
||||||
s1->highlight_data(s1style_buff, table , 2, 'A', style_unfinn_cb, 0);
|
s1->highlight_data(s1style_buff, table , sizeof(table)/sizeof(table[0]), 'A', style_unfinn_cb, 0);
|
||||||
s1->buffer(s1buff);
|
s1->buffer(s1buff);
|
||||||
std::cout << c.A_buf.c_str() << std::endl;
|
|
||||||
s1->insert(c.A_buf.c_str());
|
|
||||||
Fl_Text_Display * s2 = new Fl_Text_Display(w/2, 0, w/2, h);
|
Fl_Text_Display * s2 = new Fl_Text_Display(w/2, 0, w/2, h);
|
||||||
Fl_Text_Buffer * s2buff = new Fl_Text_Buffer();
|
s2buff = new Fl_Text_Buffer();
|
||||||
|
s2style_buff = new Fl_Text_Buffer();
|
||||||
|
|
||||||
|
s2->highlight_data(s2style_buff, table, sizeof(table)/sizeof(table[0]), 'A', style_unfinn_cb, 0);
|
||||||
s2->buffer(s2buff);
|
s2->buffer(s2buff);
|
||||||
s2->buffer()->insert(0, c.B_buf.c_str());
|
|
||||||
|
|
||||||
|
|
||||||
|
// s1style_buff->insert(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA");
|
||||||
|
// std::cout << c.A_buf.c_str() << std::endl;
|
||||||
|
// s1->insert(c.A_buf.c_str());
|
||||||
|
|
||||||
|
LoadReport(c.A_buf, s1buff, s1style_buff);
|
||||||
|
LoadReport(c.B_buf, s2buff, s2style_buff);
|
||||||
|
|
||||||
|
// s2->buffer()->insert(0, c.B_buf.c_str());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
text_boxes->end();
|
text_boxes->end();
|
||||||
win->end();
|
win->end();
|
||||||
this->end();
|
this->end();
|
||||||
|
|
@ -98,7 +210,17 @@ Summary::Summary(ComplexEntry c, int x, int y, int w, int h) : Fl_Group(x, y, w,
|
||||||
win->resizable(text_boxes);
|
win->resizable(text_boxes);
|
||||||
|
|
||||||
this->callback(SummaryCallback);
|
this->callback(SummaryCallback);
|
||||||
|
}
|
||||||
|
|
||||||
|
Summary::~Summary() {
|
||||||
|
std::cout << "HERE" << std::endl;
|
||||||
|
|
||||||
|
this->clear();
|
||||||
|
|
||||||
|
delete s1buff;
|
||||||
|
delete s2buff;
|
||||||
|
delete s1style_buff;
|
||||||
|
delete s2style_buff;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@
|
||||||
#include <FL/Fl_Button.H>
|
#include <FL/Fl_Button.H>
|
||||||
#include <FL/Fl_Group.H>
|
#include <FL/Fl_Group.H>
|
||||||
#include <FL/Fl_Tabs.H>
|
#include <FL/Fl_Tabs.H>
|
||||||
|
#include <FL/Fl_Text_Buffer.H>
|
||||||
#include <FL/Fl_Window.H>
|
#include <FL/Fl_Window.H>
|
||||||
#include <FL/Fl_Text_Display.H>
|
#include <FL/Fl_Text_Display.H>
|
||||||
|
|
||||||
|
|
@ -17,7 +18,13 @@ void SummaryCallback(Fl_Widget * w, void * data);
|
||||||
|
|
||||||
struct Summary : Fl_Group {
|
struct Summary : Fl_Group {
|
||||||
std::string title;
|
std::string title;
|
||||||
|
Fl_Text_Buffer * s1buff;
|
||||||
|
Fl_Text_Buffer * s1style_buff;
|
||||||
|
Fl_Text_Buffer * s2buff;
|
||||||
|
Fl_Text_Buffer * s2style_buff;
|
||||||
|
|
||||||
Summary(ComplexEntry c, int x, int y, int w, int h);
|
Summary(ComplexEntry c, int x, int y, int w, int h);
|
||||||
|
~Summary();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue