More work on ccenter
This commit is contained in:
parent
cf280900be
commit
0f2314edac
@ -26,7 +26,7 @@ CC=cc
|
||||
CFLAGS=-I/usr/local/include
|
||||
DEPS = main.c
|
||||
|
||||
OBJ = main.o load_ini.o systemconfig.o systempaths.o mailconfs.o mailareas.o filedirs.o filesubs.o ../../inih/ini.o
|
||||
OBJ = main.o load_ini.o systemconfig.o systempaths.o mailconfs.o mailareas.o filedirs.o filesubs.o textfiles.o ../../inih/ini.o
|
||||
%.o: %.c $(DEPS)
|
||||
$(CC) -c -o $@ $< $(CFLAGS) -I../../deps/cdk-5.0-20161210/include/
|
||||
|
||||
|
@ -178,4 +178,5 @@ extern void mail_conferences();
|
||||
extern void edit_mail_areas(int confer);
|
||||
extern void file_directories();
|
||||
extern void edit_file_subdirs(int fdir);
|
||||
extern void textfiles();
|
||||
#endif
|
||||
|
@ -46,17 +46,22 @@ int main(int argc, char **argv) {
|
||||
int selection;
|
||||
int doexit = 0;
|
||||
char *menuItems[MAX_MENU_ITEMS][MAX_SUB_ITEMS];
|
||||
int menuLength[] = {7, 2};
|
||||
int menuLength[] = {2, 9, 2};
|
||||
menuItems[0][0] = strdup("Main");
|
||||
menuItems[0][1] = strdup("System Config");
|
||||
menuItems[0][2] = strdup("System Paths");
|
||||
menuItems[0][3] = strdup("Mail Conferences");
|
||||
menuItems[0][4] = strdup("File Directories");
|
||||
menuItems[0][5] = strdup("Text Files");
|
||||
menuItems[0][6] = strdup("Exit");
|
||||
menuItems[1][0] = strdup("Misc");
|
||||
menuItems[1][1] = strdup("About");
|
||||
int locations[2] = {LEFT, RIGHT};
|
||||
menuItems[0][1] = strdup("Exit");
|
||||
menuItems[1][0] = strdup("Configuration");
|
||||
menuItems[1][1] = strdup("System Config");
|
||||
menuItems[1][2] = strdup("System Paths");
|
||||
menuItems[1][3] = strdup("Mail Conferences");
|
||||
menuItems[1][4] = strdup("File Directories");
|
||||
menuItems[1][5] = strdup("Text Files");
|
||||
menuItems[1][6] = strdup("Archivers");
|
||||
menuItems[1][7] = strdup("Protocols");
|
||||
menuItems[1][8] = strdup("Doors");
|
||||
menuItems[2][0] = strdup("Misc");
|
||||
menuItems[2][1] = strdup("About");
|
||||
|
||||
int locations[3] = {LEFT, LEFT, RIGHT};
|
||||
CDKparseParams(argc, argv, ¶ms, "c:" CDK_CLI_PARAMS);
|
||||
if (!load_ini_file(CDKparamString (¶ms, 'c'))) {
|
||||
fprintf(stderr, "Error opening ini file: %s\n", CDKparamString (¶ms, 'c'));
|
||||
@ -69,7 +74,7 @@ int main(int argc, char **argv) {
|
||||
|
||||
displayLabel();
|
||||
|
||||
mainMenu = newCDKMenu(cdkscreen, menuItems, 2, menuLength, locations, TOP, A_NORMAL, A_NORMAL);
|
||||
mainMenu = newCDKMenu(cdkscreen, menuItems, 3, menuLength, locations, TOP, A_NORMAL, A_NORMAL);
|
||||
setCDKMenuTitleHighlight(mainMenu, A_STANDOUT);
|
||||
setCDKMenuSubTitleHighlight(mainMenu, A_STANDOUT);
|
||||
|
||||
@ -80,6 +85,13 @@ int main(int argc, char **argv) {
|
||||
} else if (mainMenu->exitType == vNORMAL) {
|
||||
switch(selection / 100) {
|
||||
case 0:
|
||||
switch (selection % 100) {
|
||||
case 5:
|
||||
doexit = 1;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
switch (selection % 100) {
|
||||
case 0:
|
||||
system_config();
|
||||
@ -93,12 +105,14 @@ int main(int argc, char **argv) {
|
||||
case 3:
|
||||
file_directories();
|
||||
break;
|
||||
case 5:
|
||||
doexit = 1;
|
||||
case 4:
|
||||
textfiles();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
case 2:
|
||||
switch (selection % 100) {
|
||||
case 0:
|
||||
displayAbout();
|
||||
|
142
utils/ccenter/textfiles.c
Normal file
142
utils/ccenter/textfiles.c
Normal file
@ -0,0 +1,142 @@
|
||||
#include <curses.h>
|
||||
#include <cdk.h>
|
||||
#include "ccenter.h"
|
||||
|
||||
extern struct bbs_config conf;
|
||||
extern CDKSCREEN *cdkscreen;
|
||||
|
||||
void edit_txtfile_name(int txtfile) {
|
||||
char *entrytext;
|
||||
CDKENTRY *txtFileName = newCDKEntry(cdkscreen, 7, 7, "</B/32>Text File Name<!32>", NULL, A_NORMAL, ' ', vMIXED, 48, 1, 64, TRUE, FALSE);
|
||||
|
||||
setCDKEntry(txtFileName, conf.text_files[txtfile]->name, 1, 64, TRUE);
|
||||
|
||||
entrytext = activateCDKEntry(txtFileName, 0);
|
||||
|
||||
if (txtFileName->exitType == vNORMAL) {
|
||||
if (conf.text_files[txtfile]->name != NULL) {
|
||||
free(conf.text_files[txtfile]->name);
|
||||
}
|
||||
conf.text_files[txtfile]->name = strdup(entrytext);
|
||||
}
|
||||
destroyCDKEntry(txtFileName);
|
||||
}
|
||||
|
||||
void edit_txtfile_file(int txtfile) {
|
||||
char *entrytext;
|
||||
CDKENTRY *txtFileFile = newCDKEntry(cdkscreen, 7, 7, "</B/32>Text File Filename<!32>", NULL, A_NORMAL, ' ', vMIXED, 48, 1, 1024, TRUE, FALSE);
|
||||
|
||||
setCDKEntry(txtFileFile, conf.text_files[txtfile]->path, 1, 1024, TRUE);
|
||||
|
||||
entrytext = activateCDKEntry(txtFileFile, 0);
|
||||
|
||||
if (txtFileFile->exitType == vNORMAL) {
|
||||
if (conf.text_files[txtfile]->path != NULL) {
|
||||
free(conf.text_files[txtfile]->path);
|
||||
}
|
||||
conf.text_files[txtfile]->path = strdup(entrytext);
|
||||
}
|
||||
destroyCDKEntry(txtFileFile);
|
||||
}
|
||||
|
||||
void delete_txtfile(int txtfile) {
|
||||
int i;
|
||||
free(conf.text_files[txtfile]->name);
|
||||
free(conf.text_files[txtfile]->path);
|
||||
free(conf.text_files[txtfile]);
|
||||
|
||||
for (i=txtfile;i<conf.text_file_count-1;i++) {
|
||||
conf.text_files[txtfile] = conf.text_files[txtfile + 1];
|
||||
}
|
||||
|
||||
conf.text_file_count--;
|
||||
|
||||
conf.text_files = (struct text_file **)realloc(conf.text_files, sizeof(struct text_file *) * conf.text_file_count);
|
||||
}
|
||||
|
||||
void edit_text_file(int txtfile) {
|
||||
char *itemList[] = {"Name",
|
||||
"Path and Filename",
|
||||
"Delete Text File"};
|
||||
|
||||
char buffer[1024];
|
||||
int selection;
|
||||
|
||||
snprintf(buffer, 1024, "</B/32>%s<!32>", conf.text_files[txtfile]->name);
|
||||
CDKSCROLL *editTxtFiles = newCDKScroll(cdkscreen, 5, 5, RIGHT, 6, 30, buffer, itemList, 3, FALSE, A_STANDOUT, TRUE, FALSE);
|
||||
|
||||
while (1) {
|
||||
selection = activateCDKScroll(editTxtFiles, 0);
|
||||
if (editTxtFiles->exitType == vESCAPE_HIT) {
|
||||
break;
|
||||
}
|
||||
switch(selection) {
|
||||
case 0:
|
||||
edit_txtfile_name(txtfile);
|
||||
break;
|
||||
case 1:
|
||||
edit_txtfile_file(txtfile);
|
||||
break;
|
||||
case 2:
|
||||
delete_txtfile(txtfile);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
destroyCDKScroll(editTxtFiles);
|
||||
}
|
||||
|
||||
void add_new_text_file() {
|
||||
char filepath[PATH_MAX];
|
||||
conf.text_files = (struct text_file **)realloc(conf.text_files, sizeof(struct text_file *) * (conf.text_file_count + 1));
|
||||
conf.text_files[conf.text_file_count] = (struct text_file *)malloc(sizeof(struct text_file));
|
||||
conf.text_files[conf.text_file_count]->name = strdup("New Text File");
|
||||
snprintf(filepath, PATH_MAX, "%s/newfile.ans", conf.ansi_path);
|
||||
conf.text_files[conf.text_file_count]->path = strdup(filepath);
|
||||
conf.text_file_count++;
|
||||
|
||||
edit_text_file(conf.text_file_count - 1);
|
||||
}
|
||||
|
||||
void textfiles() {
|
||||
char **itemlist;
|
||||
int selection;
|
||||
int i;
|
||||
int txtcount;
|
||||
|
||||
while (1) {
|
||||
itemlist = (char **)malloc(sizeof(char *) * (conf.text_file_count + 1));
|
||||
txtcount = conf.text_file_count;
|
||||
itemlist[0] = strdup("Add Text File");
|
||||
|
||||
for (i=0;i<txtcount;i++) {
|
||||
itemlist[i+1] = strdup(conf.text_files[i]->name);
|
||||
}
|
||||
|
||||
CDKSCROLL *txtFileList = newCDKScroll(cdkscreen, 3, 3, RIGHT, 12, 30, "</B/32>Text Files<!32>", itemlist, txtcount + 1, FALSE, A_STANDOUT, TRUE, FALSE);
|
||||
|
||||
selection = activateCDKScroll(txtFileList, 0);
|
||||
if (txtFileList->exitType == vESCAPE_HIT) {
|
||||
destroyCDKScroll(txtFileList);
|
||||
for (i=0;i<txtcount+1;i++) {
|
||||
free(itemlist[i]);
|
||||
}
|
||||
free(itemlist);
|
||||
break;
|
||||
}
|
||||
if (selection == 0) {
|
||||
// add new
|
||||
add_new_text_file();
|
||||
} else {
|
||||
// edit existing
|
||||
edit_text_file(selection - 1);
|
||||
}
|
||||
destroyCDKScroll(txtFileList);
|
||||
for (i=0;i<txtcount+1;i++) {
|
||||
free(itemlist[i]);
|
||||
}
|
||||
free(itemlist);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user