2 * Copyright (C) 2008 Diego Hernan Borghetti.
22 void e_cmd_cr(E_Eco
*ec
)
24 if (ec
->view
->b
->dot
== 0) {
25 if (ec
->view
->b
->line
->prev
) {
26 e_buffer_up(ec
->view
->b
);
27 e_buffer_eol(ec
->view
->b
);
28 e_buffer_newline(ec
->view
->b
);
29 e_buffer_down(ec
->view
->b
);
32 e_buffer_newline_first(ec
->view
->b
);
35 else if (ec
->view
->b
->dot
== ec
->view
->b
->line
->used
)
36 e_buffer_newline(ec
->view
->b
);
38 e_buffer_splitline(ec
->view
->b
);
40 e_view_redraw(ec
->view
);
43 void e_cmd_ht(E_Eco
*ec
)
45 e_buffer_insert(ec
->view
->b
, '\t');
46 e_view_redraw(ec
->view
);
49 void e_cmd_backspace(E_Eco
*ec
)
51 e_buffer_backspace(ec
->view
->b
);
52 e_view_redraw(ec
->view
);
55 void e_cmd_write(E_Eco
*ec
)
59 if (!strcmp(ec
->view
->b
->file
, "main")) {
60 buf
= e_status_get_msg(ec
, "File: ");
64 free((void *) ec
->view
->b
->file
);
65 ec
->view
->b
->file
= strdup(buf
);
67 e_file_write(ec
, ec
->view
->b
);
70 void e_cmd_killline(E_Eco
*ec
)
72 e_buffer_killline(ec
->view
->b
, 0);
73 e_view_redraw(ec
->view
);
76 void e_cmd_rotate(E_Eco
*ec
)
81 void e_cmd_goto(E_Eco
*ec
)
86 buf
= e_status_get_msg(ec
, "Line: ");
89 e_buffer_goto(ec
->view
->b
, line
);
90 e_view_redraw(ec
->view
);
94 void e_cmd_find_file(E_Eco
*ec
)
101 buf
= e_status_get_msg(ec
, "Find File: ");
103 bf
= e_list_find(ec
, buf
);
105 v
= e_list_view_find(ec
, bf
);
106 e_view_unshow(ec
->view
);
112 bf
= e_file_read(buf
, &st
);
114 v
= e_view_new(ec
->sc
);
116 e_list_view_add(ec
, v
);
121 e_view_unshow(ec
->view
);
128 void e_cmd_cutline(E_Eco
*ec
)
130 e_buffer_killline(ec
->view
->b
, 1);
131 e_view_redraw(ec
->view
);
134 void e_cmd_paste(E_Eco
*ec
)
136 e_kill_paste(ec
->view
->b
);
137 e_view_redraw(ec
->view
);
140 void e_cmd_cleankill(E_Eco
*ec
)
145 void e_cmd_update(E_Eco
*ec
)
147 e_view_redraw(ec
->view
);
150 e_screen_swap(ec
->tr
, ec
->sc
, 1);
154 void e_cmd_search_forward(E_Eco
*ec
)
158 buf
= e_status_get_msg(ec
, "Search: ");
160 strcpy(ec
->view
->search
, buf
);
161 e_buffer_search(ec
->view
->b
, ec
->view
->search
, BUFFER_SEARCH_FORWARD
);
162 e_status_set_msg(ec
, "(Search: %s)", ec
->view
->search
);
163 e_view_redraw(ec
->view
);
165 else if (ec
->view
->search
) {
166 e_buffer_search(ec
->view
->b
, ec
->view
->search
, BUFFER_SEARCH_FORWARD
);
167 e_status_set_msg(ec
, "(Search: %s)", ec
->view
->search
);
168 e_view_redraw(ec
->view
);
172 void e_cmd_search_backward(E_Eco
*ec
)
176 buf
= e_status_get_msg(ec
, "Search: ");
178 strcpy(ec
->view
->search
, buf
);
179 e_buffer_search(ec
->view
->b
, ec
->view
->search
, BUFFER_SEARCH_BACKWARD
);
180 e_status_set_msg(ec
, "(Search: %s)", ec
->view
->search
);
181 e_view_redraw(ec
->view
);
183 else if (ec
->view
->search
) {
184 e_buffer_search(ec
->view
->b
, ec
->view
->search
, BUFFER_SEARCH_BACKWARD
);
185 e_status_set_msg(ec
, "(Search: %s)", ec
->view
->search
);
186 e_view_redraw(ec
->view
);
190 void e_cmd_replace(E_Eco
*ec
)
195 buf
= e_status_get_msg(ec
, "Replace: ");
197 strcpy(ec
->view
->search
, buf
);
198 buf
= e_status_get_msg(ec
, "With: ");
200 num
= e_buffer_replace(ec
->view
->b
, ec
->view
->search
, buf
);
201 e_status_set_msg(ec
, "(%d subsitutions)", num
);