Ejemplo n.º 1
0
int main(int argc, char *argv[])
{
    int c; /* c must be int not char, because the value of KEY_RESIZE is 632. */

    char buf[BUFSIZ];
    enum request request; 
    request = REQ_VIEW_MAIN; 

    struct view *view;
    if (argc < 2) {
        printf("Usage: %s <dir/filename> <keyword>\n", argv[0]);
        return;
    }
    signal(SIGINT, quit);

    if (argc == 3) {
        snprintf(buf, sizeof(buf), FIND_CMDD, argv[1], argv[2]);
        string_copy(fmt_cmd, buf);
    }else{
        snprintf(buf, sizeof(buf), FIND_CMD, argv[1]);
        string_copy(fmt_cmd, buf);
    }
    
	init();
            
	while (view_driver(display[current_view], request)) 
    {
        int i;

        foreach_view (view, i)
            update_view(view);

        c = wgetch(status_win);     
        request = get_request(c);
        
        if ( request == REQ_SCREEN_RESIZE) {

            int height, width;

            getmaxyx(stdscr, height, width);

            wresize(status_win, 1, width);
            mvwin(status_win, height - 1, 0);
            wrefresh(status_win);
        }
    }

	quit(0);

    return 0;
}
Ejemplo n.º 2
0
Archivo: xxx.c Proyecto: yaomoon/GT2440
int main(int argc, char *argv[])
{
	const char *codeset = "UTF-8";
    /* c must be int not char, because the value of KEY_RESIZE is 632. */
    int c;
    char buf[BUFSIZ];
    enum request request; 
    request = REQ_VIEW_MAIN; 
    struct view *view;

    size_t argv1_len;
    size_t argv2_len;
    size_t size;

    if (argc < 2) {
        printf("Usage: %s <dir/filename> <keyword>\n", argv[0]);
        return 0;
    }
    
    argv1_len = strlen(argv[1]);
    size = argv1_len + 3;

    char dest1[size];
    strcat1(dest1, argv[1]);

    if (argc == 3) {
        argv2_len = strlen(argv[2]);
        size = argv2_len + 3;

        char dest2[size];
        strcat1(dest2, argv[2]);

        snprintf(buf, sizeof(buf), FIND_CMDD, dest2, dest1);
        string_copy(fmt_cmd, buf);

    }else{
        snprintf(buf, sizeof(buf), FIND_CMD, dest1);
        string_copy(fmt_cmd, buf);
    }

    signal(SIGINT, quit);

	if (setlocale(LC_ALL, "")) {
		codeset = nl_langinfo(CODESET);
	}

	if (*opt_encoding && strcmp(codeset, "UTF-8")) {
		opt_iconv_in = iconv_open("UTF-8", opt_encoding);
		if (opt_iconv_in == ICONV_NONE)
			die("Failed to initialize character set conversion");
	}

	if (codeset && strcmp(codeset, "UTF-8")) {
		opt_iconv_out = iconv_open(codeset, "UTF-8");
		if (opt_iconv_out == ICONV_NONE)
			die("Failed to initialize character set conversion");
	}
    
	init();
#ifdef yaomoon
fprintf(moon_log,"hello yaomoon\n");
fprintf(moon_log,"current_view=%d\n",current_view);

#endif
            
	while (view_driver(display[current_view], request)) 
    {
        int i;

#ifdef yaomoon
fprintf(moon_log,"321:while 1\n");
#endif

        foreach_view (view, i)
            update_view(view);

#ifdef yaomoon
        while(1);
#endif
        c = wgetch(status_win);     
        request = get_request(c);
        
        if ( request == REQ_SCREEN_RESIZE) {
#ifdef yaomoon
fprintf(moon_log,"326:request == REQ_SCREEN_RESIZE\n");
#endif

            int height, width;

            getmaxyx(stdscr, height, width);

            wresize(status_win, 1, width);
            mvwin(status_win, height - 1, 0);
            wrefresh(status_win);
        }
#ifdef yaomoon
        else
            fprintf(moon_log,"341:request != REQ_SCREEN_RESIZE\n");
#endif
    }

	quit(0);

    return 0;
}