Subversion Repositories Kolibri OS

Rev

Rev 9763 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 9763 Rev 9764
Line 1... Line 1...
1
#include 
1
#include 
2
#include 
2
#include 
3
#include 
3
#include 
4
#include 
4
#include 
5
#include 
5
#include 
-
 
6
#include 
Line 6... Line 7...
6
 
7
 
7
#include "func.h"
8
#include "func.h"
Line 8... Line 9...
8
#include "parser.h"
9
#include "parser.h"
Line 13... Line 14...
13
enum BUTTONS {
14
enum BUTTONS {
14
	BTN_QUIT = 1,
15
	BTN_QUIT = 1,
15
	BTN_EDIT = 5
16
	BTN_EDIT = 5
16
};
17
};
Line 17... Line 18...
17
 
18
 
18
const char header[] = "Graph";
19
const char STR_PROGRAM_TITLENAME[] = "Graph";
19
const char empty_text[] = "No function loaded. Type file name and press Enter. ";
20
const char empty_text[] = "No function loaded. Type file name and press Enter. ";
20
const char er_file_not_found[] = "Cannot open file. ";
21
const char er_file_not_found[] = "Cannot open file. ";
21
const char str_filename[] = "Filename:";
22
const char str_filename[] = "Filename:";
-
 
23
const char str_editfile[] = "Edit";
-
 
24
const char STR_ERR_CONSOLEINIT[] = "Unable to initialize console.";
-
 
25
const char STR_MSG_HELP_USAGE[] = "Usage: %s [OPTION] [FILENAME]...\n";
-
 
26
const char* STR_MSG_HELP[] = {
-
 
27
	"Draws a graph by calculating mathematical function or using list of points.\n\n",
-
 
28
 
-
 
29
	"\t--help\t\tdisplay this help and exit\n\n",
-
 
30
 
-
 
31
	"You can provide path to file if you want it to be opened immediately.\n",
Line 22... Line 32...
22
const char str_editfile[] = "Edit";
32
};
23
 
33
 
24
// íà÷àëüíûå ðàçìåðû
34
// íà÷àëüíûå ðàçìåðû
Line 353... Line 363...
353
 
363
 
354
	rr = _ksys_file_read_file(edit_path, 0, filesize, HugeBuf, nullptr);
364
	rr = _ksys_file_read_file(edit_path, 0, filesize, HugeBuf, nullptr);
355
	sprintf(debuf, "read3: %d\n", rr);
365
	sprintf(debuf, "read3: %d\n", rr);
Line 356... Line 366...
356
	_ksys_debug_puts(debuf);
366
	_ksys_debug_puts(debuf);
357
 
367
 
358
	strcpy(full_head, header);
368
	strcpy(full_head, STR_PROGRAM_TITLENAME);
Line 359... Line 369...
359
	strcpy(full_head+strlen(full_head), " - ");
369
	strcpy(full_head+strlen(full_head), " - ");
Line 489... Line 499...
489
 
499
 
490
	_ksys_define_button(cWidth - 70, mybox.top, 50, 21, BTN_EDIT, 0xc0c0c0);
500
	_ksys_define_button(cWidth - 70, mybox.top, 50, 21, BTN_EDIT, 0xc0c0c0);
491
	_ksys_draw_text((char*)str_editfile, cWidth - 60, mybox.top + 4, 0, 0x90000000);
501
	_ksys_draw_text((char*)str_editfile, cWidth - 60, mybox.top + 4, 0, 0x90000000);
Line -... Line 502...
-
 
502
}
-
 
503
 
-
 
504
void consoleInit() {
-
 
505
	if (con_init()) { // Init fail
-
 
506
		_ksys_debug_puts("[");
-
 
507
		_ksys_debug_puts(STR_PROGRAM_TITLENAME);
-
 
508
		_ksys_debug_puts("] ");
492
}
509
  		_ksys_debug_puts(STR_ERR_CONSOLEINIT);
-
 
510
		_ksys_debug_puts("\n");
-
 
511
  		exit(2);
-
 
512
	}
-
 
513
	(*con_set_title)(STR_PROGRAM_TITLENAME);
-
 
514
}
-
 
515
 
-
 
516
void consoleExit() {
-
 
517
	(*con_exit)(0);
-
 
518
}
493
 
519
 
494
int main() {
520
int main(int argc, char** argv) {
-
 
521
	full_head = (char*)malloc(300);
-
 
522
	strcpy(full_head, STR_PROGRAM_TITLENAME);
-
 
523
 
-
 
524
	if (argc == 2) {
-
 
525
		if (!strcmp(argv[1], "--help") || !strcmp(argv[1], "-h")) {
-
 
526
			consoleInit();
-
 
527
			printf(STR_MSG_HELP_USAGE, argv[0]);
-
 
528
			for (int j = 0; j < sizeof(STR_MSG_HELP)/sizeof(STR_MSG_HELP[0]); ++j) puts(STR_MSG_HELP[j]);
-
 
529
			consoleExit();
-
 
530
			return 0;
-
 
531
		} else {
-
 
532
			strcpy(edit_path, argv[1]);
-
 
533
			if (load_points3())
-
 
534
				draw_window();
-
 
535
		}
-
 
536
	} else if (argc > 2) {
-
 
537
		consoleInit();
-
 
538
		printf(STR_MSG_HELP_USAGE, argv[0]);
-
 
539
		consoleExit();
-
 
540
		return 1;
495
	full_head = (char*)malloc(300);
541
	}
496
	strcpy(full_head, "Graph");
542
 
497
	_ksys_set_event_mask(0xC0000027);
543
	_ksys_set_event_mask(0xC0000027);
498
	int event;
544
	int event;
499
	while (1) {
545
	while (1) {