Add support for max_text_width configuration setting
authorNikolas Garofil <garo@dunaldi.garofil.be>
Wed, 25 Nov 2009 15:04:49 +0000 (16:04 +0100)
committerNikolas Garofil <garo@dunaldi.garofil.be>
Wed, 25 Nov 2009 15:04:49 +0000 (16:04 +0100)
ChangeLog
doc/config_settings.xml
extras/nano/conky.nanorc
extras/vim/syntax/conkyrc.vim
src/conky.c

index 9ada263..46c0bc0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,6 @@
+2009-11-24
+       * Added support for max_text_width
+
 2009-11-20
        * Allow for mpd connections to use IPv6
 
index 52463ae..19c4f18 100644 (file)
     <varlistentry>
         <term>
             <command>
+                <option>max_text_width</option>
+            </command>
+            <option>width</option>
+        </term>
+        <listitem>When a line in the output contains 'width'
+       chars and the end isn't reached, the next char will start
+       on a new line. If you want to make sure that lines don't
+       get broken, set 'width' to 0
+        <para /></listitem>
+    </varlistentry>
+    <varlistentry>
+        <term>
+            <command>
                 <option>max_user_text</option>
             </command>
             <option>bytes</option>
index e037fa7..2bf7c66 100644 (file)
@@ -5,7 +5,7 @@
 syntax "conky" "(\.*conkyrc.*$|conky.conf)"
 
 ## Configuration items
-color green "\<(alignment|append_file|background|border_inner_margin|border_outer_margin|border_width|color0|color1|color2|color3|color4|color5|color6|color7|color8|color9|colorN|cpu_avg_samples|default_bar_size|default_color|default_gauge_size|default_graph_size|default_outline_color|default_shade_color|diskio_avg_samples|display|double_buffer|draw_borders|draw_graph_borders|draw_outline|draw_shades|extra_newline|font|format_human_readable|gap_x|gap_y|if_up_strictness|imap|imlib_cache_flush_interval|imlib_cache_size|lua_draw_hook_post|lua_draw_hook_pre|lua_load|lua_shutdown_hook|lua_startup_hook|mail_spool|max_port_monitor_connections|max_specials|max_user_text|maximum_width|minimum_size|mpd_host|mpd_password|mpd_port|music_player_interval|net_avg_samples|no_buffers|out_to_console|out_to_ncurses|out_to_stderr|out_to_x|override_utf8_locale|overwrite_file|own_window|own_window_class|own_window_colour|own_window_hints|own_window_title|own_window_transparent|own_window_type|pad_percents|pop3|sensor_device|short_units|show_graph_range|show_graph_scale|stippled_borders|temperature_unit|template|template0|template1|template2|template3|template4|template5|template6|template7|template8|template9|text|text_buffer_size|top_cpu_separate|top_name_width|total_run_times|update_interval|update_interval_on_battery|uppercase|use_spacer|use_xft|xftalpha|xftfont)\>"
+color green "\<(alignment|append_file|background|border_inner_margin|border_outer_margin|border_width|color0|color1|color2|color3|color4|color5|color6|color7|color8|color9|colorN|cpu_avg_samples|default_bar_size|default_color|default_gauge_size|default_graph_size|default_outline_color|default_shade_color|diskio_avg_samples|display|double_buffer|draw_borders|draw_graph_borders|draw_outline|draw_shades|extra_newline|font|format_human_readable|gap_x|gap_y|if_up_strictness|imap|imlib_cache_flush_interval|imlib_cache_size|lua_draw_hook_post|lua_draw_hook_pre|lua_load|lua_shutdown_hook|lua_startup_hook|mail_spool|max_port_monitor_connections|max_specials|max_text_width|max_user_text|maximum_width|minimum_size|mpd_host|mpd_password|mpd_port|music_player_interval|net_avg_samples|no_buffers|out_to_console|out_to_ncurses|out_to_stderr|out_to_x|override_utf8_locale|overwrite_file|own_window|own_window_class|own_window_colour|own_window_hints|own_window_title|own_window_transparent|own_window_type|pad_percents|pop3|sensor_device|short_units|show_graph_range|show_graph_scale|stippled_borders|temperature_unit|template|template0|template1|template2|template3|template4|template5|template6|template7|template8|template9|text|text_buffer_size|top_cpu_separate|top_name_width|total_run_times|update_interval|update_interval_on_battery|uppercase|use_spacer|use_xft|xftalpha|xftfont)\>"
 
 ## Configuration item constants
 color yellow "\<(above|below|bottom_left|bottom_right|bottom_middle|desktop|dock|no|none|normal|override|skip_pager|skip_taskbar|sticky|top_left|top_right|top_middle|middle_left|middle_right|middle_middle|undecorated|yes)\>"
index 0575577..63c1f42 100644 (file)
@@ -12,7 +12,7 @@ endif
 
 syn region ConkyrcComment start=/^\s*#/ end=/$/
 
-syn keyword ConkyrcSetting alignment append_file background border_inner_margin border_outer_margin border_width color0 color1 color2 color3 color4 color5 color6 color7 color8 color9 colorN cpu_avg_samples default_bar_size default_color default_gauge_size default_graph_size default_outline_color default_shade_color diskio_avg_samples display double_buffer draw_borders draw_graph_borders draw_outline draw_shades extra_newline font format_human_readable gap_x gap_y if_up_strictness imap imlib_cache_flush_interval imlib_cache_size lua_draw_hook_post lua_draw_hook_pre lua_load lua_shutdown_hook lua_startup_hook mail_spool max_port_monitor_connections max_specials max_user_text maximum_width minimum_size mpd_host mpd_password mpd_port music_player_interval net_avg_samples no_buffers out_to_console out_to_ncurses out_to_stderr out_to_x override_utf8_locale overwrite_file own_window own_window_class own_window_colour own_window_hints own_window_title own_window_transparent own_window_type pad_percents pop3 sensor_device short_units show_graph_range show_graph_scale stippled_borders temperature_unit template template0 template1 template2 template3 template4 template5 template6 template7 template8 template9 text text_buffer_size top_cpu_separate top_name_width total_run_times update_interval update_interval_on_battery uppercase use_spacer use_xft xftalpha xftfont
+syn keyword ConkyrcSetting alignment append_file background border_inner_margin border_outer_margin border_width color0 color1 color2 color3 color4 color5 color6 color7 color8 color9 colorN cpu_avg_samples default_bar_size default_color default_gauge_size default_graph_size default_outline_color default_shade_color diskio_avg_samples display double_buffer draw_borders draw_graph_borders draw_outline draw_shades extra_newline font format_human_readable gap_x gap_y if_up_strictness imap imlib_cache_flush_interval imlib_cache_size lua_draw_hook_post lua_draw_hook_pre lua_load lua_shutdown_hook lua_startup_hook mail_spool max_port_monitor_connections max_specials max_text_width max_user_text maximum_width minimum_size mpd_host mpd_password mpd_port music_player_interval net_avg_samples no_buffers out_to_console out_to_ncurses out_to_stderr out_to_x override_utf8_locale overwrite_file own_window own_window_class own_window_colour own_window_hints own_window_title own_window_transparent own_window_type pad_percents pop3 sensor_device short_units show_graph_range show_graph_scale stippled_borders temperature_unit template template0 template1 template2 template3 template4 template5 template6 template7 template8 template9 text text_buffer_size top_cpu_separate top_name_width total_run_times update_interval update_interval_on_battery uppercase use_spacer use_xft xftalpha xftfont
 
 syn keyword ConkyrcConstant
                        \ above
index 5f04df1..bd592f3 100644 (file)
@@ -175,6 +175,7 @@ double update_interval;
 double update_interval_old;
 double update_interval_bat;
 void *global_cpu = NULL;
+unsigned int max_text_width = 0;
 
 int argc_copy;
 char** argv_copy;
@@ -2402,6 +2403,7 @@ static void generate_text(void)
 {
        struct information *cur = &info;
        char *p;
+       unsigned int i, j, k;
 
        special_count = 0;
 
@@ -2418,6 +2420,22 @@ static void generate_text(void)
        p = text_buffer;
 
        generate_text_internal(p, max_user_text, global_root_object, cur);
+       if(max_text_width > 0) {
+               for(i = 0, j = 0; p[i] != 0; i++) {
+                       if(p[i] == '\n') j = 0;
+                       else if(j == max_text_width) {
+                               k = i + strlen(p + i) + 1;
+                               if(k < text_buffer_size) {
+                                       while(k != i) {
+                                               p[k] = p[k-1];
+                                               k--;
+                                       }
+                                       p[k] = '\n';
+                                       j = 0;
+                               } else NORM_ERR("The end of the text_buffer is reached, increase \"text_buffer_size\"");
+                       } else j++;
+               }
+       }
 
        if (stuff_in_uppercase) {
                char *tmp_p;
@@ -4718,6 +4736,9 @@ char load_config_file(const char *f)
                CONF("times_in_seconds") {
                        set_times_in_seconds(string_to_bool(value));
                }
+               CONF("max_text_width") {
+                       max_text_width = atoi(value);
+               }
                CONF("out_to_console") {
                        if(string_to_bool(value)) {
                                output_methods |= TO_STDOUT;