Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
92825a7
Now prints to terminal. Needs fix for downloading as config download …
Aug 14, 2018
a47ab99
Merge pull request #1 from CodeOhms/gimxDownloader
CodeOhms Aug 14, 2018
f80e384
Can now download list of config files
Sep 10, 2018
576a24e
Merge branch 'master' of https://github.com/matlo/GIMX
Sep 10, 2018
56624e0
Fixed selection menu window
Sep 12, 2018
bb7d697
Grab updates from main project
Sep 12, 2018
119a325
Added basic debugging options for Makedefs
Sep 12, 2018
d567cf8
Merge branch 'master' of https://github.com/matlo/GIMX
Sep 12, 2018
ab829f6
Quick fix for last page not always showing when jumping from first to…
Sep 13, 2018
f7fc42d
Fixed selection menu. Added page number top right. Added functionalit…
Sep 15, 2018
79a5056
Merge updates for new gimxFileDownloader utility
Sep 15, 2018
e71b264
Selection menu now 100% complete. Now need to use returned info to do…
Sep 16, 2018
3306d1f
Can finally download configuration files! Huzza!
Sep 17, 2018
61edab3
Merge updates for gimxFileDownloader
Sep 17, 2018
7456c81
Progress bar now works. Also added download percentage. Soon a help m…
Sep 20, 2018
adb287f
Merge recent TUI polishes and bugfixes.
Sep 20, 2018
92316ec
Merge branch 'master' of https://github.com/matlo/GIMX
Oct 27, 2018
7b735e8
Refactored TUI to use less memory and better OOP design, and added he…
Apr 14, 2019
459bf6b
Merge branch 'master' of https://github.com/matlo/GIMX
Apr 15, 2019
815eefd
Add autoConfig() functionality, but requires testing once I have cont…
Apr 17, 2019
151363c
Merge branch 'master' of https://github.com/matlo/GIMX
Apr 17, 2019
80ac729
clean
Apr 17, 2019
0adfd2a
Merge branch 'master' of https://github.com/matlo/GIMX
Aug 9, 2019
b5ccccb
Fixed crash upon exiting help screen
Aug 9, 2019
3061a39
Changed the name of program to 'gimx-fetchconfig'. Now also resides i…
Aug 9, 2019
2651165
Fix typos
Aug 9, 2019
620eef0
Added -std=c++11 compiler flag for picky Mr Travis Cli, works on all …
Aug 9, 2019
7b93f7a
Removed all compiler warnings for my program, as requested
Aug 10, 2019
7f361ff
Refactored argument parsing. Replaced stray tabs with spaces. Removed…
Aug 11, 2019
bc6842b
Fixed crash upon pressing 'h' while in help menu
Aug 11, 2019
7dad208
Fixed a bunch of issues. Program now uses much simpler and more stabl…
Aug 19, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions Makedefs
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@

LD = $(CXX)

CFLAGS += -Wall -Wextra -O3
CXXFLAGS += -Wall -Wextra -O3

#CFLAGS += -Wall -Wextra -O3
#CXXFLAGS += -Wall -Wextra -O3
#Comment the above two lines and uncomment the below three lines to compile with debug symbols.

#CFLAGS += -Wall -Wextra -O0 -g -fsanitize=address -fno-omit-frame-pointer
#CXXFLAGS += -Wall -Wextra -O0 -g -fsanitize=address -fno-omit-frame-pointer

#If you don't care for library address sanitiser, uncomment below for debugging
#CFLAGS += -Wall -Wextra -O0 -g
#CXXFLAGS += -Wall -Wextra -O0 -g
#Library address sanitiser is not available for mingw64. This applies to msys2.
#Uncomment below lines, and comment above lines, for plain debug symbols.
CFLAGS += -Wall -Wextra -O0 -g
CXXFLAGS += -Wall -Wextra -O0 -g

CPPFLAGS += -I../shared

Expand Down
1 change: 0 additions & 1 deletion fetchconfig/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ ifneq ($(OS),Windows_NT)
LDLIBS += -lstdc++ -lm `pkg-config --libs ncursesw`
else
LDLIBS += -lws2_32 -lstdc++ -lpdcursesw -lintl
#LDLIBS:=$(filter-out -mwindows,$(LDLIBS))
endif

CPPFLAGS += -Iinclude -std=c++11
Expand Down
11 changes: 1 addition & 10 deletions fetchconfig/configDownload.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,15 +142,6 @@ ManualConfigDownload::ManualConfigDownload() : ConfigDownload(stdscr, newWinData
screen = newwin(winData->height, winData->width, winData->startY, winData->startX);
winData->win = screen;

// //Progress dialog
// dlWinData->height = 7;
// dlWinData->width = 30;
// dlWinData->startX = (winData->width /2) - (dlWinData->width /2);
// dlWinData->startY = (winData->height /2) - (dlWinData->height /2);
// dlScreen = newwin(dlWinData->height, dlWinData->width, dlWinData->startY, dlWinData->startX);
// dlWinData->win = dlScreen;
// progressDialog.reset(new ttyProgressDialog(dlWinData.get(), "Downloading"));

//Help dialog
helpText = "Press:\n\nESC to exit\nENTER to select\nArrow keys to change selection\n"\
"Page up and down keys to change page";
Expand All @@ -161,7 +152,7 @@ bool ManualConfigDownload::help()
{
BasicMenu helpMenu(helpText, winData.get(), "Help menu");
/*Stylise the menu borders*/
// borders => (bool, we, ns)
// borders => (bool, we, ns)
helpMenu.setDrawBorder(true, 0, 0);
flushinp();

Expand Down
57 changes: 25 additions & 32 deletions fetchconfig/easyCurses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,15 +302,14 @@ namespace EasyCurses
TF::overflow(lines, _maxChars(), lineFormat);
numLines = lineFormat.size();

// keyBindings = {
// { KEY_NPAGE, NavContent::pageUp }, { KEY_PPAGE, NavContent::pageDown },
// { 27, NavContent::finish }
// }; //27 => ESC

keypad(winData->win, true);

this->cusAct = [](void) -> bool {
return false;
};
}

std::map<int, int> BasicMenu::keyBindings = {
std::map<int, NavContent> BasicMenu::keyBindings = {
{ KEY_NPAGE, NavContent::pageUp }, { KEY_PPAGE, NavContent::pageDown },
{ 27, NavContent::finish }
}; //27 => ESC
Expand All @@ -320,24 +319,14 @@ namespace EasyCurses
return wgetch(winData->win);
}

int BasicMenu::mapInput(int input)
NavContent BasicMenu::mapInput(int rawInput)
{
auto res = keyBindings.find(input);
auto res = keyBindings.find(rawInput);
if(res != keyBindings.end())
return res->second;
return NavContent::null;
}

// void BasicMenu::setKeyBindings(std::map<int, int> newKBs)
// {
// keyBindings = newKBs;
// }
//
// std::map<int, int>& BasicMenu::getKeyBindings()
// {
// return keyBindings;
// }

void BasicMenu::setCustomAction(F cusAct)
{
this->cusAct = cusAct;
Expand All @@ -348,7 +337,7 @@ namespace EasyCurses
return cusAct;
}

void BasicMenu::calculatePage(int seek)
void BasicMenu::calculatePage(NavContent seek)
{
int startPage = page;

Expand All @@ -373,15 +362,15 @@ namespace EasyCurses
else //4th
++page;
break;

break;
default:
break;
}

if(startPage != page)
setUpdate();
}

void BasicMenu::inputHandling(int& input)
void BasicMenu::inputHandling(NavContent& input)
{
input = mapInput(getInput());

Expand Down Expand Up @@ -452,7 +441,7 @@ namespace EasyCurses
update();
wrefresh(winData->win);

int input = NavContent::null;
NavContent input = NavContent::null;
do
{
inputHandling(input);
Expand Down Expand Up @@ -488,7 +477,7 @@ namespace EasyCurses
keyBindings[KEY_LEFT] = NavContent::left;
keyBindings[KEY_UP] = NavContent::lineUp;
keyBindings[KEY_DOWN] = NavContent::lineDown;
keyBindings[10] = 10;
keyBindings[10] = NavContent::select; //Enter key

keypad(winData->win, true);
}
Expand Down Expand Up @@ -518,7 +507,7 @@ namespace EasyCurses
}
}

void SelectionMenu::calculatePage(int seek)
void SelectionMenu::calculatePage(NavContent seek)
{
//Deals with page up and down keys
BasicMenu::calculatePage(seek);
Expand Down Expand Up @@ -552,7 +541,6 @@ namespace EasyCurses
updateLineTrackers(pageTop());
break;
}

break;

case NavContent::lineUp:
Expand All @@ -563,28 +551,27 @@ namespace EasyCurses
{
page = lastPage() -1;
updateLineTrackers(numLines -1);
break;
}
else if(highlight < pageTop()) //4th
{
--page;
updateLineTrackers(pageBottom());
break;
}
break;

default:
break;
}

if(startPage != page)
setUpdate();
}

void SelectionMenu::navTrunc(int input)
void SelectionMenu::navTrunc(NavContent input)
{
if(overflowLine == overflowLayout.end())
return;


bool changed = false;

TF::TextLayout::iterator first, last;
Expand Down Expand Up @@ -612,6 +599,9 @@ namespace EasyCurses
++overflowLine;
}
break;

default:
break;
}

if(changed)
Expand Down Expand Up @@ -654,7 +644,7 @@ namespace EasyCurses
wrefresh(winData->win);
}

void SelectionMenu::inputHandling(int& input)
void SelectionMenu::inputHandling(NavContent& input)
{
BasicMenu::inputHandling(input);

Expand All @@ -669,7 +659,7 @@ namespace EasyCurses
navTrunc(input);
break;

case 10:
case NavContent::select:
if(selected[highlight] == true)
selected[highlight] = false;
else
Expand All @@ -680,6 +670,9 @@ namespace EasyCurses
case NavContent::finish:
//User done selecting
return;

default:
break;
}
}

Expand Down
18 changes: 10 additions & 8 deletions fetchconfig/gimx-fetchconfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,18 @@ class FileDownloader
{
configDl = std::unique_ptr<AutoConfigDownload>(new AutoConfigDownload);
static_cast<AutoConfigDownload*>(configDl.get());

configDl->chooseConfigs();
}

int callOptions(struct option* longOptions, int optionCharacter, int optionIndex)
{
int result = 0;
int result = -1;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

parseArgs now stops on first "non-flag" option.

switch(optionCharacter)
{
case -1:
//End of list
break;
case 0:
//If this option set a flag, do nothing else now.
if(longOptions[optionIndex].flag != 0)
Expand All @@ -71,10 +74,10 @@ class FileDownloader
case 'h':
case '?':
default:
result = -1;
result = -2;
break;
}

return result;
}

Expand Down Expand Up @@ -106,13 +109,12 @@ int main(int argc, char* argv[])
auto callback = [&fDownloader](struct option* opts, int optChar, int optI) -> int {
return fDownloader.callOptions(opts, optChar, optI);
};



int res = parseArgs(argc, argv, longOpts, callback);

/*End curses*/
endwin();
if(res == -1)
if(res == -2 || optind < argc)
help();
return 0;
}
46 changes: 7 additions & 39 deletions fetchconfig/include/configDownload.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,46 +62,31 @@ class ConfigDownload
virtual ~ConfigDownload() { };

virtual bool setUpDirectories(WINDOW* win);

virtual int chooseConfigs() = 0;
virtual int getConfig(std::string& configName);
virtual int grabConfigs(std::list<std::string>& configs, WINDOW* screen);

virtual void initDownload();
virtual void cleanDownload();
virtual int updateProgress\
(configupdater::ConfigUpdaterStatus status, double progress,
double total);
virtual int updateProgress(configupdater::ConfigUpdaterStatus status,
double progress, double total);
};

class ManualConfigDownload : public ConfigDownload
{
public:
ManualConfigDownload();
~ManualConfigDownload() { delwin(screen); delwin(dlScreen); }

bool help();

virtual int chooseConfigs() override;

// virtual void initDownload() override;
// virtual void cleanDownload() override;
virtual int chooseConfigs() override;

private:
/*
* From ConfigDownload:
* std::string userDir;
* std::string gimxDir;
* std::string gimxConfigDir;
* std::unique_ptr<ttyProgressDialog> progressDialog;
* std::unique_ptr<WinData> dlWinData;
* WINDOW* dlScreen;
* void* clientp;
*/

WINDOW* screen;
std::unique_ptr<WinData> winData;

std::string helpText;

//Information needed to allow user to choose config(s)
Expand All @@ -113,25 +98,8 @@ class AutoConfigDownload : public ConfigDownload
{
public:
AutoConfigDownload();

int chooseConfigs();

// virtual void initDownload() override;
// virtual void cleanDownload() override;

private:
/*
* From ConfigDownload:
* std::string userDir;
* std::string gimxDir;
* std::string gimxConfigDir;
* std::unique_ptr<ttyProgressDialog> progressDialog;
* std::unique_ptr<WinData> winData;
* std::unique_ptr<WinData> dlWinData;
* WINDOW* screen;
* WINDOW* dlScreen;
* void* clientp;
*/
int chooseConfigs();
};


Expand Down
Loading