diff -urp /home/users/gotar/git/mc/src/viewer/actions_cmd.c ./actions_cmd.c
old
|
new
|
mcview_handle_editkey (mcview_t * view, |
242 | 242 | |
243 | 243 | /* --------------------------------------------------------------------------------------------- */ |
244 | 244 | |
245 | | static cb_ret_t |
| 245 | static int |
246 | 246 | mcview_execute_cmd (mcview_t * view, unsigned long command) |
247 | 247 | { |
248 | 248 | int res = MSG_HANDLED; |
… |
… |
mcview_execute_cmd (mcview_t * view, uns |
297 | 297 | view->dirty++; |
298 | 298 | break; |
299 | 299 | case CK_ViewMoveToBol: |
300 | | mcview_moveto_bol (view); |
| 300 | return mcview_moveto_bol (view); |
301 | 301 | break; |
302 | 302 | case CK_ViewMoveToEol: |
303 | 303 | mcview_moveto_eol (view); |
304 | 304 | break; |
305 | 305 | case CK_ViewMoveLeft: |
306 | | mcview_move_left (view, 1); |
307 | | break; |
| 306 | return mcview_move_left (view, 1); |
308 | 307 | case CK_ViewMoveRight: |
309 | 308 | mcview_move_right (view, 1); |
310 | 309 | break; |
311 | 310 | case CK_ViewMoveLeft10: |
312 | 311 | if (!view->hex_mode) |
313 | | mcview_move_left (view, 10); |
314 | | break; |
| 312 | return mcview_move_left (view, 10); |
| 313 | return -MSG_HANDLED; |
315 | 314 | case CK_ViewMoveRight10: |
316 | 315 | if (!view->hex_mode) |
317 | 316 | mcview_move_right (view, 10); |
… |
… |
mcview_execute_cmd (mcview_t * view, uns |
323 | 322 | mcview_display_toggle_ruler (view); |
324 | 323 | break; |
325 | 324 | case CK_ViewMoveUp: |
326 | | mcview_move_up (view, 1); |
327 | | break; |
| 325 | return mcview_move_up (view, 1); |
328 | 326 | case CK_ViewMoveDown: |
329 | 327 | mcview_move_down (view, 1); |
330 | 328 | break; |
331 | 329 | case CK_ViewMoveHalfPgUp: |
332 | | mcview_move_up (view, (view->data_area.height + 1) / 2); |
333 | | break; |
| 330 | return mcview_move_up (view, (view->data_area.height + 1) / 2); |
334 | 331 | case CK_ViewMoveHalfPgDn: |
335 | 332 | mcview_move_down (view, (view->data_area.height + 1) / 2); |
336 | 333 | break; |
337 | 334 | case CK_ViewMovePgUp: |
338 | | mcview_move_up (view, view->data_area.height); |
339 | | break; |
| 335 | return mcview_move_up (view, view->data_area.height); |
340 | 336 | case CK_ViewMovePgDn: |
341 | 337 | mcview_move_down (view, view->data_area.height); |
342 | 338 | break; |
343 | 339 | case CK_ViewMoveTop: |
344 | | mcview_moveto_top (view); |
345 | | break; |
| 340 | return mcview_moveto_top (view); |
346 | 341 | case CK_ViewMoveBottom: |
347 | 342 | mcview_moveto_bottom (view); |
348 | 343 | break; |
349 | 344 | case CK_ShowCommandLine: |
350 | 345 | view_other_cmd (); |
351 | | break; |
| 346 | return -MSG_HANDLED; |
352 | 347 | /* |
353 | 348 | // Unlike Ctrl-O, run a new shell if the subshell is not running |
354 | 349 | case '!': |
… |
… |
mcview_execute_cmd (mcview_t * view, uns |
376 | 371 | case CK_ViewQuit: |
377 | 372 | if (!mcview_is_in_panel (view)) |
378 | 373 | dlg_stop (view->widget.owner); |
379 | | break; |
| 374 | return -MSG_HANDLED; |
380 | 375 | default: |
381 | 376 | res = MSG_NOT_HANDLED; |
382 | 377 | } |
… |
… |
mcview_execute_cmd (mcview_t * view, uns |
384 | 379 | } |
385 | 380 | |
386 | 381 | /* Both views */ |
387 | | static cb_ret_t |
| 382 | static int |
388 | 383 | mcview_handle_key (mcview_t * view, int key) |
389 | 384 | { |
390 | 385 | unsigned long command; |
| 386 | int res; |
391 | 387 | |
392 | 388 | key = convert_from_input_c (key); |
393 | 389 | |
… |
… |
mcview_handle_key (mcview_t * view, int |
402 | 398 | } |
403 | 399 | |
404 | 400 | command = lookup_keymap_command (view->plain_map, key); |
405 | | if ((command != CK_Ignore_Key) && (mcview_execute_cmd (view, command) == MSG_HANDLED)) |
406 | | return MSG_HANDLED; |
| 401 | if (command != CK_Ignore_Key) |
| 402 | { |
| 403 | res = mcview_execute_cmd (view, command); |
| 404 | if (res != MSG_NOT_HANDLED) |
| 405 | return res; |
| 406 | } |
407 | 407 | |
408 | 408 | #ifdef MC_ENABLE_DEBUGGING_CODE |
409 | 409 | if (c == 't') |
… |
… |
cb_ret_t |
450 | 450 | mcview_callback (Widget * w, widget_msg_t msg, int parm) |
451 | 451 | { |
452 | 452 | mcview_t *view = (mcview_t *) w; |
453 | | cb_ret_t i; |
| 453 | int i; |
454 | 454 | |
455 | 455 | mcview_compute_areas (view); |
456 | 456 | mcview_update_bytes_per_line (view); |
… |
… |
mcview_callback (Widget * w, widget_msg_ |
475 | 475 | |
476 | 476 | case WIDGET_KEY: |
477 | 477 | i = mcview_handle_key (view, parm); |
478 | | mcview_update (view); |
479 | | return i; |
| 478 | if (i != MSG_NOT_HANDLED && i != -MSG_HANDLED) |
| 479 | mcview_update (view); |
| 480 | if (i != MSG_NOT_HANDLED) |
| 481 | return MSG_HANDLED; |
| 482 | return MSG_NOT_HANDLED; |
480 | 483 | |
481 | 484 | case WIDGET_COMMAND: |
482 | 485 | i = mcview_execute_cmd (view, parm); |
diff -urp /home/users/gotar/git/mc/src/viewer/datasource.c ./datasource.c
old
|
new
|
mcview_get_ptr_file (mcview_t * view, of |
136 | 136 | { |
137 | 137 | assert (view->datasource == DS_FILE); |
138 | 138 | |
139 | | mcview_file_load_data (view, byte_index); |
140 | | if (mcview_already_loaded (view->ds_file_offset, byte_index, view->ds_file_datalen)) |
| 139 | if (mcview_file_load_data (view, byte_index)) |
141 | 140 | return (char *) (view->ds_file_data + (byte_index - view->ds_file_offset)); |
142 | 141 | return NULL; |
143 | 142 | } |
… |
… |
mcview_set_byte (mcview_t * view, off_t |
259 | 258 | /* --------------------------------------------------------------------------------------------- */ |
260 | 259 | |
261 | 260 | /*static */ |
262 | | void |
| 261 | gboolean |
263 | 262 | mcview_file_load_data (mcview_t * view, off_t byte_index) |
264 | 263 | { |
265 | 264 | off_t blockoffset; |
… |
… |
mcview_file_load_data (mcview_t * view, |
269 | 268 | assert (view->datasource == DS_FILE); |
270 | 269 | |
271 | 270 | if (mcview_already_loaded (view->ds_file_offset, byte_index, view->ds_file_datalen)) |
272 | | return; |
| 271 | return TRUE; |
273 | 272 | |
274 | 273 | if (byte_index >= view->ds_file_filesize) |
275 | | return; |
| 274 | return FALSE; |
276 | 275 | |
277 | 276 | blockoffset = mcview_offset_rounddown (byte_index, view->ds_file_datasize); |
278 | 277 | if (mc_lseek (view->ds_file_fd, blockoffset, SEEK_SET) == -1) |
… |
… |
mcview_file_load_data (mcview_t * view, |
300 | 299 | { |
301 | 300 | view->ds_file_datalen = bytes_read; |
302 | 301 | } |
303 | | return; |
| 302 | return TRUE; |
304 | 303 | |
305 | 304 | error: |
306 | 305 | view->ds_file_datalen = 0; |
| 306 | return FALSE; |
307 | 307 | } |
308 | 308 | |
309 | 309 | /* --------------------------------------------------------------------------------------------- */ |
diff -urp /home/users/gotar/git/mc/src/viewer/display.c ./display.c
old
|
new
|
mcview_update (mcview_t * view) |
183 | 183 | { |
184 | 184 | static int dirt_limit = 1; |
185 | 185 | |
| 186 | /* don't update viewer in inactive dialog */ |
| 187 | if (view->widget.owner->state != DLG_ACTIVE) |
| 188 | return; |
| 189 | |
186 | 190 | if (view->dpy_bbar_dirty) |
187 | 191 | { |
188 | 192 | view->dpy_bbar_dirty = FALSE; |
diff -urp /home/users/gotar/git/mc/src/viewer/inlines.h ./inlines.h
old
|
new
|
mcview_get_byte_file (mcview_t * view, o |
80 | 80 | { |
81 | 81 | assert (view->datasource == DS_FILE); |
82 | 82 | |
83 | | mcview_file_load_data (view, byte_index); |
84 | | if (mcview_already_loaded (view->ds_file_offset, byte_index, view->ds_file_datalen)) |
| 83 | if (mcview_file_load_data (view, byte_index)) |
85 | 84 | { |
86 | 85 | if (retval) |
87 | 86 | *retval = view->ds_file_data[byte_index - view->ds_file_offset]; |
diff -urp /home/users/gotar/git/mc/src/viewer/internal.h ./internal.h
old
|
new
|
int mcview_get_utf (mcview_t *, off_t, i |
242 | 242 | gboolean mcview_get_byte_string (mcview_t *, off_t, int *); |
243 | 243 | gboolean mcview_get_byte_none (mcview_t *, off_t, int *); |
244 | 244 | void mcview_set_byte (mcview_t *, off_t, byte); |
245 | | void mcview_file_load_data (mcview_t *, off_t); |
| 245 | gboolean mcview_file_load_data (mcview_t *, off_t); |
246 | 246 | void mcview_close_datasource (mcview_t *); |
247 | 247 | void mcview_set_datasource_file (mcview_t *, int, const struct stat *); |
248 | 248 | gboolean mcview_load_command_output (mcview_t *, const char *); |
… |
… |
gboolean mcview_lock_file (mcview_t * vi |
296 | 296 | gboolean mcview_unlock_file (mcview_t * view); |
297 | 297 | |
298 | 298 | /* move.c */ |
299 | | void mcview_move_up (mcview_t *, off_t); |
| 299 | int mcview_move_up (mcview_t *, off_t); |
300 | 300 | void mcview_move_down (mcview_t *, off_t); |
301 | | void mcview_move_left (mcview_t *, off_t); |
| 301 | int mcview_move_left (mcview_t *, off_t); |
302 | 302 | void mcview_move_right (mcview_t *, off_t); |
303 | 303 | void mcview_scroll_to_cursor (mcview_t *); |
304 | | void mcview_moveto_top (mcview_t *); |
| 304 | int mcview_moveto_top (mcview_t *); |
305 | 305 | void mcview_moveto_bottom (mcview_t *); |
306 | | void mcview_moveto_bol (mcview_t *); |
| 306 | int mcview_moveto_bol (mcview_t *); |
307 | 307 | void mcview_moveto_eol (mcview_t *); |
308 | 308 | void mcview_moveto_offset (mcview_t *, off_t); |
309 | 309 | void mcview_moveto (mcview_t *, off_t, off_t); |
diff -urp /home/users/gotar/git/mc/src/viewer/move.c ./move.c
old
|
new
|
mcview_movement_fixups (mcview_t * view, |
85 | 85 | |
86 | 86 | /* --------------------------------------------------------------------------------------------- */ |
87 | 87 | |
88 | | void |
| 88 | int |
89 | 89 | mcview_move_up (mcview_t * view, off_t lines) |
90 | 90 | { |
91 | | off_t new_offset; |
| 91 | off_t new_offset, i; |
92 | 92 | |
93 | 93 | if (view->hex_mode) |
94 | 94 | { |
| 95 | i = MSG_HANDLED; /* in this mode actual linecount doesn't matter */ |
95 | 96 | off_t bytes = lines * view->bytes_per_line; |
96 | 97 | if (view->hex_cursor >= bytes) |
97 | 98 | { |
… |
… |
mcview_move_up (mcview_t * view, off_t l |
106 | 107 | } |
107 | 108 | else |
108 | 109 | { |
109 | | off_t i; |
110 | 110 | |
111 | 111 | for (i = 0; i < lines; i++) |
112 | 112 | { |
… |
… |
mcview_move_up (mcview_t * view, off_t l |
147 | 147 | } |
148 | 148 | } |
149 | 149 | } |
| 150 | if (i == 0) return -MSG_HANDLED; |
150 | 151 | mcview_movement_fixups (view, TRUE); |
| 152 | return i; |
151 | 153 | } |
152 | 154 | |
153 | 155 | /* --------------------------------------------------------------------------------------------- */ |
… |
… |
mcview_move_down (mcview_t * view, off_t |
220 | 222 | |
221 | 223 | /* --------------------------------------------------------------------------------------------- */ |
222 | 224 | |
223 | | void |
| 225 | int |
224 | 226 | mcview_move_left (mcview_t * view, off_t columns) |
225 | 227 | { |
| 228 | int ret; |
| 229 | ret = -MSG_HANDLED; |
| 230 | |
226 | 231 | if (view->hex_mode) |
227 | 232 | { |
| 233 | ret = MSG_HANDLED; |
228 | 234 | off_t old_cursor = view->hex_cursor; |
229 | 235 | assert (columns == 1); |
230 | 236 | if (view->hexview_in_text || !view->hexedit_lownibble) |
… |
… |
mcview_move_left (mcview_t * view, off_t |
239 | 245 | else |
240 | 246 | { |
241 | 247 | if (view->dpy_text_column >= columns) |
| 248 | { |
242 | 249 | view->dpy_text_column -= columns; |
243 | | else |
| 250 | ret = columns; |
| 251 | } |
| 252 | else { |
| 253 | if (view->dpy_text_column > 0) |
| 254 | ret = view->dpy_text_column; |
244 | 255 | view->dpy_text_column = 0; |
| 256 | } |
245 | 257 | } |
246 | 258 | mcview_movement_fixups (view, FALSE); |
| 259 | return ret; |
247 | 260 | } |
248 | 261 | |
249 | 262 | /* --------------------------------------------------------------------------------------------- */ |
… |
… |
mcview_scroll_to_cursor (mcview_t * view |
295 | 308 | |
296 | 309 | /* --------------------------------------------------------------------------------------------- */ |
297 | 310 | |
298 | | void |
| 311 | int |
299 | 312 | mcview_moveto_top (mcview_t * view) |
300 | 313 | { |
| 314 | int ret; |
| 315 | ret = -MSG_HANDLED; |
| 316 | |
| 317 | if (view->dpy_start > 0 || view->hex_cursor > 0 || view->dpy_text_column > 0) |
| 318 | ret = MSG_HANDLED; |
| 319 | |
301 | 320 | view->dpy_start = 0; |
302 | 321 | view->hex_cursor = 0; |
303 | 322 | view->dpy_text_column = 0; |
304 | 323 | mcview_movement_fixups (view, TRUE); |
| 324 | return ret; |
305 | 325 | } |
306 | 326 | |
307 | 327 | /* --------------------------------------------------------------------------------------------- */ |
… |
… |
mcview_moveto_bottom (mcview_t * view) |
334 | 354 | |
335 | 355 | /* --------------------------------------------------------------------------------------------- */ |
336 | 356 | |
337 | | void |
| 357 | int |
338 | 358 | mcview_moveto_bol (mcview_t * view) |
339 | 359 | { |
| 360 | int ret; |
| 361 | ret = -MSG_HANDLED; |
340 | 362 | if (view->hex_mode) |
341 | 363 | { |
| 364 | ret = MSG_HANDLED; |
342 | 365 | view->hex_cursor -= view->hex_cursor % view->bytes_per_line; |
343 | 366 | } |
344 | 367 | else if (!view->text_wrap_mode) |
345 | 368 | { |
| 369 | /* this doesn't seem to do anything, according to this file header this is always the beginning of current line */ |
346 | 370 | view->dpy_start = mcview_bol (view, view->dpy_start, 0); |
347 | 371 | } |
| 372 | if (view->dpy_text_column > 0) |
| 373 | ret = view->dpy_text_column; |
348 | 374 | view->dpy_text_column = 0; |
349 | 375 | mcview_movement_fixups (view, TRUE); |
| 376 | return ret; |
350 | 377 | } |
351 | 378 | |
352 | 379 | /* --------------------------------------------------------------------------------------------- */ |