Am 07.03.2011 um 01:02 schrieb Pavel Sanda:

> Stephan Witt wrote:
>>> it doesn't meet the requests i have seen up to now. the people asking for 
>>> this
>>> feature wants generally much wider cursor than you propose - closer to 
>>> block cursor.
>> 
>> I cannot believe that a 4 pixel wide cursor makes sense when
> 
> i can't understand 4 pixels at any normal zoom, but funny enough just next 
> mail in users list ;)
> 
>> using 120% zoom.
> 
> does this value have any meaning if you dont know which particular font is 
> used?
> 
>> A possibility - nevertheless I tried to avoid another RC variable - 
>> would be to introduce the RC variable with the option to choose automatic 
>> cursor width
>> or a arbitrary fixed width. Should I prepare that?
> 
> so instead of one you propose two now? :)
> 
> anyway, my acceptance for 2.0 was due to minimal possibility of regressions 
> introduced
> when we have RC variable for width. for any magic computations its too late. 
> even stupid
> spellcheck underline had many iterations and rc2 is not good experimental 
> sand.

So I've made a patch to add RC + prefs interface for it.
When cursor width is set to zero automatic zoom happens.

Stephan

Index: src/LyXRC.h
===================================================================
--- src/LyXRC.h (Revision 37889)
+++ src/LyXRC.h (Arbeitskopie)
@@ -65,6 +65,7 @@
                RC_CONVERTER_CACHE_MAXAGE,
                RC_COPIER,
                RC_CURSOR_FOLLOWS_SCROLLBAR,
+               RC_CURSOR_WIDTH,
                RC_DATE_INSERT_FORMAT,
                RC_DEFAULT_DECIMAL_POINT,
                RC_DEFAULT_LANGUAGE,
@@ -530,6 +531,8 @@
        ScrollWheelZoom scroll_wheel_zoom;
        ///
        bool force_paint_single_char;
+       ///
+       int cursor_width;
 };
 
 
Index: src/LyXRC.cpp
===================================================================
--- src/LyXRC.cpp       (Revision 37889)
+++ src/LyXRC.cpp       (Arbeitskopie)
@@ -85,6 +85,7 @@
        { "\\converter_cache_maxage", LyXRC::RC_CONVERTER_CACHE_MAXAGE },
        { "\\copier", LyXRC::RC_COPIER },
        { "\\cursor_follows_scrollbar", LyXRC::RC_CURSOR_FOLLOWS_SCROLLBAR },
+       { "\\cursor_width", LyXRC::RC_CURSOR_WIDTH },
        { "\\date_insert_format", LyXRC::RC_DATE_INSERT_FORMAT },
        { "\\def_file", LyXRC::RC_DEFFILE },
        { "\\default_decimal_point", LyXRC::RC_DEFAULT_DECIMAL_POINT },
@@ -360,6 +361,7 @@
        completion_inline_dots = -1;
        completion_inline_delay = 0.2;
        default_decimal_point = ".";
+       cursor_width = 1;
 }
 
 
@@ -903,6 +905,10 @@
                        lexrc >> cursor_follows_scrollbar;
                        break;
 
+               case RC_CURSOR_WIDTH:
+                       lexrc >> cursor_width;
+                       break;
+
                case RC_SCROLL_BELOW_DOCUMENT:
                        lexrc >> scroll_below_document;
                        break;
@@ -1754,6 +1760,15 @@
                }
                if (tag != RC_LAST)
                        break;
+       case RC_CURSOR_WIDTH:
+               if (ignore_system_lyxrc ||
+                       cursor_width
+                       != system_lyxrc.cursor_width) {
+                       os << "\\cursor_width "
+                       << cursor_width << '\n';
+               }
+               if (tag != RC_LAST)
+                       break;
        case RC_SCROLL_BELOW_DOCUMENT:
                if (ignore_system_lyxrc ||
                    scroll_below_document
@@ -3005,6 +3020,7 @@
        case LyXRC::RC_EXPORT_OVERWRITE:
        case LyXRC::RC_DEFAULT_DECIMAL_POINT:
        case LyXRC::RC_SCROLL_WHEEL_ZOOM:
+       case LyXRC::RC_CURSOR_WIDTH:
        case LyXRC::RC_LAST:
                break;
        }
@@ -3078,6 +3094,10 @@
                str = _("LyX normally doesn't update the cursor position if you 
move the scrollbar. Set to true if you'd prefer to always have the cursor on 
screen.");
                break;
 
+       case RC_CURSOR_WIDTH:
+               str = _("Configure the width of the text cursor. Automatic zoom 
controled cursor width used when set to 0.");
+               break;
+
        case RC_SCROLL_BELOW_DOCUMENT:
                str = _("LyX normally doesn't allow the user to scroll further 
than the bottom of the document. Set to true if you prefer to scroll the bottom 
of the document to the top of the screen");
                break;
Index: src/frontends/qt4/GuiWorkArea.cpp
===================================================================
--- src/frontends/qt4/GuiWorkArea.cpp   (Revision 37889)
+++ src/frontends/qt4/GuiWorkArea.cpp   (Arbeitskopie)
@@ -73,11 +73,6 @@
 
 #include <cmath>
 
-#ifdef Q_WS_WIN
-int const CursorWidth = 2;
-#else
-int const CursorWidth = 1;
-#endif
 int const TabIndicatorWidth = 3;
 
 #undef KeyPress
@@ -128,7 +123,9 @@
 
 class CursorWidget {
 public:
-       CursorWidget() {}
+       CursorWidget() {
+               recomputeWidth();
+       }
 
        void draw(QPainter & painter)
        {
@@ -141,7 +138,7 @@
                int bot = rect_.bottom();
 
                // draw vertical line
-               painter.fillRect(x_, y, CursorWidth, rect_.height(), color_);
+               painter.fillRect(x_, y, cursor_width_, rect_.height(), color_);
 
                // draw RTL/LTR indication
                painter.setPen(color_);
@@ -149,7 +146,7 @@
                        if (rtl_)
                                painter.drawLine(x_, bot, x_ - l, bot);
                        else
-                               painter.drawLine(x_, bot, x_ + CursorWidth + r, 
bot);
+                               painter.drawLine(x_, bot, x_ + cursor_width_ + 
r, bot);
                }
 
                // draw completion triangle
@@ -160,8 +157,8 @@
                                painter.drawLine(x_ - 1, m - d, x_ - 1 - d, m);
                                painter.drawLine(x_ - 1, m + d, x_ - 1 - d, m);
                        } else {
-                               painter.drawLine(x_ + CursorWidth, m - d, x_ + 
CursorWidth + d, m);
-                               painter.drawLine(x_ + CursorWidth, m + d, x_ + 
CursorWidth + d, m);
+                               painter.drawLine(x_ + cursor_width_, m - d, x_ 
+ cursor_width_ + d, m);
+                               painter.drawLine(x_ + cursor_width_, m + d, x_ 
+ cursor_width_ + d, m);
                        }
                }
        }
@@ -196,11 +193,17 @@
                }
 
                // compute overall rectangle
-               rect_ = QRect(x - l, y, CursorWidth + r + l, h);
+               rect_ = QRect(x - l, y, cursor_width_ + r + l, h);
        }
 
        void show(bool set_show = true) { show_ = set_show; }
        void hide() { show_ = false; }
+       int cursorWidth() const { return cursor_width_; }
+       void recomputeWidth() {
+               cursor_width_ = lyxrc.cursor_width
+                       ? lyxrc.cursor_width 
+                       : 1 + int((lyxrc.zoom + 50) / 200.0);
+       }
 
        QRect const & rect() { return rect_; }
 
@@ -219,6 +222,8 @@
        QRect rect_;
        /// x position (were the vertical line is drawn)
        int x_;
+       
+       int cursor_width_;
 };
 
 
@@ -600,6 +605,7 @@
                && !completer_->popupVisible()
                && !completer_->inlineVisible();
        cursor_visible_ = true;
+       cursor_->recomputeWidth();
        showCursor(p.x_, p.y_, h, l_shape, isrtl, completable);
 }
 
Index: src/frontends/qt4/GuiPrefs.cpp
===================================================================
--- src/frontends/qt4/GuiPrefs.cpp      (Revision 37889)
+++ src/frontends/qt4/GuiPrefs.cpp      (Arbeitskopie)
@@ -2528,6 +2528,8 @@
                this, SIGNAL(changed()));
        connect(macroEditStyleCO, SIGNAL(activated(int)),
                this, SIGNAL(changed()));
+       connect(cursorWidthSB, SIGNAL(valueChanged(int)),
+               this, SIGNAL(changed()));
        connect(fullscreenLimitGB, SIGNAL(clicked()),
                this, SIGNAL(changed()));
        connect(fullscreenWidthSB, SIGNAL(valueChanged(int)),
@@ -2555,6 +2557,7 @@
                case 1: rc.macro_edit_style = LyXRC::MACRO_EDIT_INLINE; break;
                case 2: rc.macro_edit_style = LyXRC::MACRO_EDIT_LIST;   break;
        }
+       rc.cursor_width = cursorWidthSB->value();
        rc.full_screen_toolbars = toggleToolbarsCB->isChecked();
        rc.full_screen_scrollbar = toggleScrollbarCB->isChecked();
        rc.full_screen_tabbar = toggleTabbarCB->isChecked();
@@ -2572,6 +2575,7 @@
        sortEnvironmentsCB->setChecked(rc.sort_layouts);
        groupEnvironmentsCB->setChecked(rc.group_layouts);
        macroEditStyleCO->setCurrentIndex(rc.macro_edit_style);
+       cursorWidthSB->setValue(rc.cursor_width);
        toggleScrollbarCB->setChecked(rc.full_screen_scrollbar);
        toggleToolbarsCB->setChecked(rc.full_screen_toolbars);
        toggleTabbarCB->setChecked(rc.full_screen_tabbar);
Index: src/frontends/qt4/ui/PrefEditUi.ui
===================================================================
--- src/frontends/qt4/ui/PrefEditUi.ui  (Revision 37889)
+++ src/frontends/qt4/ui/PrefEditUi.ui  (Arbeitskopie)
@@ -38,6 +38,36 @@
         </property>
        </widget>
       </item>
+      <item row="1" column="0" >
+        <layout class="QGridLayout" name="gridLayout_4" >
+         <item row="0" column="0" >
+          <widget class="QLabel" name="label_3" >
+           <property name="text" >
+            <string>Cursor width (&amp;pixels):</string>
+           </property>
+           <property name="buddy" >
+            <cstring>cursorWidthSB</cstring>
+           </property>
+          </widget>
+         </item>
+         <item row="0" column="1" >
+          <widget class="QSpinBox" name="cursorWidthSB" >
+           <property name="minimum" >
+            <number>0</number>
+           </property>
+           <property name="maximum" >
+            <number>10</number>
+           </property>
+           <property name="singleStep" >
+            <number>1</number>
+           </property>
+           <property name="value" >
+            <number>1</number>
+           </property>
+          </widget>
+         </item>
+        </layout>
+      </item>
       <item row="2" column="0" >
        <widget class="QCheckBox" name="scrollBelowCB" >
         <property name="text" >

Reply via email to