@@ -57,7 +57,7 @@ void content_line_print(int r, struct Window *w, struct Cursor *c) //Print line
5757 attrset (COLOR_PAIR (EDITOR_SCHEME )); //Turn on attribute for the boundary color scheme
5858 move (r + 1 , 0 ); //Set cursor to the beginning of the line for the y-position "row" -- all being relative to editor bounds
5959
60- j = get_line_number_pos (r , w -> contents );
60+ j = get_line_number_pos (r + w -> top , w -> contents );
6161 if (r == c -> y )
6262 j += (long ) c -> x - (c -> x %w -> width )- floor (c -> x /w -> width );
6363
@@ -72,25 +72,13 @@ void content_line_print(int r, struct Window *w, struct Cursor *c) //Print line
7272 addch ('>' );
7373}
7474
75- void print_editor (struct Window * w )
76- {
77- getmaxyx (stdscr , w -> height , w -> width ); //Get the dimensions of current screen (stdscr) and place those values into the Window structure
78-
79- attrset (COLOR_PAIR (EDITOR_SCHEME )); //Set color pair for editor (black text on white background)
80- move (0 , 0 );
81- for (int i = 0 ; i < w -> height * w -> width ; i ++ ) printw (" " );
82-
83- border_line_print (0 , "Unnamed Text Editor" , w ); //Print a Cyan line from the given y position (0, representing the first line)
84- border_line_print (w -> height - 1 , "[Esc] Quit [F1] Help [F2] Save [F3] Open [F4] New [F5] Delete line" , w ); //Print the bottom line
85- }
86-
8775void print_contents (struct Window * w , struct Cursor * c , struct File * f )
8876{
89- int i = 0 , pos = get_line_number_pos ( w -> top , w -> contents ) ;
90- while (pos < w -> height - 2 )
77+ int i = 0 ;
78+ while (i < w -> height - 2 )
9179 {
92- content_line_print (pos , w , c );
93- pos ++ ;
80+ content_line_print (i , w , c );
81+ i ++ ;
9482 }
9583 move (c -> y - w -> top + 1 , c -> x %w -> width );
9684}
@@ -115,9 +103,13 @@ bool msg_box(struct Window *w, char *msg)
115103 }
116104}
117105
118- void dialog (struct Window * w , char * prompt )
106+ void dialog (struct Window * w , char * prompt , char * msg )
119107{
120- print_editor (w );
108+ attrset (COLOR_PAIR (EDITOR_SCHEME ));
109+ move (0 , 0 );
110+ for (int i = 0 ; i < w -> height * w -> width ; i ++ ) printw (" " );
111+
112+ border_line_print (0 , msg , w );
121113 border_line_print (w -> height - 1 , prompt , w );
122114 move (w -> height - 1 , strlen (prompt ));
123115}
0 commit comments