#include <conio.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
int pos=6;
int change[7][4]=
{
{0,1,2,0},{1,1,3,0},{0,6,4,2},{1,3,5,6},{2,5,4,4},{3,5,5,4},{0,3,4,2}
};
char menu[7][5]={"lab1","lab2","lab3","lab4","lab5","lab6","HELP"};
int coord[7][2]=
{
{30,9},{37,9},{27,11},{41,11},{30,13},{37,13},{34,11}
};
void bg_window();
void print_menu();
void select_menu();
void help();
void main(int argc, char *argv[])
{
int key;
if(strcmp(argv[1], "/help")==0 || strcmp(argv[1], "/h")==0)
{
bg_window();
select_menu();
}
else
{
bg_window();
switch(key)
{
case 72:pos=change[pos][0];break;
case 77:pos=change[pos][1];break;
case 80:pos=change[pos][2];break;
case 75:pos=change[pos][3];break;
case 13:select_menu();break;
case 27:return;
}
}
}
void bg_window()
{
int i;
window(2,2,79,24);
textbackground(BLUE);
textcolor(GREEN);
clrscr();
puts(" ╔══════════════════════════════════════════════════════════════════════════╗ ");
for(i=0;i<=20;i++)
puts(" ║ ║ ");
puts(" ╚══════════════════════════════════════════════════════════════════════════╝ ");
}
void print_menu()
{
int i;
window(5,3,76,23);
textbackground(BLUE);
clrscr();
for(i=0;i<7;i++)
{
window(coord[i][0],coord[i][1],coord[i][0]+5,coord[i][1]+1);
textcolor(i==pos?LIGHTRED:YELLOW);
textbackground(i==pos?GREEN:RED);
clrscr();
gotoxy(3,1);
cprintf("%s", menu[i]);
}
}
void select_menu()
{
int key;
window(5,3,76,23);
textbackground(BLUE);
textcolor(YELLOW);
clrscr();
switch(pos)
{
case 0:
help();
break;
case 1: case 2: case 3: case 4: case 5: case 6:
cprintf("Лабораторная работа номер %d", pos);
break;
}
for(;;)
{
if(getch()==27)
break;
}
}
void help()
{
FILE *f;
char *c;
int y=2;
if((f=fopen("HELP", "rt"))==NULL)
{
cprintf("\nОшибка открытия файла!\n");
}
else
{
while(!feof(f))
{
c=fgetc(f);
if(c=='\n')
{
gotoxy(1,y++);
}
else
{
cprintf("%c", c);
}
}
fclose(f);
}
}