// ToDo lister v1.0 by LegeNda / Silver (plaine@icenet.fi) // !!! Rember to edit #define line !!! #define TODOFILE "d:/bbbs/todo.list" int Line(char mode) { int f, line=1, tmp, ed, poisto=1, key, max, com=1; char text, temp; if (mode=="del") { if((f=fopen(TODOFILE,"rt"))==-1) { printf("\e[1;33mAuha, auha! \e[0mCannot open \"%s\" for \"rt\"!\n",TODOFILE); return(0); } do { text[line]=fgets(f); if (strlen(text[line])>3) line++; } while (!feof(f)); fclose(f); tmp=line; max=line; max++; line=1; printf("\e[0m\e[1;1H\e[2J"); printf("\e[0;36mChoose with arrow keys, delete with enter or quit with *.\n"); printf("\e[0;32m---------------------------------------------------------\n\e[0m\n"); do { printf("%s\n",text[line]); _delay(20); line++; } while (linemax) poisto=max; } if (key=="\e"||key=="*"||key=="q"||key=="Q") { com=1; key=5; } if (key==" "||key=="\n"||key=="\r") { com=2; key=5; } printf("\e[%u;1H\e[0;37;0m%-78s\e[%u;1H\e[1;37;44m%-78s",ed+3,text[ed],poisto+3,stupcase(text[poisto])); } } while (key!=5); if (com==1) { printf("\e[0m\e[1;1H\e[2J\e[1;33mSilver Ice productions.\e[0m\n"); return(0); } line=1; f=fopen(TODOFILE,"wt"); do { if (line!=poisto) fprintf(f,"%s\n",text[line]); line++; } while (line ",76,0); fprintf(f,"%s\n",text); fclose(f); return(0); } } int main() { int fh; char ask, para=stlocase(bv_comstring); bv_comstring=bv_local_buffe=""; printf("\n"); if (strlen(para)<2) { printf("\e[0;36mToDo lister v1.0 \e[0mby LegeNda / SilverIce [\e[1;37mtodo -? \e[0mfor help]\n"); exit(0); } if (copy(para,1,1)!="-") { printf("\e[0;36mToDo lister v1.0 \e[0mby LegeNda / SilverIce [\e[1;37mtodo -? \e[0mfor help]\n"); printf("\e[1;33mAuha, auha!\e[0m Unknown parameter use TODO -? for help!\n"); exit(0); } if (para=="-?"||para=="-help") { printf("\e[0;36mToDo lister v1.0 \e[0mby LegeNda / SilverIce\e[0m\n\n"); printf("usage: \e[1;37mtodo -? \e[0mThis help.\n"); printf(" \e[1;37mtodo -help \e[0mThis help.\n"); printf(" \e[1;37mtodo -edit \e[0mEdit ToDo list.\n"); printf(" \e[1;37mtodo -view \e[0mView current ToDo list.\n"); printf(" \e[1;37mtodo -del \e[0mDelete one line from ToDo list.\n"); printf(" \e[1;37mtodo -add \e[0mAdd one line to ToDo list.\n"); printf(" \e[1;37mtodo -erase \e[0mErase whole to ToDo list.\n\n"); printf("\e[1;36mSilver Ice productions.\e[0m\n"); exit(0); } if (para=="-edit") { bbbs(sprintf("q mg %s",TODOFILE)); printf("\e[1;33mSilver Ice productions.\e[0m\n"); exit(0); } if (para=="-del") { Line("del"); exit(0); } if (para=="-add") { Line("add"); exit(0); } if (para=="-erase") { ask=stlocase(input(sprintf("Really wanna erase whole \"%s\"? (y/N) ",TODOFILE),1,1)); if (ask!="y") exit(0); remove(TODOFILE); printf("%s erased!\n",TODOFILE); exit(0); } if (para=="-view") { if((fh=fopen(TODOFILE,"rt"))==-1) { printf("\e[1;33mAuha, auha! \e[0mCannot open \"%s\" for \"rt\"!\n",TODOFILE); exit(0); } printf("\e[0;36mToDo lister v1.0 \e[0mby LegeNda / SilverIce\e[0m\n"); printf("\e[1;37mToDo list for today is:\e[0m\n\n"); do { printf("\e[0;32m%s\e[0m\n",fgets(fh)); } while (!feof(fh)); printf("\n"); fclose(fh); exit(0); } printf("\e[0;36mToDo lister v1.0 \e[0mby LegeNda / SilverIce [\e[1;37mtodo -? \e[0mfor help]\n"); printf("\e[1;33mAuha, auha!\e[0m Unknown parameter use TODO -? for help!\n"); }