Commit Graph

806 Commits

Author SHA1 Message Date
Ilia Maslakov
5f45920a32 Ticket #1514 (incorrect draw right margin)
fixed incorrect drawind right margin if option show_right_margin = 0

Signed-off-by: Ilia Maslakov <il.smind@gmail.com>
2010-01-15 01:29:21 +01:00
Ilia Maslakov
c3755f0c50 added keybind CK_Toggle_Show_Margin for toggle show right margin (with empty default key)
added new color pair for right margin (editrightmargin) into skins

Signed-off-by: Ilia Maslakov <il.smind@gmail.com>
2010-01-06 14:31:40 +03:00
Ilia Maslakov
7c2692cf8c add new etitor parameter editor_show_right_margin
Signed-off-by: Ilia Maslakov <il.smind@gmail.com>
2010-01-06 14:26:02 +03:00
Ilia Maslakov
5203d6739d Ticket #1514 (show right margin)
* added new color pair EDITOR_RIGHT_MARGIN_COLOR
    * show right margin. Used EDITOR_RIGHT_MARGIN_COLOR color for drawing text beyond rigth edge.

Signed-off-by: Ilia Maslakov <il.smind@gmail.com>
2010-01-06 14:26:01 +03:00
Andrew Borodin
b881a7b9ad Some simple optimization of syntax highlighting engine.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2010-01-05 12:19:41 +03:00
Andrew Borodin
39ddea87ee Ticket #1843: slow syntax highlighting engine in editor.
Initial step: some #include's arrangement.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2010-01-05 12:19:41 +03:00
Enrico Weigelt, metux IT service
ec1a52fb0a VFS: renamed USE_VFS to ENABLE_VFS 2009-12-30 11:06:11 +02:00
Enrico Weigelt, metux IT service
80b3776c20 VFS: fixed lots of missing includes to vfs/vfs.h 2009-12-30 11:06:09 +02:00
Sergei Trofimovich
4d9bc2923b Ticket #1906: edit: crash on file open whoen some Syntax files are absent (reported by pavlinux)
valgrind log snippet: (from here http://pavlinux.ru/vgmc.log)

> ==26750== HEAP SUMMARY:
> ==26750==     in use at exit: 0 bytes in 0 blocks
> ==26750==   ==26749== Invalid free() / delete / delete[]
> ==26749==    at 0x4A06DD8: free (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
> ==26749==    by 0x48B5F9: edit_read_syntax_rules (syntax.c:766)
> ==26749==    by 0x48CDA7: edit_read_syntax_file (syntax.c:1140)
> ==26749==    by 0x48D06D: edit_load_syntax (syntax.c:1219)
> ==26749==    by 0x4762F6: edit_init (edit.c:834)
> ==26749==    by 0x4858FC: edit_file (editwidget.c:241)
> ==26749==    by 0x44D017: do_edit_at_line (cmd.c:304)
> ==26749==    by 0x44D098: do_edit (cmd.c:324)
> ==26749==    by 0x44D10E: edit_cmd (cmd.c:331)
> ==26749==    by 0x46C2E4: midnight_execute_cmd (main.c:1193)
> ==26749==    by 0x46CD41: midnight_callback (main.c:1690)
> ==26749==    by 0x4353F4: buttonbar_call (widget.c:2654)
> ==26749==  Address 0x60f8e10 is 0 bytes inside a block of size 30 free'd
> ==26749==    at 0x4A06DD8: free (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
> ==26749==    by 0x48B32C: open_include_file (syntax.c:705)
> ==26749==    by 0x48B6E8: edit_read_syntax_rules (syntax.c:784)
> ==26749==    by 0x48CDA7: edit_read_syntax_file (syntax.c:1140)
> ==26749==    by 0x48D06D: edit_load_syntax (syntax.c:1219)
> ==26749==    by 0x4762F6: edit_init (edit.c:834)
> ==26749==    by 0x4858FC: edit_file (editwidget.c:241)
> ==26749==    by 0x44D017: do_edit_at_line (cmd.c:304)
> ==26749==    by 0x44D098: do_edit (cmd.c:324)
> ==26749==    by 0x44D10E: edit_cmd (cmd.c:331)
> ==26749==    by 0x46C2E4: midnight_execute_cmd (main.c:1193)
> ==26749==    by 0x46CD41: midnight_callback (main.c:1690)

We see doublefree memory corruption here, introduced by spurious 'g_free(error_file_name)'
of changeset:0c17219b2ab5cb5fe2e73f8d7cc9c11c755a3ae4 (syntax.c file)

The rest of code seems to store real syntax file name there.

Making code the same as part above: don't free 'error_file_name'

Signed-off-by: Sergei Trofimovich <slyfox@inbox.ru>
2009-12-27 10:23:50 +02:00
Vit Rosin
280d7e88f9 change type of some parameters from int to long.
Changed functions:
 * edit_count_lines()
 * edit_move_forward()
 * edit_move_backward()

Signed-off-by: Slava Zanko <slavazanko@gmail.com>
2009-12-25 19:44:34 +02:00
Andrew Borodin
b9400e140f Ticket #1892: fixed resource leaks.
Fixed memory leak.
Fixed unclosed file descriptors.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2009-12-23 22:31:30 +03:00
Ilia Maslakov
3edfb0bc58 Ticket #1884 (incorrect jump to the EOF)
fixed edit_move_to_top for save the current cursor column position after jump to the EOF.

Signed-off-by: Ilia Maslakov <il.smind@gmail.com>
2009-12-21 10:43:57 +03:00
Ilia Maslakov
b0c58fbf4d Ticket #1877 (edit scroll down fix)
fixed edit_move_updown: cursor held, text scrolled up.

Signed-off-by: Ilia Maslakov <il.smind@gmail.com>
2009-12-17 17:10:55 +00:00
Ilia Maslakov
26689fc39e editcmd.c 'eval_marks': removed unused variable 'diff'
Signed-off-by: Ilia Maslakov <il.smind@gmail.com>
2009-12-16 11:10:44 +02:00
Andrew Borodin
dc604d811a The check result of g_new(), g_new0(), g_malloc(), g_malloc0() and g_realloc() is useless.
g_new(), g_new0(), g_malloc(), g_malloc0() and g_realloc() functions
never return NULL and call abort() on fail. So check result of these
functions is useless. g_try_new(), g_try_new0(), g_try_malloc(),
g_try_malloc0() and g_try_realloc() functions are used instead.

Some minor optimization and code formatting are also performed.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2009-12-16 11:10:43 +02:00
Vit Rosin
b6875454b2 Unifying of g_strconcat() calls
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2009-12-16 11:10:43 +02:00
Andrew Borodin
ec5791b7af Types accuracy, minor optimization, removed unneeded goto and return.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2009-12-16 11:10:42 +02:00
Ilia Maslakov
b90825fee4 added NULL check before call g_utf8_find_prev_char, g_utf8_get_char_validated for more safety.
Signed-off-by: Ilia Maslakov <il.smind@gmail.com>
2009-12-16 11:10:42 +02:00
Andrew Borodin
1e32a51d2d Optimization of DLG_RESIZE message handling.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2009-12-16 11:10:42 +02:00
Sergei Trofimovich
4f2079fec7 clang: fixed useful warnings (-Wformat related)
../../mc/edit/editcmd.c:2519:50: error: field precision should have type 'int', but argument has type 'gsize' (aka 'unsigned long') [-Wformat]
    match_expr = g_strdup_printf ("(^|\\s+|\\b)%.*s[^\\s\\.=\\+\\[\\]\\(\\)\\,\\;\\:\\\"\\'\\-\\?\\/\\|\\\\\\{\\}\\*\\&\\^\\%%\\$#@\\!]+", word_len, bufpos);
                                                 ^                                                                                         ~~~~~~~~
../../mc/edit/editcmd.c:2700:38: error: field precision should have type 'int', but argument has type 'gsize' (aka 'unsigned long') [-Wformat]
    match_expr = g_strdup_printf ("%.*s", word_len, bufpos);
                                     ^    ~~~~~~~~
2 diagnostics generated.
make[2]: *** [editcmd.o] Error 1
make[2]: Target `all' not remade because of errors.
../../../mc/src/mcconfig/common.c:71:74: error: format string is not a string literal (potentially insecure) [-Wformat-security]
        g_propagate_error (error, g_error_new (mc_main_error_quark() ,0, strerror(errno)));
                                                                         ^~~~~~~~~~~~~~~
../../../mc/src/mcconfig/common.c:83:74: error: format string is not a string literal (potentially insecure) [-Wformat-security]
        g_propagate_error (error, g_error_new (mc_main_error_quark() ,0, strerror(errno)));
                                                                         ^~~~~~~~~~~~~~~
2 diagnostics generated.
make[3]: *** [libmcconfig_la-common.lo] Error 1
make[3]: Target `all' not remade because of errors.
../../mc/src/main.c:2165:41: error: format string is not a string literal (potentially insecure) [-Wformat-security]
        message (D_ERROR, _("Warning"), error->message);
                                        ^~~~~~~~~~~~~~
1 diagnostic generated.

Signed-off-by: Sergei Trofimovich <slyfox@inbox.ru>
2009-12-16 11:10:41 +02:00
Andrew Borodin
3e12139a94 Editor: some code clean up.
Removed unneeded goto, return, #ifdef.
Type accuracy.
Indentation.
Minor optimization.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Signed-off-by: Sergei Trofimovich <slyfox@inbox.ru>
2009-12-16 11:10:41 +02:00
Andrew Borodin
06311a3e40 Refactoring of editor initialization.
Since button bar is a part of editor dialog, its initialization
was moved from WIDGET_INIT stage to DLG_INIT one.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2009-12-16 11:10:40 +02:00
Slava Zanko
71bb255b2c Refactoring of edit_replace_cmd__conv_to_display() and edit_replace_cmd__conv_to_input() functions.
Now these functions will return newly allocated string in any case.
As third-side effect, fixed memory leak with '--disable-charset' configure option.

Signed-off-by: Slava Zanko <slavazanko@gmail.com>
2009-12-16 11:10:40 +02:00
Ilia Maslakov
af79d7b3ef fixed uninitialised editor buffers (detected by valgrind) thnx andrew_b
Signed-off-by: Ilia Maslakov <il.smind@gmail.com>
2009-12-16 11:10:40 +02:00
Andrew Borodin
d2e096044d Some speed optimization of editor.
Functions that are called only in one place have been maken inline.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2009-12-16 11:10:40 +02:00
Slava Zanko
7dc3b43a20 Merged code of two functions edit_move_up() and edit_move_down()
into one function with additional parameter.

Signed-off-by: Slava Zanko <slavazanko@gmail.com>
2009-12-10 09:28:31 +03:00
Ilia Maslakov
6ed3909280 Ticket #1628 (fix for drawing CJK chars)
fixed: drawing CJK character as '...'.
    Sometimes the CJK character gets replaced by three inverse dots.

Signed-off-by: Ilia Maslakov <il.smind@gmail.com>
2009-12-10 09:26:58 +03:00
Ilia Maslakov
dd5b7c8651 Ticket #1839 (troubles with vertical selection: delete, move, etc.)
fixed: 'eval_marks' for correct vertical block delete.

Signed-off-by: Ilia Maslakov <il.smind@gmail.com>

    fixed edit_block_delete, edit_delete_column_of_text for correct delete vertical block
    fixed cursor position after delete block

Signed-off-by: Ilia Maslakov <il.smind@gmail.com>
2009-12-09 14:58:02 +03:00
Ilia Maslakov
595eb7e3f0 Ticket #1809 (incorrect calculanion char width in 8-bit locales)
fixed: cursor placement and movements in non-ascii (cyrillic) UTF-8 files
    in 8-bit (KOI8-R) locales
    fixed incorrect width calculation in 7-bit codeset

Signed-off-by: Ilia Maslakov <il.smind@gmail.com>

    Minor optimization of edit_move_forward3() function.
    Also fixed build with --disable-charset option.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2009-12-09 14:42:51 +03:00
Ilia Maslakov
2ae5412fb7 refresh screen any way
Signed-off-by: Ilia Maslakov <il.smind@gmail.com>
2009-12-06 10:20:35 +03:00
Andrew Borodin
8eb860eb48 Ticket #1844: refactoring of goto in editor user_menu() function.
Refactoring of uneeded goto in user_menu() function in editor.
Thanks to Vit Rosin for originl patch.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2009-12-06 10:20:35 +03:00
Ilia Maslakov
99f0e50aba Ticket #1809 (editor: incorrect cursor positioning)
fixed: cursor positioning after non-printeble char (in 8-bit encoding)
    added: char convertion for correct cursor movement

Signed-off-by: Ilia Maslakov <il.smind@gmail.com>
2009-12-02 18:28:22 +00:00
Ilia Maslakov
cfc90ab23f fixed eval_marks for correct calculation of the sizes of the selected block
Signed-off-by: Ilia Maslakov <il.smind@gmail.com>
2009-11-24 20:35:09 +00:00
Ilia Maslakov
dc9029f599 Ticket #1839
fixed vertical selection behavior.

Signed-off-by: Ilia Maslakov <il.smind@gmail.com>
2009-11-24 20:33:15 +00:00
Ilia Maslakov
380504c8d9 Ticket #1837 (incorrect block selection)
fixed strange behavior of selection in editor.

Signed-off-by: Ilia Maslakov <il.smind@gmail.com>
2009-11-20 15:34:42 +03:00
Andrew Borodin
a193e2e56f Ticket #1831: fixed compilation warings of --disable-nls and --disable-charset options.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Signed-off-by: Slava Zanko <slavazanko@gmail.com>
2009-11-20 14:39:51 +03:00
Ilia Maslakov
51e7de4bb5 Ticket #1809 (invalid length of nonprintable chars)
fixed calculation of the cursor position in 'edit_move_forward3'.

Signed-off-by: Ilia Maslakov <il.smind@gmail.com>
2009-11-19 17:41:26 +03:00
Andrew Borodin
ed2e33574a Fixed generation of shortcut string for menu items.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2009-11-19 10:07:52 +03:00
Andrew Borodin
366067d0c3 Fixed CK_Menu command handling in editor.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2009-11-19 10:07:52 +03:00
Andrew Borodin
1ed7892f8e Modified ButtonBar engine to allow bind keys to unused buttons.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2009-11-19 10:07:51 +03:00
Andrew Borodin
c2693b7212 Implemented keybindings engine for ButtonBar (F1-F10 keys).
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2009-11-19 10:07:51 +03:00
Andrew Borodin
b7f367542a Modified menu command handling using DLG_ACTION message.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2009-11-19 10:07:51 +03:00
Andrew Borodin
11d21f1437 Modified dialog callback function.
Added two parameters:
  * Widget *sender -- to recognize the wiget that have sent message;
  * void *data -- to pass any user-defined data to the dialog.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2009-11-19 10:07:51 +03:00
Andrew Borodin
5592a472f6 Optimization of command handling. 2009-11-19 10:07:51 +03:00
Andrew Borodin
8224a26cf4 ButtonBar optimizations.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2009-11-19 10:07:51 +03:00
Andrew Borodin
da33e767e9 Type accuracy and code clean up.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2009-11-19 10:07:51 +03:00
Andrew Borodin
9b82c05fca Changed widget order in editor and viewer dialogs.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2009-11-19 10:07:51 +03:00
Andrew Borodin
71c9e4c668 Ticket #212: implemented keybindings for ButtonBar.
First step: renamed type of dialog command execution function.
Made execution function more flexible: added parameters for
sender and receiver widgets and user data.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2009-11-19 10:07:51 +03:00
Ilia Maslakov
64bc6aa1c7 Ticket #1792 (incorrect mouse movement)
Fixed incorrect mouse movement when text scrolled to the right.

Signed-off-by: Ilia Maslakov <il.smind@gmail.com>
2009-11-18 21:53:08 +00:00
Andrew Borodin
354b184463 Ticket #1810: fixed CK_Edit_Save_Mode command handling.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2009-11-11 13:55:52 +03:00