コード例 #1
0
ファイル: main.c プロジェクト: BackupTheBerlios/ooview-svn
int olog (int errcode) {
    FILE *logfile;
    char *logstring;
    time_t time_now;


    logfile = fopen (logfilepath, "a");


    if (logfile != NULL) {
        /*log file format:
        	date  \n errcode - errdesc
        	example:
        	Wed May 31 10:36:50 2006
        		Code: 13 - unknown error
        */

        char *my_time;

        time_now = time(NULL);

        my_time = ctime(&time_now);
        fprintf(logfile,"%s   %i - %s\n", my_time, errcode, returnvalues[errcode]);

        fclose(logfile);
        return 0;
    }	else	{
        /*print error message to status bar (cant be written to logfile, eh)*/

        print_status_bar("Could not write to logfile. Check permissions!");
    }
    return 9;

}
コード例 #2
0
ファイル: main.c プロジェクト: BackupTheBerlios/ooview-svn
int load_config() {
    FILE *configfile;

    if ((configfile = fopen(configpath, "r")) != NULL) {
        int i=0;
        char buf;


        DEF_LANG=(char *)malloc(50);
        PRINTER=(char *)malloc(50);
        GFX_VIEWER=(char *)malloc(50);
        BROWSER=(char *)malloc(50);

        while ( buf != 10) {
            buf=fgetc(configfile);
            if (buf != 10)
                DEF_LANG[i]=buf;

            i++;
        }
        i=0;
        buf=0;
        while ( buf != 10) {
            buf=fgetc(configfile);
            if (buf != 10)
                PRINTER[i]=buf;

            i++;
        }
        i=0;
        buf=0;

        while ( buf != 10) {
            buf=fgetc(configfile);
            if (buf != 10)
                GFX_VIEWER[i]=buf;

            i++;
        }
        i=0;
        buf=0;
        while ( buf != 10) {
            buf=fgetc(configfile);
            if (buf != 10)
                BROWSER[i]=buf;

            i++;
        }


        fclose(configfile);
    } else {
        olog(14);
        print_status_bar("Could not open configfile");
        return 14;
    }
    return 0;
}
コード例 #3
0
ファイル: main.c プロジェクト: BackupTheBerlios/ooview-svn
int open_file(char *file) {
    if ((strstr(file,".ovd")!=NULL) || (strstr(file,".odt")!=NULL) )  /* check whether it's a ovd or odt*/
    {
        if (strstr(file,".ovd")!=NULL)			/* ovd*/
        {
            ovd_file = fopen(file,"r");

            if (ovd_file != NULL)
            {
                buffer = (struct fileinfo *)malloc(sizeof(struct fileinfo));
                main_win = subwin(stdscr,LINES-2,COLS,1,0);
                get_file_content(ovd_file, file, buffer);
                fclose(ovd_file);
                cur_char = buffer->content;
                print_site(buffer->cur_line, buffer->lines);
                print_file(buffer,cur_char);
                file_printed = true;
                file_type = 2;
            }
            else
            {
                print_status_bar("File does not exist!");
            }
        }
        else								/* else if odt */
        {
            buffer = (struct fileinfo *)malloc(sizeof(struct fileinfo));
            main_win= subwin(stdscr,LINES-2,COLS,1,0);
            open_odt(file, buffer);
            /*												get_file_meta("/tmp/ooview/meta.xml",buffer);*/
            cur_char = buffer->content;
            print_site(buffer->cur_line, buffer->lines);
            print_file(buffer,cur_char);
            file_printed = true;
            file_type = 1;
        }

    }
    else
    {
        print_status_bar("Must be a OOView-file (ovd) or OpenDocument-file (odt)!");
    }
}
コード例 #4
0
ファイル: med.c プロジェクト: paud/d2x-xl
void editor_status( const char *format, ... )
{
	va_list ap;

	va_start(ap, format);
	vsprintf(status_line, format, ap);
	va_end(ap);

	print_status_bar(status_line);

	Editor_status_lastTime = EditorTime_of_day;

}
コード例 #5
0
ファイル: med.c プロジェクト: paud/d2x-xl
void clear_editor_status(void)
{
	int curTime = EditorTime_of_day.tm_hour * 3600 + EditorTime_of_day.tm_min*60 + EditorTime_of_day.tm_sec;
	int eraseTime = Editor_status_lastTime.tm_hour * 3600 + Editor_status_lastTime.tm_min*60 + Editor_status_lastTime.tm_sec + EDITOR_STATUS_MESSAGE_DURATION;

	if (curTime > eraseTime) {
		int	i;
		char	message[DIAGNOSTIC_MESSAGE_MAX];

		for (i=0; i<DIAGNOSTIC_MESSAGE_MAX-1; i++)
			message[i] = ' ';

		message[i] = 0;
		print_status_bar(message);
		Editor_status_lastTime.tm_hour = 99;
	}
}
コード例 #6
0
ファイル: med.c プロジェクト: CDarrow/DXX-Retro
// Handler for the main editor dialog
int editor_handler(UI_DIALOG *dlg, d_event *event, void *data)
{
	editor_view *new_cv;
	int keypress = 0;
	int rval = 0;

	if (event->type == EVENT_KEY_COMMAND)
		keypress = event_key_get(event);
	else if (event->type == EVENT_WINDOW_CLOSE)
	{
		close_editor();
		EditorWindow = NULL;
		return 0;
	}
	
	// Update the windows

	if (event->type == EVENT_UI_DIALOG_DRAW)
	{
		gr_set_curfont(editor_font);

		// Draw status box
		gr_set_current_canvas( NULL );
		gr_setcolor( CGREY );
		gr_rect(STATUS_X,STATUS_Y,STATUS_X+STATUS_W-1,STATUS_Y+STATUS_H-1);			//0, 582, 799, 599 );
		
		medlisp_update_screen();
		calc_frame_time();
		texpage_do(event);
		objpage_do(event);
		ui_pad_draw(EditorWindow, PAD_X, PAD_Y);

		print_status_bar(status_line);
		TimedAutosave(mine_filename);	// shows the time, hence here
		set_editor_time_of_day();
		return 1;
	}
	
	if ((selected_gadget == (UI_GADGET *)GameViewBox && !render_3d_in_big_window) ||
		(selected_gadget == (UI_GADGET *)LargeViewBox && render_3d_in_big_window))
		switch (event->type)
		{
			case EVENT_MOUSE_BUTTON_UP:
			case EVENT_MOUSE_BUTTON_DOWN:
				break;
			case EVENT_MOUSE_MOVED:
				if (!keyd_pressed[ KEY_LCTRL ] && !keyd_pressed[ KEY_RCTRL ])
					break;
			case EVENT_JOYSTICK_BUTTON_UP:
			case EVENT_JOYSTICK_BUTTON_DOWN:
			case EVENT_JOYSTICK_MOVED:
			case EVENT_KEY_COMMAND:
			case EVENT_KEY_RELEASE:
			case EVENT_IDLE:
				kconfig_read_controls(event, 1);

				if (slew_frame(0))
				{		//do movement and check keys
					Update_flags |= UF_GAME_VIEW_CHANGED;
					if (Gameview_lockstep)
					{
						Cursegp = &Segments[ConsoleObject->segnum];
						med_create_new_segment_from_cursegp();
						Update_flags |= UF_ED_STATE_CHANGED;
					}

					rval = 1;
				}
				break;
				
			default:
				break;
		}

	//do non-essential stuff in idle event
	if (event->type == EVENT_IDLE)
	{
		check_wall_validity();
		Assert(Num_walls>=0);

		if (Gameview_lockstep) {
			static segment *old_cursegp=NULL;
			static int old_curside=-1;

			if (old_cursegp!=Cursegp || old_curside!=Curside) {
				SetPlayerFromCursegMinusOne();
				old_cursegp = Cursegp;
				old_curside = Curside;
			}
		}

		if ( event_get_idle_seconds() > COMPRESS_INTERVAL ) 
		{
			med_compress_mine();
			event_reset_idle_seconds();
		}

	//	Commented out because it occupies about 25% of time in twirling the mine.
	// Removes some Asserts....
	//		med_check_all_vertices();
		clear_editor_status();		// if enough time elapsed, clear editor status message
	}

	gr_set_current_canvas( GameViewBox->canvas );
	
	// Remove keys used for slew
	switch(keypress)
	{
		case KEY_PAD9:
		case KEY_PAD7:
		case KEY_PADPLUS:
		case KEY_PADMINUS:
		case KEY_PAD8:
		case KEY_PAD2:
		case KEY_LBRACKET:
		case KEY_RBRACKET:
		case KEY_PAD1:
		case KEY_PAD3:
		case KEY_PAD6:
		case KEY_PAD4:
			keypress = 0;
	}
	if ((keypress&0xff)==KEY_LSHIFT) keypress=0;
	if ((keypress&0xff)==KEY_RSHIFT) keypress=0;
	if ((keypress&0xff)==KEY_LCTRL) keypress=0;
	if ((keypress&0xff)==KEY_RCTRL) keypress=0;
//		if ((keypress&0xff)==KEY_LALT) keypress=0;
//		if ((keypress&0xff)==KEY_RALT) keypress=0;

	//=================== DO FUNCTIONS ====================

	if ( KeyFunction[ keypress ] != NULL )
	{
		KeyFunction[keypress]();
		keypress = 0;
		rval = 1;
	}

	switch (keypress)
	{
		case 0:
		case KEY_Z:
		case KEY_G:
		case KEY_LALT:
		case KEY_RALT:
		case KEY_LCTRL:
		case KEY_RCTRL:
		case KEY_LSHIFT:
		case KEY_RSHIFT:
		case KEY_LAPOSTRO:
			break;
		case KEY_SHIFTED + KEY_L:
			ToggleLighting();
			rval = 1;
			break;
		case KEY_F1:
			render_3d_in_big_window = !render_3d_in_big_window;
			Update_flags |= UF_ALL;
			rval = 1;
			break;			
		default:
			if (!rval)
			{
				char kdesc[100];
				GetKeyDescription( kdesc, keypress );
				editor_status_fmt("Error: %s isn't bound to anything.", kdesc  );
			}
	}

	//================================================================

	if (ModeFlag)
	{
		ui_close_dialog(EditorWindow);
		return 0;
	}

//		if (EditorWindow->keyboard_focus_gadget == (UI_GADGET *)GameViewBox) current_view=NULL;
//		if (EditorWindow->keyboard_focus_gadget == (UI_GADGET *)GroupViewBox) current_view=NULL;

	new_cv = current_view;

#if ORTHO_VIEWS
	if (EditorWindow->keyboard_focus_gadget == (UI_GADGET *)LargeViewBox) new_cv=&LargeView;
	if (EditorWindow->keyboard_focus_gadget == (UI_GADGET *)TopViewBox)	new_cv=&TopView;
	if (EditorWindow->keyboard_focus_gadget == (UI_GADGET *)FrontViewBox) new_cv=&FrontView;
	if (EditorWindow->keyboard_focus_gadget == (UI_GADGET *)RightViewBox) new_cv=&RightView;
#endif
	if (new_cv != current_view ) {
		current_view->ev_changed = 1;
		new_cv->ev_changed = 1;
		current_view = new_cv;
	}

	// DO TEXTURE STUFF
	if (texpage_do(event))
		rval = 1;
	
	if (objpage_do(event))
		rval = 1;


	// Process selection of Cursegp using mouse.
	if (GADGET_PRESSED(LargeViewBox) && !render_3d_in_big_window) 
	{
		int	xcrd,ycrd;
		xcrd = LargeViewBox->b1_drag_x1;
		ycrd = LargeViewBox->b1_drag_y1;

		find_segments(xcrd,ycrd,LargeViewBox->canvas,&LargeView,Cursegp,Big_depth);	// Sets globals N_found_segs, Found_segs

		// If shift is down, then add segment to found list
		if (keyd_pressed[ KEY_LSHIFT ] || keyd_pressed[ KEY_RSHIFT ])
			subtract_found_segments_from_selected_list();
		else
			add_found_segments_to_selected_list();

		Found_seg_index = 0;	
	
		if (N_found_segs > 0) {
			sort_seg_list(N_found_segs,Found_segs,&ConsoleObject->pos);
			Cursegp = &Segments[Found_segs[0]];
			med_create_new_segment_from_cursegp();
			if (Lock_view_to_cursegp)
				set_view_target_from_segment(Cursegp);
		}

		Update_flags |= UF_ED_STATE_CHANGED | UF_VIEWPOINT_MOVED;
	}

	if ((event->type == EVENT_UI_USERBOX_DRAGGED) && (ui_event_get_gadget(event) == (UI_GADGET *)GameViewBox))
	{
		int	x, y;
		x = GameViewBox->b1_drag_x2;
		y = GameViewBox->b1_drag_y2;

		gr_set_current_canvas( GameViewBox->canvas );
		gr_setcolor( 15 );
		gr_rect( x-1, y-1, x+1, y+1 );
	}
	
	// Set current segment and side by clicking on a polygon in game window.
	//	If ctrl pressed, also assign current texture map to that side.
	//if (GameViewBox->mouse_onme && (GameViewBox->b1_done_dragging || GameViewBox->b1_clicked)) {
	if ((GADGET_PRESSED(GameViewBox) && !render_3d_in_big_window) ||
		(GADGET_PRESSED(LargeViewBox) && render_3d_in_big_window))
	{
		int	xcrd,ycrd;
		int seg,side,face,poly,tmap;

		if (render_3d_in_big_window) {
			xcrd = LargeViewBox->b1_drag_x1;
			ycrd = LargeViewBox->b1_drag_y1;
		}
		else {
			xcrd = GameViewBox->b1_drag_x1;
			ycrd = GameViewBox->b1_drag_y1;
		}

		//Int3();

		if (find_seg_side_face(xcrd,ycrd,&seg,&side,&face,&poly)) {


			if (seg<0) {							//found an object

				Cur_object_index = -seg-1;
				editor_status_fmt("Object %d selected.",Cur_object_index);

				Update_flags |= UF_ED_STATE_CHANGED;
			}
			else {

				//	See if either shift key is down and, if so, assign texture map
				if (keyd_pressed[KEY_LSHIFT] || keyd_pressed[KEY_RSHIFT]) {
					Cursegp = &Segments[seg];
					Curside = side;
					AssignTexture();
					med_create_new_segment_from_cursegp();
					editor_status("Texture assigned");
				} else if (keyd_pressed[KEY_G])	{
					tmap = Segments[seg].sides[side].tmap_num;
					texpage_grab_current(tmap);
					editor_status( "Texture grabbed." );
				} else if (keyd_pressed[ KEY_LAPOSTRO] ) {
					move_object_to_mouse_click();
				} else {
					Cursegp = &Segments[seg];
					Curside = side;
					med_create_new_segment_from_cursegp();
					editor_status("Curseg and curside selected");
				}
			}

			Update_flags |= UF_ED_STATE_CHANGED;
		}
		else 
			editor_status("Click on non-texture ingored");

	}

	// Allow specification of LargeView using mouse
	if (event->type == EVENT_MOUSE_MOVED && (keyd_pressed[ KEY_LCTRL ] || keyd_pressed[ KEY_RCTRL ]))
	{
		int dx, dy, dz;

		event_mouse_get_delta(event, &dx, &dy, &dz);
		if ((dx != 0) && (dy != 0))
		{
			vms_matrix	MouseRotMat,tempm;
			
			GetMouseRotation( dx, dy, &MouseRotMat );
			vm_matrix_x_matrix(&tempm,&LargeView.ev_matrix,&MouseRotMat);
			LargeView.ev_matrix = tempm;
			LargeView.ev_changed = 1;
			Large_view_index = -1;			// say not one of the orthogonal views
			rval = 1;
		}
	}

	if (event->type == EVENT_MOUSE_MOVED)
	{
		int dx, dy, dz;

		event_mouse_get_delta(event, &dx, &dy, &dz);
		if (dz != 0)
		{
			current_view->ev_dist += dz*10000;
			current_view->ev_changed = 1;
		}
	}
	
	return rval;
}
コード例 #7
0
ファイル: main.c プロジェクト: BackupTheBerlios/ooview-svn
int main (int argc, char **argv)
{

    logfilepath = getenv ("HOME");
    logfilepath = strcat (logfilepath, "/.ooview.log");

    load_config();


    initscr();
    raw();
    noecho();
    start_color();
    keypad(stdscr,TRUE);

    init_pair(1, COLOR_WHITE, COLOR_BLACK);
    init_pair(2, COLOR_RED, COLOR_WHITE);
    init_pair(3, COLOR_BLUE, COLOR_WHITE);
    init_pair(4, COLOR_BLACK, COLOR_WHITE);
    bkgd(COLOR_PAIR(1));
    curs_set(0);

    menu_bar = subwin(stdscr,1,COLS,0,0);
    wbkgd(menu_bar,COLOR_PAIR(2));
    waddstr(menu_bar,"File");
    wattron(menu_bar, COLOR_PAIR(3));
    waddstr(menu_bar,"<F1>");
    wattroff(menu_bar, COLOR_PAIR(3));
    wmove(menu_bar, 0, 19);
    waddstr(menu_bar,"View");
    wattron(menu_bar, COLOR_PAIR(3));
    waddstr(menu_bar,"<F2>");
    wattroff(menu_bar, COLOR_PAIR(3));
    wmove(menu_bar, 0, 34);
    waddstr(menu_bar,"Options");
    wattron(menu_bar, COLOR_PAIR(3));
    waddstr(menu_bar,"<F3>");
    wattroff(menu_bar, COLOR_PAIR(3));
    wmove(menu_bar, 0, 53);
    waddstr(menu_bar,"Help");
    wattron(menu_bar, COLOR_PAIR(3));
    waddstr(menu_bar,"<F4>");
    wattroff(menu_bar, COLOR_PAIR(3));

    status_bar = subwin(stdscr,1,COLS,LINES-1,0);
    wbkgd(status_bar,COLOR_PAIR(4));

    n_choices[0] = ARRAY_SIZE(file_choices);
    n_choices[1] = ARRAY_SIZE(view_choices);
    n_choices[2] = ARRAY_SIZE(opts_choices);
    n_choices[3] = ARRAY_SIZE(help_choices);
    file_items = (ITEM **)calloc(n_choices[0] + 1, sizeof(ITEM *));
    view_items = (ITEM **)calloc(n_choices[1] + 1, sizeof(ITEM *));
    opts_items = (ITEM **)calloc(n_choices[2] + 1, sizeof(ITEM *));
    help_items = (ITEM **)calloc(n_choices[3] + 1, sizeof(ITEM *));

    for (i=0; i<n_choices[0]; ++i)
        file_items[i] = new_item(file_choices[i], NULL);

    for (i=0; i<n_choices[1]; ++i)
        view_items[i] = new_item(view_choices[i], NULL);

    for (i=0; i<n_choices[2]; ++i)
        opts_items[i] = new_item(opts_choices[i], NULL);

    for (i=0; i<n_choices[3]; ++i)
        help_items[i] = new_item(help_choices[i], NULL);

    file_items[n_choices[0]] = (ITEM *)NULL;
    view_items[n_choices[1]] = (ITEM *)NULL;
    opts_items[n_choices[2]] = (ITEM *)NULL;
    help_items[n_choices[3]] = (ITEM *)NULL;

    file_menu = new_menu((ITEM **)file_items);
    view_menu = new_menu((ITEM **)view_items);
    opts_menu = new_menu((ITEM **)opts_items);
    help_menu = new_menu((ITEM **)help_items);

    set_menu_mark(file_menu, "");
    set_menu_mark(view_menu, "");
    set_menu_mark(opts_menu, "");
    set_menu_mark(help_menu, "");

    init_screen();
    if (argc == 2)
        open_file(argv[1]);

    while ((c = getch()) != EXIT_KEY)
    {
        action_performed = false;

        switch (c)
        {
        case KEY_F(1):
            cur_menu=1;
            break;
        case KEY_F(2):
            cur_menu=2;
            break;
        case KEY_F(3):
            cur_menu=3;
            break;
        case KEY_F(4):
            cur_menu=4;
            break;
        case KEY_UP:
            if ((file_printed) && (buffer->cur_line > 1))
            {
                int backsteps = 0;
                int steps;
                char *tmp;

                if ((*--cur_char)==NEWLINE)
                    backsteps++;

                tmp = cur_char - 1;

                if ((*--cur_char) == NEWLINE)
                {
                    cur_char = tmp;
                    print_status_bar("yeah");
                }
                else
                {
                    do {
                        cur_char--;
                        backsteps++;
                    } while (((*cur_char)!=NEWLINE) && (cur_char != buffer->content));

                    if (backsteps > COLS)
                    {
                        int test;
                        test = backsteps/COLS;
                        steps = (backsteps%COLS);
                        if (test>1)
                            steps += COLS;

                        mvwprintw(status_bar,0,0,"%d",steps);
                        touchwin(status_bar);
                        wrefresh(status_bar);
                        cur_char += backsteps;
                        cur_char -= steps;
                    }
                }
                buffer->cur_line--;
                print_site(buffer->cur_line, buffer->lines);

                if (cur_char!=buffer->content)
                    print_file(buffer,++cur_char);
                else
                    print_file(buffer,cur_char);
            }
            break;
        case KEY_DOWN:
            if ((file_printed) && (buffer->cur_line < buffer->lines))
            {
                int cols=0;


                while (((*cur_char)!=NEWLINE) && (cols < COLS-1))
                {
                    cols++;
                    cur_char++;
                }


                buffer->cur_line++;
                print_site(buffer->cur_line, buffer->lines);
                print_file(buffer,++cur_char);
            }
            break;
        default:
            if (meta_win!=NULL)
            {
                delwin(meta_win);
                touchwin(stdscr);
                refresh();
            }

        }

        if (cur_menu == 1)
        {
            file_win = newwin(8,19,1,0);
            keypad(file_win,TRUE);
            box(file_win,0,0);
            set_menu_win(file_menu, file_win);
            set_menu_sub(file_menu, derwin(file_win,6,17,1,1));
            post_menu(file_menu);
            while (c = wgetch(file_win))
            {
                if (c == KEY_DOWN)
                    menu_driver(file_menu, REQ_DOWN_ITEM);
                else if (c == KEY_UP)
                    menu_driver(file_menu, REQ_UP_ITEM);
                else if (c == KEY_RIGHT)
                {
                    cur_menu = 2;
                    break;
                }
                else if (c == KEY_LEFT)
                {
                    cur_menu = 4;
                    break;
                }
                else if (c == RETURN)
                {
                    cur_menu = 0;
                    cmd = (char *)item_name(current_item(file_menu));
                    action_performed = true;
                    break;
                }
                else
                {
                    cur_menu = 0;
                    break;
                }

            }

            unpost_menu(file_menu);
            touchwin(stdscr);
            wrefresh(stdscr);
        }
        if (cur_menu == 2)
        {
            view_win = newwin(6,15,1,19);
            keypad(view_win,TRUE);
            box(view_win,0,0);
            set_menu_win(view_menu, view_win);
            set_menu_sub(view_menu, derwin(view_win,4,13,1,1));
            post_menu(view_menu);
            while (c = wgetch(view_win))
            {
                if (c == KEY_DOWN)
                    menu_driver(view_menu, REQ_DOWN_ITEM);
                else if (c == KEY_UP)
                    menu_driver(view_menu, REQ_UP_ITEM);
                else if (c == KEY_RIGHT)
                {
                    cur_menu = 3;
                    break;
                }
                else if (c == KEY_LEFT)
                {
                    cur_menu = 1;
                    break;
                }
                else if (c == RETURN)
                {
                    cur_menu = 0;
                    cmd = (char *)item_name(current_item(view_menu));
                    action_performed = true;
                    break;
                }
                else
                {
                    cur_menu = 0;
                    break;
                }
            }

            unpost_menu(view_menu);
            touchwin(stdscr);
            refresh();
        }
        if (cur_menu == 3)
        {
            opts_win = newwin(5,19,1,34);
            keypad(opts_win,TRUE);
            box(opts_win,0,0);
            set_menu_win(opts_menu, opts_win);
            set_menu_sub(opts_menu, derwin(opts_win,3,17,1,1));
            post_menu(opts_menu);
            while (c = wgetch(opts_win))
            {
                if (c == KEY_DOWN)
                    menu_driver(opts_menu, REQ_DOWN_ITEM);
                else if (c == KEY_UP)
                    menu_driver(opts_menu, REQ_UP_ITEM);
                else if (c == KEY_RIGHT)
                {
                    cur_menu = 4;
                    break;
                }
                else if (c == KEY_LEFT)
                {
                    cur_menu = 2;
                    break;
                }
                else if (c == RETURN)
                {
                    cur_menu = 0;
                    cmd = (char *)item_name(current_item(opts_menu));
                    action_performed = true;
                    break;
                }
                else
                {
                    cur_menu = 0;
                    break;
                }
            }

            unpost_menu(opts_menu);
            touchwin(stdscr);
            refresh();
        }
        if (cur_menu == 4)
        {
            help_win = newwin(6,17,1,53);
            keypad(help_win,TRUE);
            box(help_win,0,0);
            set_menu_win(help_menu, help_win);
            set_menu_sub(help_menu, derwin(help_win,4,15,1,1));
            post_menu(help_menu);
            while (c = wgetch(help_win))
            {
                if (c == KEY_DOWN)
                    menu_driver(help_menu, REQ_DOWN_ITEM);
                else if (c == KEY_UP)
                    menu_driver(help_menu, REQ_UP_ITEM);
                else if (c == KEY_RIGHT)
                {
                    cur_menu = 1;
                    break;
                }
                else if (c == KEY_LEFT)
                {
                    cur_menu = 3;
                    break;
                }
                else if (c == RETURN)
                {
                    cur_menu = 0;
                    cmd = (char *)item_name(current_item(help_menu));
                    action_performed = true;
                    break;
                }
                else
                {
                    cur_menu = 0;
                    break;
                }
            }

            unpost_menu(help_menu);
            touchwin(stdscr);
            refresh();
        }




        if (action_performed)
        {
            char file[80];
            clear_status_bar();

            if (!strcmp(cmd,"Open"))
            {
                if (file_printed==false)
                {
                    print_status_bar("Enter a file: ");
                    curs_set(1);
                    echo();
                    wscanw(status_bar,"%s",file);			/* get filename from user */
                    curs_set(0);
                    noecho();
                    open_file(file);


                }
                else
                {
                    print_status_bar("Please close current file.");
                }

            }
            if (!strcmp(cmd,"Close"))
            {
                if (file_printed)
                {
                    free(buffer);


                    werase(main_win);
                    init_screen();
                    wrefresh(main_win);
                    file_printed = false;
                    system("rm -rf /tmp/ooview");


                }
                else
                {
                    print_status_bar("No open file!");
                }
            }
            if (!strcmp(cmd,"Reload"))
            {
                if (file_printed)
                {
                    if (strstr(file,".ovd")!=NULL)			/* ovd*/
                    {
                        ovd_file = fopen(file,"r");

                        if (ovd_file != NULL)
                        {
                            free(buffer);
                            buffer = (struct fileinfo *)malloc(sizeof(struct fileinfo));
                            main_win = subwin(stdscr,LINES-2,COLS,1,0);
                            get_file_content(ovd_file, file, buffer);
                            fclose(ovd_file);
                            cur_char = buffer->content;
                            print_site(buffer->cur_line, buffer->lines);
                            print_file(buffer,cur_char);
                            file_printed = true;
                        }
                        else
                        {
                            print_status_bar("File does not exist!");
                        }
                    }
                    else								/* else if odt */
                    {
                        free(buffer);
                        buffer = (struct fileinfo *)malloc(sizeof(struct fileinfo));
                        main_win= subwin(stdscr,LINES-2,COLS,1,0);
                        open_odt(file,buffer);
                        get_file_meta("/tmp/ooview/meta.xml",buffer);
                        cur_char = buffer->content;
                        print_site(buffer->cur_line, buffer->lines);
                        print_file(buffer,cur_char);
                        file_printed = true;
                    }


                }
                else
                {
                    print_status_bar("No open file!");
                }
            }

            if (!strcmp(cmd,"Document info"))
            {
                if (file_printed)
                {
                    if (file_type==1)
                    {

                        meta_win = newwin(9,COLS-2,(LINES/2)-5,1);
                        wbkgd(meta_win,COLOR_PAIR(4));


                        mvwprintw(meta_win,1,1,"Genarator:  %s", buffer->generator);
                        mvwprintw(meta_win,2,1,"Initial creator:\t%s", buffer->initial_creator);
                        mvwprintw(meta_win,3,1,"Creation date:\t\t%s", buffer->creation_date);
                        mvwprintw(meta_win,4,1,"Creator:\t\t%s", buffer->creator);
                        mvwprintw(meta_win,5,1,"Date:\t\t\t%s", buffer->date);
                        mvwprintw(meta_win,6,1,"Editing cycles:\t%s", buffer->editing_cycles);
                        mvwprintw(meta_win,7,1,"Editing duration:\t%s", buffer->editing_duration);

                        box(meta_win,0,0);
                        wrefresh(meta_win);
                        touchwin(meta_win);

                    }
                }
                else
                {
                    print_status_bar("No open file!");
                }
            }

            if (!strcmp(cmd,"OOView homepage"))
            {
                char *syscall;
                syscall=(char *)malloc(strlen(BROWSER)+strlen(HOMEPAGE_URL)+1);


                sprintf(syscall, "%s %s", BROWSER, HOMEPAGE_URL);
                system(syscall);
                free(syscall);
                if (file_printed)
                    free(buffer);
                end_curses();
                return(0);

            }

            if (!strcmp(cmd,"Documentation"))
            {
                char *syscall;
                syscall=(char *)malloc(strlen(BROWSER)+strlen(HOMEPAGE_URL)+1);


                sprintf(syscall, "%s %s", BROWSER, HOMEPAGE_URL);
                system(syscall);
                free(syscall);
                if (file_printed)
                    free(buffer);
                end_curses();
                return(0);

            }

            if (!strcmp(cmd, "About OOView"))
                print_status_bar("OOView. Visit Homepage for details");

            if (!strcmp(cmd, "Copying"))
                print_status_bar("OOView is under GPL/2 Visit Homepage for details");

            if (!strcmp(cmd, "Find")) {

                if (file_printed) {

                    print_status_bar("Enter string to find: ");
                    char *findit;

                    curs_set(1);
                    echo();

                    wscanw(status_bar,"%s",findit);

                    /*

                    how to find a string in a string?
                    find it -> set cursor to position

                    */

                    print_status_bar("Not implemented yet :(");
                    curs_set(0);
                    noecho();
                } else {
                    print_status_bar("No open file!");
                }
            }

            if (!strcmp(cmd, "External Programs")) {
                char *prompt;

                /*getting printer command*/
                prompt = (char *)malloc((strlen("Enter Printing Command []: ")+strlen(PRINTER)));
                sprintf(prompt,"Enter Printing Command [%s]: ",PRINTER);
                print_status_bar(prompt);
                free(prompt);

                curs_set(1);
                echo();
                char *newcmd;
                wscanw(status_bar,"%s",newcmd);
                curs_set(0);
                noecho();
                print_status_bar(newcmd);
                /* / getting printer command*/

            }

            if (!strcmp(cmd,"Exit"))
            {
                if (file_printed)
                    free(buffer);
                end_curses();
                return 0;
            }
        }

    }
    if (file_printed)
        free(buffer);

    end_curses();
    return 0;
}