Author: jghali
Date: Thu Jul 16 09:42:24 2020
New Revision: 23921

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=23921
Log:
#16159: Add selectFrameText() to scripter

Modified:
    trunk/Scribus/doc/de/scripterapi-textframes.html
    trunk/Scribus/doc/en/scripterapi-textframes.html
    trunk/Scribus/doc/fr/scripterapi-textframes.html
    trunk/Scribus/doc/it/scripterapi-textframes.html
    trunk/Scribus/doc/ru/scripterapi-textframes.html
    trunk/Scribus/scribus/plugins/scriptplugin/cmdtext.cpp
    trunk/Scribus/scribus/plugins/scriptplugin/cmdtext.h
    trunk/Scribus/scribus/plugins/scriptplugin/scriptplugin.cpp
    trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdtext.cpp
    trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdtext.h
    trunk/Scribus/scribus/plugins/scriptplugin_py2x/scriptplugin.cpp

Modified: trunk/Scribus/doc/de/scripterapi-textframes.html
URL: 
http://scribus.net/websvn/diff.php?repname=Scribus&rev=23921&path=/trunk/Scribus/doc/de/scripterapi-textframes.html
==============================================================================
--- trunk/Scribus/doc/de/scripterapi-textframes.html    (original)
+++ trunk/Scribus/doc/de/scripterapi-textframes.html    Thu Jul 16 09:42:24 2020
@@ -117,9 +117,16 @@
 <p>Link two text frames. The frame named "fromname" is linked to the frame 
named "toname". The target frame must be an empty text frame and must not link 
to or be linked from any other frames already.</p>
 <p>May throw <a href="#ScribusException">ScribusException</a> if linking rules 
are violated.</p></dd>
 
+<dt><a name="-selectFrameText"><strong>selectFrameText</strong></a>(...)</dt>
+<dd><code>selectFrameText(start, count, ["name"])</code>
+<p>Selects "count" characters of text in the text frame "name" starting from 
the character "start". Character counting starts at 0. If "count" is zero, any 
text selection will be cleared. If "count" is -1, the selection will extend to 
the end of the frame. If "name" is not given the currently selected item is 
used.</p>
+<p>This function only acts on the text visible in the specified frame. If you 
need to work on the text contained in a text chain, use selectText() 
instead.</p>
+<p>As this function depends on text layout being up-to-date, you may need to 
call <a href="#-layoutText">layoutText()</a> or <a 
href="#-layoutTextChain">layoutTextChain()</a> before calling this function in 
order to get expected result.</p>
+<p>May throw IndexError if the selection is outside the bounds of the 
text.</p></dd>
+
 <dt><a name="-selectText"><strong>selectText</strong></a>(...)</dt>
 <dd><code>selectText(start, count, ["name"])</code>
-<p>Selects "count" characters of text in the text frame "name" starting from 
the character "start". Character counting starts at 0. If "count" is zero, any 
text selection will be cleared.  If "name" is not given the currently selected 
item is used.</p>
+<p>Selects "count" characters of text in the text frame "name" starting from 
the character "start". Character counting starts at 0. If "count" is zero, any 
text selection will be cleared. If "name" is not given the currently selected 
item is used.</p>
 <p>May throw IndexError if the selection is outside the bounds of the text.</p>
 <p>There is no specific command to select all of the text in a frame. To 
accomplish this, you might create a function in your script which you would 
call with the name of the frame as follows:</p>
 <p><b>def SelectAllText(textframe):</b></p>
@@ -128,7 +135,6 @@
     <p><b>&nbsp;&nbsp;&nbsp;&nbsp;return</b></p></dd>
 <dd><p>One of the reasons this is important is that, should you want to select 
a frame and then apply a Paragraph Style to the frame, you will find that a 
frame with multiple paragraphs will not have the style set for all of the text, 
only the last paragraph. Therefore, the solution is to select all the text of 
the frame, and then apply the style.</p></dd>
 
-
 <dt><a name="-setColumns"><strong>setColumns</strong></a>(...)</dt>
 <dd><code>setColumns(nr, ["name"])</code>
 <p>Sets the number of columns of the text frame "name" to the integer "nr". If 
"name" is not given the currently selected item is used.</p>

Modified: trunk/Scribus/doc/en/scripterapi-textframes.html
URL: 
http://scribus.net/websvn/diff.php?repname=Scribus&rev=23921&path=/trunk/Scribus/doc/en/scripterapi-textframes.html
==============================================================================
--- trunk/Scribus/doc/en/scripterapi-textframes.html    (original)
+++ trunk/Scribus/doc/en/scripterapi-textframes.html    Thu Jul 16 09:42:24 2020
@@ -117,9 +117,16 @@
 <p>Link two text frames. The frame named "fromname" is linked to the frame 
named "toname". The target frame must be an empty text frame and must not link 
to or be linked from any other frames already.</p>
 <p>May throw <a href="#ScribusException">ScribusException</a> if linking rules 
are violated.</p></dd>
 
+<dt><a name="-selectFrameText"><strong>selectFrameText</strong></a>(...)</dt>
+<dd><code>selectFrameText(start, count, ["name"])</code>
+<p>Selects "count" characters of text in the text frame "name" starting from 
the character "start". Character counting starts at 0. If "count" is zero, any 
text selection will be cleared. If "count" is -1, the selection will extend to 
the end of the frame. If "name" is not given the currently selected item is 
used.</p>
+<p>This function only acts on the text visible in the specified frame. If you 
need to work on the text contained in a text chain, use selectText() 
instead.</p>
+<p>As this function depends on text layout being up-to-date, you may need to 
call <a href="#-layoutText">layoutText()</a> or <a 
href="#-layoutTextChain">layoutTextChain()</a> before calling this function in 
order to get expected result.</p>
+<p>May throw IndexError if the selection is outside the bounds of the 
text.</p></dd>
+
 <dt><a name="-selectText"><strong>selectText</strong></a>(...)</dt>
 <dd><code>selectText(start, count, ["name"])</code>
-<p>Selects "count" characters of text in the text frame "name" starting from 
the character "start". Character counting starts at 0. If "count" is zero, any 
text selection will be cleared.  If "name" is not given the currently selected 
item is used.</p>
+<p>Selects "count" characters of text in the text frame "name" starting from 
the character "start". Character counting starts at 0. If "count" is zero, any 
text selection will be cleared. If "name" is not given the currently selected 
item is used.</p>
 <p>May throw IndexError if the selection is outside the bounds of the text.</p>
 <p>There is no specific command to select all of the text in a frame. To 
accomplish this, you might create a function in your script which you would 
call with the name of the frame as follows:</p>
 <p><b>def SelectAllText(textframe):</b></p>
@@ -128,7 +135,6 @@
     <p><b>&nbsp;&nbsp;&nbsp;&nbsp;return</b></p></dd>
 <dd><p>One of the reasons this is important is that, should you want to select 
a frame and then apply a Paragraph Style to the frame, you will find that a 
frame with multiple paragraphs will not have the style set for all of the text, 
only the last paragraph. Therefore, the solution is to select all the text of 
the frame, and then apply the style.</p></dd>
 
-
 <dt><a name="-setColumns"><strong>setColumns</strong></a>(...)</dt>
 <dd><code>setColumns(nr, ["name"])</code>
 <p>Sets the number of columns of the text frame "name" to the integer "nr". If 
"name" is not given the currently selected item is used.</p>

Modified: trunk/Scribus/doc/fr/scripterapi-textframes.html
URL: 
http://scribus.net/websvn/diff.php?repname=Scribus&rev=23921&path=/trunk/Scribus/doc/fr/scripterapi-textframes.html
==============================================================================
--- trunk/Scribus/doc/fr/scripterapi-textframes.html    (original)
+++ trunk/Scribus/doc/fr/scripterapi-textframes.html    Thu Jul 16 09:42:24 2020
@@ -94,9 +94,17 @@
 <p>&Eacute;tablit un lien entre deux cadres de texte. Le cadre nommé 
"nomDepart" est lié au cadre "nomArrivee". Le cadre cible doit &ecirc;tre un 
cadre de texte vide et ne doit pas pointer vers d'autres cadres ni porter un 
lien provenant d'autres cadres.</p>
 <p>Peut générer <a href="#ScribusException">ScribusException</a> en cas 
d'infraction des règles de liens.</p></dd>
 
+
+<dt><a name="-selectFrameText"><strong>selectFrameText</strong></a>(...)</dt>
+<dd><code>selectFrameText(depart, compte, ["nom"])</code>
+<p>Sélectionne le nombre ("compte") de caractères de texte dans le cadre de 
texte "nom" en partant du caractère "départ". Le décompte des caractères 
commence &agrave; 0. Si "compte" est égal &agrave; zéro, tout le texte sera 
effacé. Si "compte" est égal à -1, la sélection s'étendra jusqu'au dernier 
charactère du cadre. Si "nom" n'est pas fourni, l'élément sélectionné est 
utilisé.</p>
+<p>Cette fonction agit uniquement sur le texte visible dans le cadre 
spécifié. Si vous avez besoin de travailler sur le texte contenu dans une 
chaîne de texte, veuillez utiliser selectText() à la place.</p>
+<p>Comme cette fonction nécessite que la mise en page du texte soit à jour, 
il est possible que vous ayez besoin d'appeler <a 
href="#-layoutText">layoutText()</a> ou <a 
href="#-layoutTextChain">layoutTextChain()</a> au préalable afin d'obtenir le 
résultat attendu.</p>
+<p>Peut générer IndexError si la sélection dépasse les limites du 
texte.</p></dd>
+
 <dt><a name="-selectText"><strong>selectText</strong></a>(...)</dt>
 <dd><code>selectText(depart, compte, ["nom"])</code>
-<p>Sélectionne le nombre ("compte") de caractères de texte dans le cadre de 
texte "nom" en partant du caractère "départ". Le décompte des caractères 
commence &agrave; 0. Si "compte" est &agrave; zéro, tout le texte sera 
effacé. Si "nom" n'est pas fourni, l'élément sélectionné est utilisé. </p>
+<p>Sélectionne le nombre ("compte") de caractères de texte dans le cadre de 
texte "nom" en partant du caractère "départ". Le décompte des caractères 
commence &agrave; 0. Si "compte" est égal &agrave; zéro, tout le texte sera 
effacé. Si "nom" n'est pas fourni, l'élément sélectionné est utilisé.</p>
 <p>Peut générer IndexError si la sélection dépasse les limites du 
texte.</p></dd>
 
 <dt><a name="-setColumns"><strong>setColumns</strong></a>(...)</dt>

Modified: trunk/Scribus/doc/it/scripterapi-textframes.html
URL: 
http://scribus.net/websvn/diff.php?repname=Scribus&rev=23921&path=/trunk/Scribus/doc/it/scripterapi-textframes.html
==============================================================================
--- trunk/Scribus/doc/it/scripterapi-textframes.html    (original)
+++ trunk/Scribus/doc/it/scripterapi-textframes.html    Thu Jul 16 09:42:24 2020
@@ -117,9 +117,16 @@
 <p>Link two text frames. The frame named "fromname" is linked to the frame 
named "toname". The target frame must be an empty text frame and must not link 
to or be linked from any other frames already.</p>
 <p>May throw <a href="#ScribusException">ScribusException</a> if linking rules 
are violated.</p></dd>
 
+<dt><a name="-selectFrameText"><strong>selectFrameText</strong></a>(...)</dt>
+<dd><code>selectFrameText(start, count, ["name"])</code>
+<p>Selects "count" characters of text in the text frame "name" starting from 
the character "start". Character counting starts at 0. If "count" is zero, any 
text selection will be cleared. If "count" is -1, the selection will extend to 
the end of the frame. If "name" is not given the currently selected item is 
used.</p>
+<p>This function only acts on the text visible in the specified frame. If you 
need to work on the text contained in a text chain, use selectText() 
instead.</p>
+<p>As this function depends on text layout being up-to-date, you may need to 
call <a href="#-layoutText">layoutText()</a> or <a 
href="#-layoutTextChain">layoutTextChain()</a> before calling this function in 
order to get expected result.</p>
+<p>May throw IndexError if the selection is outside the bounds of the 
text.</p></dd>
+
 <dt><a name="-selectText"><strong>selectText</strong></a>(...)</dt>
 <dd><code>selectText(start, count, ["name"])</code>
-<p>Selects "count" characters of text in the text frame "name" starting from 
the character "start". Character counting starts at 0. If "count" is zero, any 
text selection will be cleared.  If "name" is not given the currently selected 
item is used.</p>
+<p>Selects "count" characters of text in the text frame "name" starting from 
the character "start". Character counting starts at 0. If "count" is zero, any 
text selection will be cleared. If "name" is not given the currently selected 
item is used.</p>
 <p>May throw IndexError if the selection is outside the bounds of the text.</p>
 <p>There is no specific command to select all of the text in a frame. To 
accomplish this, you might create a function in your script which you would 
call with the name of the frame as follows:</p>
 <p><b>def SelectAllText(textframe):</b></p>
@@ -128,7 +135,6 @@
     <p><b>&nbsp;&nbsp;&nbsp;&nbsp;return</b></p></dd>
 <dd><p>One of the reasons this is important is that, should you want to select 
a frame and then apply a Paragraph Style to the frame, you will find that a 
frame with multiple paragraphs will not have the style set for all of the text, 
only the last paragraph. Therefore, the solution is to select all the text of 
the frame, and then apply the style.</p></dd>
 
-
 <dt><a name="-setColumns"><strong>setColumns</strong></a>(...)</dt>
 <dd><code>setColumns(nr, ["name"])</code>
 <p>Sets the number of columns of the text frame "name" to the integer "nr". If 
"name" is not given the currently selected item is used.</p>

Modified: trunk/Scribus/doc/ru/scripterapi-textframes.html
URL: 
http://scribus.net/websvn/diff.php?repname=Scribus&rev=23921&path=/trunk/Scribus/doc/ru/scripterapi-textframes.html
==============================================================================
--- trunk/Scribus/doc/ru/scripterapi-textframes.html    (original)
+++ trunk/Scribus/doc/ru/scripterapi-textframes.html    Thu Jul 16 09:42:24 2020
@@ -117,9 +117,16 @@
 <p>Link two text frames. The frame named "fromname" is linked to the frame 
named "toname". The target frame must be an empty text frame and must not link 
to or be linked from any other frames already.</p>
 <p>May throw <a href="#ScribusException">ScribusException</a> if linking rules 
are violated.</p></dd>
 
+<dt><a name="-selectFrameText"><strong>selectFrameText</strong></a>(...)</dt>
+<dd><code>selectFrameText(start, count, ["name"])</code>
+<p>Selects "count" characters of text in the text frame "name" starting from 
the character "start". Character counting starts at 0. If "count" is zero, any 
text selection will be cleared. If "count" is -1, the selection will extend to 
the end of the frame. If "name" is not given the currently selected item is 
used.</p>
+<p>This function only acts on the text visible in the specified frame. If you 
need to work on the text contained in a text chain, use selectText() 
instead.</p>
+<p>As this function depends on text layout being up-to-date, you may need to 
call <a href="#-layoutText">layoutText()</a> or <a 
href="#-layoutTextChain">layoutTextChain()</a> before calling this function in 
order to get expected result.</p>
+<p>May throw IndexError if the selection is outside the bounds of the 
text.</p></dd>
+
 <dt><a name="-selectText"><strong>selectText</strong></a>(...)</dt>
 <dd><code>selectText(start, count, ["name"])</code>
-<p>Selects "count" characters of text in the text frame "name" starting from 
the character "start". Character counting starts at 0. If "count" is zero, any 
text selection will be cleared.  If "name" is not given the currently selected 
item is used.</p>
+<p>Selects "count" characters of text in the text frame "name" starting from 
the character "start". Character counting starts at 0. If "count" is zero, any 
text selection will be cleared. If "name" is not given the currently selected 
item is used.</p>
 <p>May throw IndexError if the selection is outside the bounds of the text.</p>
 <p>There is no specific command to select all of the text in a frame. To 
accomplish this, you might create a function in your script which you would 
call with the name of the frame as follows:</p>
 <p><b>def SelectAllText(textframe):</b></p>
@@ -128,7 +135,6 @@
     <p><b>&nbsp;&nbsp;&nbsp;&nbsp;return</b></p></dd>
 <dd><p>One of the reasons this is important is that, should you want to select 
a frame and then apply a Paragraph Style to the frame, you will find that a 
frame with multiple paragraphs will not have the style set for all of the text, 
only the last paragraph. Therefore, the solution is to select all the text of 
the frame, and then apply the style.</p></dd>
 
-
 <dt><a name="-setColumns"><strong>setColumns</strong></a>(...)</dt>
 <dd><code>setColumns(nr, ["name"])</code>
 <p>Sets the number of columns of the text frame "name" to the integer "nr". If 
"name" is not given the currently selected item is used.</p>

Modified: trunk/Scribus/scribus/plugins/scriptplugin/cmdtext.cpp
URL: 
http://scribus.net/websvn/diff.php?repname=Scribus&rev=23921&path=/trunk/Scribus/scribus/plugins/scriptplugin/cmdtext.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/scriptplugin/cmdtext.cpp      (original)
+++ trunk/Scribus/scribus/plugins/scriptplugin/cmdtext.cpp      Thu Jul 16 
09:42:24 2020
@@ -868,6 +868,49 @@
        }
        item->setVerticalAlignment(alignment);
        item->update();
+
+       Py_RETURN_NONE;
+}
+
+PyObject *scribus_selectframetext(PyObject* /* self */, PyObject* args)
+{
+       char *Name = const_cast<char*>("");
+       int start, selcount;
+       if (!PyArg_ParseTuple(args, "ii|es", &start, &selcount, "utf-8", &Name))
+               return nullptr;
+       if (!checkHaveDocument())
+               return nullptr;
+       PageItem *item = GetUniqueItem(QString::fromUtf8(Name));
+       if (item == nullptr)
+               return nullptr;
+
+       if (!(item->isTextFrame()) && !(item->isPathText()))
+       {
+               PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot select 
text in a non-text frame", "python error").toLocal8Bit().constData());
+               return nullptr;
+       }
+       if (selcount < -1)
+       {
+               PyErr_SetString(PyExc_IndexError, QObject::tr("Count must be 
positive, 0 or -1", "python error").toLocal8Bit().constData());
+               return nullptr;
+       }
+
+       if (start < 0 || (selcount > 0 && ((item->lastInFrame() == -1) || 
(selcount + start > item->lastInFrame() - item->firstInFrame() + 1))))
+       {
+               PyErr_SetString(PyExc_IndexError, QObject::tr("Selection index 
out of bounds", "python error").toLocal8Bit().constData());
+               return nullptr;
+       }
+       start += item->firstInFrame();
+       if (selcount == -1)
+               selcount = item->lastInFrame() + 1 - start;
+       item->itemText.deselectAll();
+       if (selcount == 0)
+       {
+               item->HasSel = false;
+               Py_RETURN_NONE;
+       }
+       item->itemText.select(start, selcount, true);
+       item->HasSel = true;
 
        Py_RETURN_NONE;
 }
@@ -1391,6 +1434,7 @@
          << scribus_layouttextchain__doc__
          << scribus_linktextframes__doc__
          << scribus_outlinetext__doc__
+         << scribus_selectframetext__doc__
          << scribus_selecttext__doc__
          << scribus_setalign__doc__
          << scribus_setcolumngap__doc__

Modified: trunk/Scribus/scribus/plugins/scriptplugin/cmdtext.h
URL: 
http://scribus.net/websvn/diff.php?repname=Scribus&rev=23921&path=/trunk/Scribus/scribus/plugins/scriptplugin/cmdtext.h
==============================================================================
--- trunk/Scribus/scribus/plugins/scriptplugin/cmdtext.h        (original)
+++ trunk/Scribus/scribus/plugins/scriptplugin/cmdtext.h        Thu Jul 16 
09:42:24 2020
@@ -388,10 +388,31 @@
 PyObject *scribus_setdirection(PyObject * /*self*/, PyObject* args);
 
 /*! docstring */
+PyDoc_STRVAR(scribus_selectframetext__doc__,
+QT_TR_NOOP("selectFrameText(start, count, [\"name\"])\n\
+\n\
+Selects \"count\" characters of text in the text frame \"name\" starting from 
the\n\
+character \"start\". Character counting starts at 0.\n\
+If \"count\" is zero, any text selection will be cleared.\n\
+If \"count\" is -1, the selection will extend to the end of the frame.\n\
+If \"name\" is not given the currently selected item is used.\n\
+\n\
+This function only acts on the text visible in the specified frame. If you 
need to \n\
+work on the text contained in a text chain, use selectText() instead.\n\
+As this function depends on text layout being up-to-date, you may need to call 
\n\
+layoutText() or layoutTextChain() before calling this function in order to get 
\n\
+expected result.\n\
+\n\
+May throw IndexError if the selection is outside the bounds of the text.\n\
+"));
+/*! Select frame text */
+PyObject *scribus_selectframetext(PyObject * /*self*/, PyObject* args);
+
+/*! docstring */
 PyDoc_STRVAR(scribus_selecttext__doc__,
 QT_TR_NOOP("selectText(start, count, [\"name\"])\n\
 \n\
-Selects \"count\" characters of text in the text frame \"name\" starting from 
the\n\
+Selects \"count\" characters of text in the story of the text frame \"name\" 
starting from the\n\
 character \"start\". Character counting starts at 0. If \"count\" is zero, 
any\n\
 text selection will be cleared.  If \"name\" is not given the currently\n\
 selected item is used.\n\

Modified: trunk/Scribus/scribus/plugins/scriptplugin/scriptplugin.cpp
URL: 
http://scribus.net/websvn/diff.php?repname=Scribus&rev=23921&path=/trunk/Scribus/scribus/plugins/scriptplugin/scriptplugin.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/scriptplugin/scriptplugin.cpp (original)
+++ trunk/Scribus/scribus/plugins/scriptplugin/scriptplugin.cpp Thu Jul 16 
09:42:24 2020
@@ -484,6 +484,7 @@
        {const_cast<char*>("setImageOffset"), scribus_setimageoffset, 
METH_VARARGS, tr(scribus_setimageoffset__doc__)},
        {const_cast<char*>("selectionCount"), (PyCFunction)scribus_selcount, 
METH_NOARGS, tr(scribus_selcount__doc__)},
        {const_cast<char*>("selectObject"), scribus_selectobj, METH_VARARGS, 
tr(scribus_selectobj__doc__)},
+       {const_cast<char*>("selectFrameText"), scribus_selectframetext, 
METH_VARARGS, tr(scribus_selectframetext__doc__)},
        {const_cast<char*>("selectText"), scribus_selecttext, METH_VARARGS, 
tr(scribus_selecttext__doc__)},
        {const_cast<char*>("sentToLayer"), scribus_senttolayer, METH_VARARGS, 
tr(scribus_senttolayer__doc__)},
        {const_cast<char*>("setActiveLayer"), scribus_setactivelayer, 
METH_VARARGS, tr(scribus_setactivelayer__doc__)},

Modified: trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdtext.cpp
URL: 
http://scribus.net/websvn/diff.php?repname=Scribus&rev=23921&path=/trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdtext.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdtext.cpp (original)
+++ trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdtext.cpp Thu Jul 16 
09:42:24 2020
@@ -868,6 +868,49 @@
        }
        item->setVerticalAlignment(alignment);
        item->update();
+
+       Py_RETURN_NONE;
+}
+
+PyObject *scribus_selectframetext(PyObject* /* self */, PyObject* args)
+{
+       char *Name = const_cast<char*>("");
+       int start, selcount;
+       if (!PyArg_ParseTuple(args, "ii|es", &start, &selcount, "utf-8", &Name))
+               return nullptr;
+       if (!checkHaveDocument())
+               return nullptr;
+       PageItem *item = GetUniqueItem(QString::fromUtf8(Name));
+       if (item == nullptr)
+               return nullptr;
+
+       if (!(item->isTextFrame()) && !(item->isPathText()))
+       {
+               PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot select 
text in a non-text frame", "python error").toLocal8Bit().constData());
+               return nullptr;
+       }
+       if (selcount < -1)
+       {
+               PyErr_SetString(PyExc_IndexError, QObject::tr("Count must be 
positive, 0 or -1", "python error").toLocal8Bit().constData());
+               return nullptr;
+       }
+
+       if (start < 0 || (selcount > 0 && ((item->lastInFrame() == -1) || 
(selcount + start > item->lastInFrame() - item->firstInFrame() + 1))))
+       {
+               PyErr_SetString(PyExc_IndexError, QObject::tr("Selection index 
out of bounds", "python error").toLocal8Bit().constData());
+               return nullptr;
+       }
+       start += item->firstInFrame();
+       if (selcount == -1)
+               selcount = item->lastInFrame() + 1 - start;
+       item->itemText.deselectAll();
+       if (selcount == 0)
+       {
+               item->HasSel = false;
+               Py_RETURN_NONE;
+       }
+       item->itemText.select(start, selcount, true);
+       item->HasSel = true;
 
        Py_RETURN_NONE;
 }

Modified: trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdtext.h
URL: 
http://scribus.net/websvn/diff.php?repname=Scribus&rev=23921&path=/trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdtext.h
==============================================================================
--- trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdtext.h   (original)
+++ trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdtext.h   Thu Jul 16 
09:42:24 2020
@@ -388,6 +388,27 @@
 PyObject *scribus_setdirection(PyObject * /*self*/, PyObject* args);
 
 /*! docstring */
+PyDoc_STRVAR(scribus_selectframetext__doc__,
+QT_TR_NOOP("selectFrameText(start, count, [\"name\"])\n\
+\n\
+Selects \"count\" characters of text in the text frame \"name\" starting from 
the\n\
+character \"start\". Character counting starts at 0.\n\
+If \"count\" is zero, any text selection will be cleared.\n\
+If \"count\" is -1, the selection will extend to the end of the frame.\n\
+If \"name\" is not given the currently selected item is used.\n\
+\n\
+This function only acts on the text visible in the specified frame. If you 
need to \n\
+work on the text contained in a text chain, use selectText() instead.\n\
+As this function depends on text layout being up-to-date, you may need to call 
\n\
+layoutText() or layoutTextChain() before calling this function in order to get 
\n\
+expected result.\n\
+\n\
+May throw IndexError if the selection is outside the bounds of the text.\n\
+"));
+/*! Select frame text */
+PyObject *scribus_selectframetext(PyObject * /*self*/, PyObject* args);
+
+/*! docstring */
 PyDoc_STRVAR(scribus_selecttext__doc__,
 QT_TR_NOOP("selectText(start, count, [\"name\"])\n\
 \n\

Modified: trunk/Scribus/scribus/plugins/scriptplugin_py2x/scriptplugin.cpp
URL: 
http://scribus.net/websvn/diff.php?repname=Scribus&rev=23921&path=/trunk/Scribus/scribus/plugins/scriptplugin_py2x/scriptplugin.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/scriptplugin_py2x/scriptplugin.cpp    
(original)
+++ trunk/Scribus/scribus/plugins/scriptplugin_py2x/scriptplugin.cpp    Thu Jul 
16 09:42:24 2020
@@ -484,6 +484,7 @@
        {const_cast<char*>("setImageOffset"), scribus_setimageoffset, 
METH_VARARGS, tr(scribus_setimageoffset__doc__)},
        {const_cast<char*>("selectionCount"), (PyCFunction)scribus_selcount, 
METH_NOARGS, tr(scribus_selcount__doc__)},
        {const_cast<char*>("selectObject"), scribus_selectobj, METH_VARARGS, 
tr(scribus_selectobj__doc__)},
+       {const_cast<char*>("selectFrameText"), scribus_selectframetext, 
METH_VARARGS, tr(scribus_selectframetext__doc__)},
        {const_cast<char*>("selectText"), scribus_selecttext, METH_VARARGS, 
tr(scribus_selecttext__doc__)},
        {const_cast<char*>("sentToLayer"), scribus_senttolayer, METH_VARARGS, 
tr(scribus_senttolayer__doc__)},
        {const_cast<char*>("setActiveLayer"), scribus_setactivelayer, 
METH_VARARGS, tr(scribus_setactivelayer__doc__)},


_______________________________________________
scribus-commit mailing list
[email protected]
http://lists.scribus.net/mailman/listinfo/scribus-commit

Reply via email to