This commit is contained in:
Inventor Xtreme 2026-05-07 23:10:32 -04:00
parent 07c3d31d38
commit 10927a226f
8 changed files with 252 additions and 95 deletions

View file

@ -1,9 +1,9 @@
CC = gcc
CXX = g++
CPPFLAGS = -g #-O3 -ffast-math
CFLAGS = -g #-O3 -ffast-math
LDFLAGS = -g #-O3 -ffast-math
CPPFLAGS = -std=c++20 -g -Wall -Wextra -Wpedantic #-O3 -ffast-math
CFLAGS = -g -Wall -Wextra -Wpedantic #-O3 -ffast-math
LDFLAGS = -g -Wall -Wextra -Wpedantic #-O3 -ffast-math
LDLIBS = -lfltk -lcurl -lfltk_images
@ -33,7 +33,7 @@ $(EXE): $(OBJ) | $(BIN_DIR)
$(CXX) $(LDFLAGS) $^ $(LDLIBS) -o $@
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c | $(OBJ_DIR)
$(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
$(CC) $(CFLAGS) -c $< -o $@
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp | $(OBJ_DIR)

View file

@ -32,9 +32,8 @@ void Curl::seturl(std::string url) {
curl_easy_setopt(handle, CURLOPT_WRITEDATA, &data);
}
std::string Curl::get() {
curl_easy_perform(handle);
return data;
CURLcode Curl::get() {
return curl_easy_perform(handle);
}
@ -42,3 +41,4 @@ std::string Curl::get() {

View file

@ -14,7 +14,7 @@ struct Curl {
void seturl(std::string url);
std::string get();
CURLcode get();
};

65
src/custom_types.cpp Normal file
View file

@ -0,0 +1,65 @@
#include "custom_types.hpp"
#include "curlwrap.hpp"
Person::Person(std::string &y, std::string &n) : year(y), name(n) {}
std::string Person::toString() const {
return "{(Person): " + year + ", " + name + "}";
}
std::ostream &operator<<(std::ostream &os, const Person &e) {
// os << "{(Person): " << e.year << ", " << e.name << "}";
os << e.toString();
return os;
}
std::string BasicEntry::toString() const {
return "{(BasicEntry): " + A.toString() + ", " + B.toString() + ", " + matchlink + +", " +
std::to_string(Apercent) + "%, " + std::to_string(Bpercent) + "%}";
}
std::ostream &operator<<(std::ostream &os, const BasicEntry &e) {
// os << "{(BasicEntry): " << e.A << ", " << e.B << ", " << e.matchlink << "}";
os << e.toString();
return os;
}
ComplexEntry::ComplexEntry(BasicEntry basic) : basic(basic) {
Curl net;
auto downbase = basic.matchlink;
auto Adown = downbase.substr(0, downbase.length() - 5) + "-0.html";
auto Bdown = downbase.substr(0, downbase.length() - 5) + "-1.html";
net.seturl(Adown);
auto ACODE = net.get();
if (ACODE != CURLE_OK) {
throw("A_NET_ERR");
} else {
A_buf = net.data;
}
net.seturl(Bdown);
auto BCODE = net.get();
if (BCODE != CURLE_OK) {
throw("B_NET_ERR");
} else {
B_buf = net.data;
}
}

57
src/custom_types.hpp Normal file
View file

@ -0,0 +1,57 @@
#ifndef CUSTOM_TYPES_HEADER
#define CUSTOM_TYPES_HEADER
#include "curlwrap.hpp"
#include <string>
struct Person {
std::string year;
std::string name;
Person(std::string &y, std::string &n);
std::string toString() const;
friend std::ostream& operator<<(std::ostream &os, const Person &e);
};
std::ostream& operator<<(std::ostream &os, const Person &e);
struct BasicEntry {
Person A;
Person B;
std::string matchlink;
int Apercent;
int Bpercent;
std::string toString() const;
friend std::ostream &operator<<(std::ostream &os, const BasicEntry &e);
};
std::ostream &operator<<(std::ostream &os, const BasicEntry &e);
struct ComplexEntry { //TODO: Keep track of match regions
BasicEntry basic;
std::string A_buf;
std::string B_buf;
ComplexEntry(BasicEntry basic);
};
#endif

View file

@ -8,6 +8,7 @@
#include "images.h"
#include "summarymanager.hpp"
#include "testcpp.hpp"
#include "custom_types.hpp"
#include <FL/Fl.H>
#include <FL/Fl_Box.H>
@ -22,60 +23,16 @@
#include <string>
#include <vector>
using namespace std;
struct Person {
std::string year;
std::string name;
Person(std::string &y, std::string &n) : year(y), name(n) {}
std::string toString() const {
return "{(Person): " + year + ", " + name + "}";
}
};
std::ostream &operator<<(std::ostream &os, const Person &e) {
// os << "{(Person): " << e.year << ", " << e.name << "}";
os << e.toString();
return os;
}
struct BasicEntry {
Person A;
Person B;
std::string matchlink;
int Apercent;
int Bpercent;
std::string toString() const {
return "{(BasicEntry): " + A.toString() + ", " + B.toString() + ", " + matchlink + +", " +
std::to_string(Apercent) + "%, " + std::to_string(Bpercent) + "%}";
}
};
std::ostream &operator<<(std::ostream &os, const BasicEntry &e) {
// os << "{(BasicEntry): " << e.A << ", " << e.B << ", " << e.matchlink << "}";
os << e.toString();
return os;
}
struct Selected {
Fl_Multi_Browser &browser;
Selected(Fl_Multi_Browser &browser_in) : browser(browser_in) {}
};
void show_callback(Fl_Widget *w, void *data) {
Selected *rdata = (Selected *)data;
void show_callback(Fl_Widget *w, void * data);
auto s = rdata->browser.size() + 1;
for (size_t i = 0; i < s; i++) {
if (rdata->browser.selected(i)) {
fl_alert("%s", rdata->browser.text(i));
}
}
}
std::vector<BasicEntry> MakeEntires(std::string filename) {
@ -206,12 +163,14 @@ struct MainGui : Fl_Window {
Fl_Tile *tilebox;
Fl_Multi_Browser *list;
SummaryManager *summaryEditor;
State s;
MainGui() : Fl_Window(0, 0, 1000, 750, "MossMan :3") {
topbar = new Topbar(0, 0, 1000, 50);
tilebox = new Fl_Tile(0, 50, 1000, 700); // parent is maingui, will be freed at decon
list = new Fl_Multi_Browser(0, 50, 150, 700);
summaryEditor = new SummaryManager(150, 50, 850, 700);
list = new Fl_Multi_Browser(0, 50, 250, 700);
summaryEditor = new SummaryManager(250, 50, 750, 700);
topbar->inspect->callback(show_callback, this);
tilebox->end();
@ -219,54 +178,50 @@ struct MainGui : Fl_Window {
resizable(tilebox);
}
void updateList(std::string filename) {
s.entries = MakeEntires(filename);
for (auto e : s.entries) {
std::cout << e << std::endl;
}
for (size_t i = 0; i < s.entries.size(); i++) {
auto e = s.entries[i];
auto h = ((e.A.year + "/" + e.A.name) + " and " + (e.B.year + "/" + e.B.name) + " (" +
std::to_string(e.Apercent) + "%, " + std::to_string(e.Bpercent) + "%)");
list->add(h.c_str(), (void *) i);
}
}
};
void show_callback(Fl_Widget *w, void *data) {
MainGui *rdata = (MainGui *)data;
auto s = rdata->list->size() + 1;
for (size_t i = 0; i < s; i++) {
if (rdata->list->selected(i)) {
fl_alert("%s", rdata->list->text(i));
auto c = ComplexEntry(rdata->s.entries[ (size_t) rdata->list->data(i)]);
rdata->summaryEditor->addComplex(c);
}
}
}
int main(int argc, char **argv) {
if (argc < 2) {
std::cout << "Not enough args" << std::endl;
exit(1);
}
State s;
s.entries = MakeEntires(argv[1]);
for (auto e : s.entries) {
std::cout << e << std::endl;
}
Fl::scheme("base");
// auto window = std::make_unique<Fl_Window>(300, 300, 300, 300, "MossMan :D");
// auto group = std::make_unique<Fl_Group>(0,0,300,300);
// auto group2 = std::make_unique<Fl_Group>(0, 0, 300, 50);
// auto box = std::make_unique<Fl_Box>(0,0,100,50,"MossMan");
// box->labelsize(36);
// box->labelfont(FL_TIMES | FL_BOLD);
// box->align(FL_ALIGN_INSIDE | FL_ALIGN_TOP_LEFT);
// auto button = std::make_unique<Fl_Button>(250, 0, 50, 50);
// auto button2 = std::make_unique<Fl_Button>(200,0, 50, 50);
// group2->resizable(*box);
// group2->end();
// auto group3 = std::make_unique<Fl_Flex>(0,51,300, 250, Fl_Flex::HORIZONTAL);
// // auto browser = std::make_unique<Fl_Multi_Browser>(0,51,300,250);
// // auto browser2 = std::make_unique<Fl_Multi_Browser>(0,51,300,250);
// auto browser = std::make_unique<Fl_Multi_Browser>(0,0,0,0);
// auto tabs = std::make_unique<SummaryManager>(0,0,300,300);
// //auto browser2 = std::make_unique<Fl_Multi_Browser>(0,0,0,0);
// tabs->hide();
// group3->end();
// std::pair<Fl_Flex&, SummaryManager&> saved(*group3, *tabs);
// button2->callback(changelayout,&saved);
// auto icon = std::make_unique<Fl_PNG_Image>("Inspect", icon_inspect_file_png,
// icon_inspect_file_png_len); button->image(*icon); button->tooltip("Inspect Entr(ies)");
// for (auto e : s.entries) {
// auto h = ((e.A.year + "/" + e.A.name) + " and " + (e.B.year + "/" + e.B.name) + " (" +
// std::to_string(e.Apercent) + "%, " + std::to_string(e.Bpercent) + "%)");
// browser->add(h.c_str());
// }
// group->resizable(*group3);
// group->end();
@ -283,6 +238,7 @@ int main(int argc, char **argv) {
// window->show();
MainGui x;
x.updateList(argv[1]);
x.show();
return Fl::run();

View file

@ -1,15 +1,39 @@
#include "summarymanager.hpp"
#include "custom_types.hpp"
#include <FL/Enumerations.H>
#include <FL/Fl.H>
#include <FL/Fl_Button.H>
#include <FL/Fl_Group.H>
#include <FL/Fl_Tabs.H>
#include <FL/Fl_Text_Buffer.H>
#include <FL/Fl_Text_Display.H>
#include <FL/Fl_Window.H>
#include <iostream>
#include <memory>
#include <string>
Fl_Text_Display::Style_Table_Entry table[] {
{ FL_BLACK, FL_COURIER, FL_NORMAL_SIZE },
{ FL_RED, FL_COURIER, FL_NORMAL_SIZE },
};
void SummaryCallback(Fl_Widget * w, void * data) {
auto sum = (Summary *) w;
if (Fl::callback_reason() == FL_REASON_CLOSED) {
std::cout << "CLOSED " << sum->title << std::endl;
}
Fl::delete_widget(w);
w->parent()->redraw();
}
SummaryManager::SummaryManager(int x, int y, int w, int h)
: Fl_Group(x, y, w, h), tabs(x, y, w, h) {
Fl_Group *grp1 = new Fl_Group(x, y + 30, w, h - 30, "Tab1");
grp1->when(FL_WHEN_CLOSED);
{
Fl_Window *win1 = new Fl_Window(x, y + 30, w, h - 30, "Tab1W");
std::cout << "here" << std::endl;
@ -42,4 +66,44 @@ SummaryManager::SummaryManager(int x, int y, int w, int h)
tabs.resizable(grp1);
end();
box(FL_FLAT_BOX);
}
void style_unfinn_cb(int, void* a) {}
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) + "%)";
this->label(title.c_str());
this->when(FL_WHEN_CLOSED);
Fl_Window * win = new Fl_Window(x, y, 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_Buffer * s1buff = new Fl_Text_Buffer();
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->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_Buffer * s2buff = new Fl_Text_Buffer();
s2->buffer(s2buff);
s2->buffer()->insert(0, c.B_buf.c_str());
text_boxes->end();
win->end();
this->end();
this->resizable(win);
win->resizable(text_boxes);
this->callback(SummaryCallback);
}
void SummaryManager::addComplex(ComplexEntry& c) {
tabs.add(new Summary(c, this->x(), this->y() +30, this->w(), this->h() - 30));
}

View file

@ -1,17 +1,32 @@
#ifndef SUMMARYMANAGER_HEADER
#define SUMMARYMANAGER_HEADER
#include "custom_types.hpp"
#include <FL/Enumerations.H>
#include <FL/Fl.H>
#include <FL/Fl_Button.H>
#include <FL/Fl_Group.H>
#include <FL/Fl_Tabs.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Text_Display.H>
#include <memory>
#include <vector>
void SummaryCallback(Fl_Widget * w, void * data);
struct Summary : Fl_Group {
std::string title;
Summary(ComplexEntry c, int x, int y, int w, int h);
};
struct SummaryManager : Fl_Group {
SummaryManager(int x, int y, int w, int h);
Fl_Tabs tabs;
std::vector<Fl_Button*> items;
std::vector<Summary*> items;
void addComplex(ComplexEntry& c);
};