changeset 5584:dc574a6d2516

text editor: if edit_rows==0 (user profile or config), dynamically size the text editor height Accepts anything from 0..999 for edit_rows userprefs now. Dynamic height is 1.5 * current height. Use Preview if this is not enough. This is done for devices like the iPhone, when user can't operate double sliders. It might be comfortable even on other devices to not have to deal with double sliders.
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Thu, 25 Feb 2010 11:43:26 +0100
parents ea0b35b54bbf
children 4a50a70af35d
files MoinMoin/PageEditor.py MoinMoin/userprefs/prefs.py
diffstat 2 files changed, 10 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/PageEditor.py	Thu Feb 25 01:35:51 2010 +0100
+++ b/MoinMoin/PageEditor.py	Thu Feb 25 11:43:26 2010 +0100
@@ -420,6 +420,15 @@
 
         lang = self.pi.get('language', request.cfg.language_default)
 
+        if not text_rows:
+            # if no specific value is given for editor height, but 0, we
+            # compute the rows from the raw_body line count plus some
+            # extra rows for adding new text in the editor. Maybe this helps
+            # with the "double slider" usability issue, esp. for devices like
+            # the iphone where you can't operate both sliders.
+            current_rows = len(raw_body.split('\n'))
+            text_rows = max(10, int(current_rows * 1.5))
+
         request.write(
             u'''\
 <textarea id="editor-textarea" name="savetext" lang="%(lang)s" dir="%(dir)s" rows="%(rows)d" cols="80"
--- a/MoinMoin/userprefs/prefs.py	Thu Feb 25 01:35:51 2010 +0100
+++ b/MoinMoin/userprefs/prefs.py	Thu Feb 25 11:43:26 2010 +0100
@@ -130,7 +130,7 @@
 
         # editor size
         request.user.edit_rows = util.web.getIntegerInput(request, 'edit_rows',
-                                                          request.user.edit_rows, 10, 60)
+                                                          request.user.edit_rows, 0, 999)
 
         # try to get the editor
         request.user.editor_default = wikiutil.clean_input(form.get('editor_default', self.cfg.editor_default))