Exemple #1
0
void show_textfile(const char *file_name)
{
	char *buf;
	unsigned int file_size;
	unsigned int line_count;
	unsigned int i;
	const char **lines;
	const char *start_line;

	buf = read_file(file_name, &file_size);
	if (!buf)
		return;
	line_count = 0;
	for (i = 0; i < file_size; ++i)
		line_count += buf[i] == '\n';
	lines = ccalloc(line_count, sizeof *lines);
	line_count = 0;
	start_line = buf;
	for (i = 0; i < file_size; ++i) {
		if (buf[i] == '\n') {
			lines[line_count++] = start_line;
			buf[i] = '\0';
			start_line = &buf[i + 1];
		}
		if (buf[i] == '\t')
			buf[i] = ' ';
	}
	create_text_box(lines, line_count, file_name, attr_textbox);
	free(lines);
	free(buf);
}
J_UI_Object* create_ui_object(UI_OBJECTS i_object_type){
	J_UI_Object* new_object;
	switch(i_object_type){
	case UI_OBJECTS::Text_Box:
		new_object = create_text_box();
	default:
		new_object = nullptr;
	}

	return new_object;
}
Exemple #3
0
void show_error(const char *msg, int err)
{
	const char *lines[2];
	unsigned int count;

	lines[0] = msg;
	count = 1;
	if (err) {
		lines[1] = strerror(err);
		count = 2;
	}
	create_text_box(lines, count, "Error", attr_errormsg);
}
Exemple #4
0
void show_text(const char *const *lines, unsigned int count, const char *title)
{
	create_text_box(lines, count, title, attr_textbox);
}