コード例 #1
0
ファイル: main.c プロジェクト: JesseEisen/tview
/*
 *This function is use to update the line
 * which will show in highlight.
 * The render function is depend on the 
 * command_type
 * */
void 
Redraw_view(void)
{
	switch(command_type){
		case IS_LS:
			Draw_LS_OutPut();
			break;
		case IS_GREP:
			Draw_Grep_OutPut();
			break;
		case IS_FIND:
			Draw_Find_OutPut();
			break;
		default:
			do_nothing();
			break;
	}
	redrawwin(stdscr);
	wrefresh(stdscr);
}
コード例 #2
0
ファイル: ls_render.c プロジェクト: simfeng/tview
void 
GatherOutPut_ls(FILE *fp)
{
	char *line = NULL;
	void *new_space;
	int y = 0, is_expand = 0;
	char type[32];
	char size[32];

	line = (char *)malloc(sizeof(char) * LS_LINELEN);
	if(line == NULL)
		T_ERR("cannot malloc space for line");
	
	lsview = malloc(sizeof(struct LS_view));
	lsview->fileinfo =(struct fileinfo *)malloc(sizeof(struct fileinfo) * 128);
	if(lsview->fileinfo == NULL)
		T_ERR("cannot malloc space for lsview");
	lsview->fileno = 0;
	
	while(fgets(line,LS_LINELEN,fp) != NULL)
	{
		if(y == 0){  /*ignore the total line*/
			y++;
			continue;
		}
		GenerateFileInfo(line);
		lsview->fileno++;
		if(is_expand == 0 && lsview->fileno > 128)
		{	
			new_space = realloc(lsview->fileinfo, sizeof(struct fileinfo) * 128);	
			if(new_space == NULL)
				T_ERR("cannot realloc more space for lsview");
			lsview->fileinfo =(struct fileinfo *) new_space;
			is_expand = 1;
		}
	}
	/*when all the input is saved into*/
	Draw_LS_OutPut();
	refresh();
}