diff --git a/src/editor/editcmd.c b/src/editor/editcmd.c
index f78d9d4..28e0d62 100644
a
|
b
|
edit_refresh_cmd (WEdit * edit) |
160 | 160 | static int |
161 | 161 | edit_save_file (WEdit *edit, const char *filename) |
162 | 162 | { |
163 | | char *p; |
164 | | gchar *tmp; |
165 | | long filelen = 0; |
| 163 | const char *slashpos; |
| 164 | char *p, *msg; |
| 165 | char *savedir, *saveprefix; |
166 | 166 | char *savename = 0; |
167 | | gchar *real_filename; |
168 | | int this_save_mode, fd = -1; |
169 | 167 | |
| 168 | gchar *tmp, *real_filename; |
| 169 | |
| 170 | int rv, this_save_mode, fd = -1; |
| 171 | long buf, filelen = 0; |
| 172 | |
| 173 | struct stat sb; |
| 174 | |
170 | 175 | if (!filename) |
171 | 176 | return 0; |
172 | 177 | if (!*filename) |
… |
… |
edit_save_file (WEdit *edit, const char *filename) |
192 | 197 | mc_close (fd); |
193 | 198 | } |
194 | 199 | |
195 | | if (this_save_mode == EDIT_QUICK_SAVE && |
196 | | !edit->skip_detach_prompt) { |
197 | | int rv; |
198 | | struct stat sb; |
199 | | |
| 200 | if (this_save_mode == EDIT_QUICK_SAVE && !edit->skip_detach_prompt) { |
200 | 201 | rv = mc_stat (real_filename, &sb); |
201 | | if (rv == 0 && sb.st_nlink > 1) { |
| 202 | if (rv == 0 && sb.st_nlink > 1) { |
202 | 203 | rv = edit_query_dialog3 (_("Warning"), |
203 | 204 | _(" File has hard-links. Detach before saving? "), |
204 | 205 | _("&Yes"), _("&No"), _("&Cancel")); |
205 | | switch (rv) { |
206 | | case 0: |
207 | | this_save_mode = EDIT_SAFE_SAVE; |
208 | | /* fallthrough */ |
209 | | case 1: |
210 | | edit->skip_detach_prompt = 1; |
211 | | break; |
212 | | default: |
213 | | g_free(real_filename); |
214 | | return -1; |
215 | | } |
| 206 | switch (rv) { |
| 207 | case 0: |
| 208 | this_save_mode = EDIT_SAFE_SAVE; |
| 209 | /* fallthrough */ |
| 210 | case 1: |
| 211 | edit->skip_detach_prompt = 1; |
| 212 | break; |
| 213 | default: |
| 214 | g_free(real_filename); |
| 215 | return -1; |
| 216 | } |
216 | 217 | } |
217 | 218 | |
218 | 219 | /* Prevent overwriting changes from other editor sessions. */ |
219 | 220 | if (rv == 0 && edit->stat1.st_mtime != 0 && edit->stat1.st_mtime != sb.st_mtime) { |
220 | | |
221 | 221 | /* The default action is "Cancel". */ |
222 | 222 | query_set_sel(1); |
223 | 223 | |
… |
… |
edit_save_file (WEdit *edit, const char *filename) |
234 | 234 | } |
235 | 235 | |
236 | 236 | if (this_save_mode != EDIT_QUICK_SAVE) { |
237 | | char *savedir, *saveprefix; |
238 | | const char *slashpos; |
239 | 237 | slashpos = strrchr (real_filename, PATH_SEP); |
240 | 238 | if (slashpos) { |
241 | 239 | savedir = g_strdup (real_filename); |
… |
… |
edit_save_file (WEdit *edit, const char *filename) |
299 | 297 | goto error_save; |
300 | 298 | } |
301 | 299 | g_free (p); |
302 | | } else if (edit->lb == LB_ASIS) { /* do not change line breaks */ |
303 | | long buf; |
| 300 | } else if (edit->lb == LB_ASIS) { /* do not change line breaks */ |
304 | 301 | buf = 0; |
305 | 302 | filelen = edit->last_byte; |
306 | 303 | while (buf <= (edit->curs1 >> S_EDIT_BUF_SIZE) - 1) { |
… |
… |
edit_save_file (WEdit *edit, const char *filename) |
355 | 352 | filelen = edit_write_stream (edit, file); |
356 | 353 | fclose (file); |
357 | 354 | } else { |
358 | | char *msg; |
359 | | |
360 | 355 | msg = g_strdup_printf (_(" Cannot open file for writing: %s "), savename); |
361 | 356 | edit_error_dialog (_("Error"), msg); |
362 | 357 | g_free (msg); |
… |
… |
edit_delete_macro_cmd (WEdit * edit) |
787 | 782 | int edit_load_macro_cmd (WEdit * edit, struct macro macro[], int *n, int k) |
788 | 783 | { |
789 | 784 | FILE *f; |
| 785 | int u; |
790 | 786 | int s, i = 0, found = 0; |
791 | 787 | |
792 | 788 | (void) edit; |
… |
… |
int edit_load_macro_cmd (WEdit * edit, struct macro macro[], int *n, int k) |
798 | 794 | if ((f = edit_open_macro_file ("r"))) { |
799 | 795 | struct macro dummy; |
800 | 796 | do { |
801 | | int u; |
802 | 797 | u = fscanf (f, ("key '%d 0': "), &s); |
803 | 798 | if (!u || u == EOF) |
804 | 799 | break; |
… |
… |
editcmd_find (WEdit *edit, gsize *len) |
1457 | 1452 | if (edit->replace_backwards) { |
1458 | 1453 | search_end = end_mark; |
1459 | 1454 | while ((int) search_start >= start_mark) { |
1460 | | if (search_end > search_start + edit->search->original_len |
| 1455 | if (search_end > search_start + (off_t)edit->search->original_len |
1461 | 1456 | && mc_search_is_fixed_search_str(edit->search)) { |
1462 | 1457 | search_end = search_start + edit->search->original_len; |
1463 | 1458 | } |
… |
… |
edit_block_process_cmd (WEdit *edit, const char *shell_cmd, int block) |
2263 | 2258 | */ |
2264 | 2259 | tmp = g_strconcat (" ", home_dir, PATH_SEP_STR EDIT_DIR, shell_cmd, " ", quoted_name, |
2265 | 2260 | " ", home_dir, PATH_SEP_STR EDIT_BLOCK_FILE " /dev/null", (char *) NULL); |
2266 | | system (tmp); |
2267 | | g_free(tmp); |
2268 | 2261 | } else { |
2269 | 2262 | /* |
2270 | 2263 | * No block selected, just execute the command for the file. |
… |
… |
edit_block_process_cmd (WEdit *edit, const char *shell_cmd, int block) |
2273 | 2266 | */ |
2274 | 2267 | tmp = g_strconcat (" ", home_dir, PATH_SEP_STR EDIT_DIR, shell_cmd, " ", |
2275 | 2268 | quoted_name, (char *) NULL); |
2276 | | system (tmp); |
2277 | | g_free(tmp); |
2278 | 2269 | } |
| 2270 | system (tmp); |
| 2271 | g_free(tmp); |
| 2272 | |
| 2273 | |
2279 | 2274 | g_free (quoted_name); |
2280 | 2275 | close_error_pipe (D_NORMAL, NULL); |
2281 | 2276 | |
… |
… |
static gboolean is_break_char(char c) |
2396 | 2391 | static int edit_find_word_start (WEdit *edit, long *word_start, gsize *word_len) |
2397 | 2392 | { |
2398 | 2393 | int c, last; |
2399 | | gsize i; |
| 2394 | gssize i; |
2400 | 2395 | |
2401 | 2396 | /* return if at begin of file */ |
2402 | 2397 | if (edit->curs1 <= 0) |
diff --git a/src/editor/editdraw.c b/src/editor/editdraw.c
index 7f147de..ece52c1 100644
a
|
b
|
struct line_s { |
280 | 280 | static inline void |
281 | 281 | print_to_widget (WEdit *edit, long row, int start_col, int start_col_real, |
282 | 282 | long end_col, struct line_s line[], char *status) |
283 | | { |
284 | | struct line_s *p; |
| 283 | { |
| 284 | unsigned int textchar; |
| 285 | int i; |
| 286 | int style; |
| 287 | int color; |
285 | 288 | |
286 | 289 | int x = start_col_real; |
287 | 290 | int x1 = start_col + EDIT_TEXT_HORIZONTAL_OFFSET + option_line_state_width; |
288 | 291 | int y = row + EDIT_TEXT_VERTICAL_OFFSET; |
289 | 292 | int cols_to_skip = abs (x); |
290 | | int i; |
| 293 | |
| 294 | struct line_s *p; |
291 | 295 | |
292 | 296 | tty_setcolor (EDITOR_NORMAL_COLOR); |
293 | 297 | |
… |
… |
print_to_widget (WEdit *edit, long row, int start_col, int start_col_real, |
321 | 325 | p = line; |
322 | 326 | i = 1; |
323 | 327 | while (p->ch) { |
324 | | int style; |
325 | | unsigned int textchar; |
326 | | int color; |
327 | | |
| 328 | |
328 | 329 | if (cols_to_skip) { |
329 | 330 | p++; |
330 | 331 | cols_to_skip--; |