[QScintilla] Incremental way of loading a a big file in QScintilla (Very very important)

Roshni Lalwani roshiba81 at gmail.com
Thu Jun 16 06:02:45 BST 2016


A gentle reminder

On Wed, Jun 15, 2016 at 7:13 PM, Roshni Lalwani <roshiba81 at gmail.com> wrote:

> A gentle reminder
>
> On Mon, Jun 13, 2016 at 6:10 PM, Roshni Lalwani <roshiba81 at gmail.com>
> wrote:
>
>> A gentle reminder. I am stuck in my problem and your help will he really
>> helpful
>>
>> On Sat, Jun 11, 2016 at 4:01 PM, Roshni Lalwani <roshiba81 at gmail.com>
>> wrote:
>>
>>> If we load the fiile a file in in object of QScintilla  using folllowing
>>> code
>>>
>>>
>>> Header myEditor.h
>>>
>>> class myScintilla: public QScintilla {
>>>      public readFile();};
>>> #include  "myEditor.h"void myEditor::readFile() {
>>>
>>>    if (FILE* fp = fopen(ofilename.toLatin1(), "r")) {
>>>     QTextStream ts(fp, QIODevice::ReadOnly);
>>>     int bufferSize =(1024* 1024)/2;
>>>     do {
>>>       QString s = ts.read(bufferSize);
>>>       append(s);
>>>     } while(!ts.atEnd());}
>>>
>>>
>>>
>>> there will be still performance issue while reading large files. It took
>>> around
>>>
>>> 1) 25 seconds to read a file of size 1.5 GB. (Machine cores 4 , 16 GB
>>> RAM) 2 10 seconds of file of size 512MB (on same machine)
>>>
>>> Is there any way we can load the file in QScintilla object incrementally
>>> based on movement of scrollbar?
>>>
>>> There is  ILoader in Scintilla::ScintillaEdit that has the capabilty .
>>> How Can we have same capability in object of QScintilla  and how Can we
>>> use ILoader  in object of QScintilla
>>>
>>>
>>> The Scintilla documentation can be found at:
>>>
>>> Here’s the basic mechanism to load the source into Scintilla using
>>> ILoader. dEditorPtr is an instance of Scintilla::ScintillaEdit. lFileSize
>>> is the size of the source file in bytes.
>>>
>>>
>>>
>>> char lBuffer[8192];
>>>
>>> size_t lCnt;
>>>
>>> ILoader *lLoader = (ILoader*) dEditorPtr->createLoader(lFileSize);
>>>
>>> FILE* lFP = fopen(ofilename.toLatin1(), “r”);
>>>
>>> while (!feof(lFP)) {
>>>
>>>    lCnt = fread(lBuffer, 1, sizeof(lBuffer), lFP);
>>>
>>>    if (lLoader->AddData(lBuffer, lCnt) != SC_STATUS_OK) {
>>>
>>>       // report error
>>>
>>>    }
>>>
>>> }
>>>
>>> dEditorPtr->setDocPointer(lLoader->ConvertToDocument());
>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/qscintilla/attachments/20160616/0c766fc7/attachment-0001.html>


More information about the QScintilla mailing list