@@ -134,7 +134,7 @@ static void draw_status(WINDOW *win, int x_off, int x_cnt, const char *status)
134134 mvwprintw (win , 0 , 0 , " " );
135135 for (i = 0 ; i < x_cnt * 2 + x_off ; i ++ )
136136 mvwaddch (win , 1 , i , ' ' );
137- mvwprintw (win , 1 , x_off , status );
137+ mvwprintw (win , 1 , x_off , "%s" , status );
138138 wrefresh (win );
139139}
140140
@@ -374,6 +374,56 @@ void graph_init(void)
374374 curses_initialized = true;
375375}
376376
377+ void get_screen_coords (int x , int y , int * sx , int * sy ) {
378+ * sx = x * X_SCALE + 5 ;
379+ * sy = y /Y_SCALE ;
380+ }
381+
382+ void plot_point (int x , int y )
383+ {
384+ mvprintw (y /Y_SCALE , x * X_SCALE , "O (%d,%d)" , x - Y_PRINT_OFFSET , y - X_PRINT_OFFSET );
385+ }
386+
387+ int eye_plot_graph (int * data )
388+ {
389+ initscr ();
390+ noecho ();
391+ curs_set (FALSE);
392+ // Draw axes
393+ for (int x = 0 ; x <= PLOT_WIDTH ; ++ x )
394+ mvaddch (0 , (x * X_SCALE ) + 5 , '-' ); // X-axis at the top
395+ for (int y = 0 ; y <= PLOT_HEIGHT ; ++ y )
396+ mvaddch (y /Y_SCALE , 5 , '|' ); // Y-axis at the left
397+ // Draw scale on X-axis
398+ for (int x = 0 ; x <= PLOT_WIDTH ; x += 5 )
399+ {
400+ mvaddch (0 , (x * X_SCALE ) + 5 , '+' );
401+ mvprintw (1 , (x * X_SCALE ) + 5 , "%d" , x );
402+ }
403+ // Draw scale on Y-axis
404+ for (int y = 0 ; y <= PLOT_HEIGHT ; y += 10 ) {
405+ mvaddch (y /Y_SCALE , 5 , '+' );
406+ mvprintw (y /Y_SCALE , 0 , "%2d" , y );
407+ }
408+
409+ //Adjusting the eye points to plot from 0 to 42 for x-axis and 0 t0 100 for Y-axis
410+ //as ncurses library did not support negative ploting
411+ data [0 ] = data [0 ] + X_LAYOUT_SHIFT ;
412+ data [1 ] = data [1 ] + X_LAYOUT_SHIFT ;
413+ data [2 ] = data [2 ] + Y_LAYOUT_SHIFT ;
414+ data [3 ] = data [3 ] + Y_LAYOUT_SHIFT ;
415+
416+ // Plot some points (example)
417+ plot_point (data [0 ] + Y_PRINT_OFFSET , Y_LAYOUT_SHIFT + X_PRINT_OFFSET ); // (10,5)
418+ plot_point (data [1 ] + Y_PRINT_OFFSET , Y_LAYOUT_SHIFT + X_PRINT_OFFSET ); // (20,10)
419+ plot_point (X_LAYOUT_SHIFT + Y_PRINT_OFFSET , data [2 ] + X_PRINT_OFFSET ); // (30,15)
420+ plot_point (X_LAYOUT_SHIFT + Y_PRINT_OFFSET , data [3 ] + X_PRINT_OFFSET ); // (35,18)
421+
422+ refresh ();
423+ getch ();
424+ endwin ();
425+ return 0 ;
426+ }
377427#else /* defined(HAVE_LIBCURSES) || defined(HAVE_LIBNCURSES) */
378428
379429int graph_draw_win (struct range * X , struct range * Y , int * data , int * shades ,
0 commit comments