~g-bluehut/ubuntu-terminal-app/whitespacefix

« back to all changes in this revision

Viewing changes to src/plugin/konsole/History.cpp

  • Committer: Michael Vetter
  • Date: 2014-07-30 09:38:31 UTC
  • Revision ID: g.bluehut@gmail.com-20140730093831-dls7ehwga1ieb7hz
Remove trailing whitespaces

Found some trailing whitespaces when I read the code and removed them.

Show diffs side-by-side

added added

removed removed

Lines of Context:
92
92
    fileMap(0)
93
93
{
94
94
  if (tmpFile.open())
95
 
  { 
 
95
  {
96
96
    tmpFile.setAutoRemove(true);
97
97
    ion = tmpFile.handle();
98
98
  }
116
116
    //if mmap'ing fails, fall back to the read-lseek combination
117
117
    if ( fileMap == MAP_FAILED )
118
118
    {
119
 
            readWriteBalance = 0; 
 
119
            readWriteBalance = 0;
120
120
            fileMap = 0;
121
121
            qDebug() << __FILE__ << __LINE__ << ": mmap'ing history failed.  errno = " << errno;
122
122
    }
139
139
{
140
140
  if ( fileMap )
141
141
          unmap();
142
 
        
 
142
 
143
143
  readWriteBalance++;
144
144
 
145
145
  int rc = 0;
151
151
 
152
152
void HistoryFile::get(unsigned char* bytes, int len, int loc)
153
153
{
154
 
  //count number of get() calls vs. number of add() calls.  
155
 
  //If there are many more get() calls compared with add() 
 
154
  //count number of get() calls vs. number of add() calls.
 
155
  //If there are many more get() calls compared with add()
156
156
  //calls (decided by using MAP_THRESHOLD) then mmap the log
157
157
  //file to improve performance.
158
158
  readWriteBalance--;
165
165
            bytes[i]=fileMap[loc+i];
166
166
  }
167
167
  else
168
 
  {    
 
168
  {
169
169
      int rc = 0;
170
170
 
171
171
      if (loc < 0 || len < 0 || loc + len > length)
201
201
 
202
202
// History Scroll File //////////////////////////////////////
203
203
 
204
 
/* 
 
204
/*
205
205
   The history scroll makes a Row(Row(Cell)) from
206
206
   two history buffers. The index buffer contains
207
207
   start of line positions which refere to the cells
221
221
HistoryScrollFile::~HistoryScrollFile()
222
222
{
223
223
}
224
 
 
 
224
 
225
225
int HistoryScrollFile::getLines()
226
226
{
227
227
  return index.len() / sizeof(int);
246
246
{
247
247
  if (lineno <= 0) return 0;
248
248
  if (lineno <= getLines())
249
 
    { 
250
 
    
 
249
    {
 
250
 
251
251
    if (!index.isMapped())
252
252
            index.map();
253
 
    
 
253
 
254
254
    int res;
255
255
    index.get((unsigned char*)&res,sizeof(int),(lineno-1)*sizeof(int));
256
256
    return res;
345
345
bool HistoryScrollBuffer::isWrappedLine(int lineNumber)
346
346
{
347
347
  Q_ASSERT( lineNumber >= 0 && lineNumber < _maxLineCount );
348
 
    
 
348
 
349
349
  if (lineNumber < _usedLines)
350
350
  {
351
351
    //kDebug() << "Line" << lineNumber << "wrapped is" << _wrappedLine[bufferIndex(lineNumber)];
361
361
 
362
362
  Q_ASSERT( lineNumber < _maxLineCount );
363
363
 
364
 
  if (lineNumber >= _usedLines) 
 
364
  if (lineNumber >= _usedLines)
365
365
  {
366
366
    memset(buffer, 0, count * sizeof(Character));
367
367
    return;
368
368
  }
369
 
  
 
369
 
370
370
  const HistoryLine& line = _historyBuffer[bufferIndex(lineNumber)];
371
371
 
372
372
  //kDebug() << "startCol " << startColumn;
374
374
  //kDebug() << "count " << count;
375
375
 
376
376
  Q_ASSERT( startColumn <= line.size() - count );
377
 
    
 
377
 
378
378
  memcpy(buffer, line.constData() + startColumn , count * sizeof(Character));
379
379
}
380
380
 
382
382
{
383
383
    HistoryLine* oldBuffer = _historyBuffer;
384
384
    HistoryLine* newBuffer = new HistoryLine[lineCount];
385
 
    
 
385
 
386
386
    for ( int i = 0 ; i < qMin(_usedLines,(int)lineCount) ; i++ )
387
387
    {
388
388
        newBuffer[i] = oldBuffer[bufferIndex(i)];
389
389
    }
390
 
    
 
390
 
391
391
    _usedLines = qMin(_usedLines,(int)lineCount);
392
392
    _maxLineCount = lineCount;
393
393
    _head = ( _usedLines == _maxLineCount ) ? 0 : _usedLines-1;
410
410
        return (_head+lineNumber+1) % _maxLineCount;
411
411
    }
412
412
    else
413
 
    {   
 
413
    {
414
414
        return lineNumber;
415
415
    }
416
416
}
508
508
void HistoryScrollBlockArray::addCells(const Character a[], int count)
509
509
{
510
510
  Block *b = m_blockArray.lastBlock();
511
 
  
 
511
 
512
512
  if (!b) return;
513
513
 
514
514
  // put cells in block's data
572
572
void CompactHistoryBlockList::deallocate(void* ptr)
573
573
{
574
574
  Q_ASSERT( !list.isEmpty());
575
 
  
576
 
  int i=0;  
 
575
 
 
576
  int i=0;
577
577
  CompactHistoryBlock *block = list.at(i);
578
578
  while ( i<list.size() && !block->contains(ptr) )
579
 
  { 
 
579
  {
580
580
    i++;
581
581
    block=list.at(i);
582
582
  }
583
583
 
584
584
  Q_ASSERT( i<list.size() );
585
 
  
 
585
 
586
586
  block->deallocate();
587
587
 
588
588
  if (!block->isInUse())
604
604
  return blockList.allocate(size);
605
605
}
606
606
 
607
 
CompactHistoryLine::CompactHistoryLine ( const TextLine& line, CompactHistoryBlockList& bList ) 
 
607
CompactHistoryLine::CompactHistoryLine ( const TextLine& line, CompactHistoryBlockList& bList )
608
608
  : blockList(bList),
609
609
    formatLength(0)
610
610
{
611
611
  length=line.size();
612
 
      
 
612
 
613
613
  if (line.size() > 0) {
614
614
    formatLength=1;
615
615
    int k=1;
616
 
  
 
616
 
617
617
    // count number of different formats in this text line
618
618
    Character c = line[0];
619
619
    while ( k<length )
625
625
      }
626
626
      k++;
627
627
    }
628
 
  
 
628
 
629
629
    //kDebug() << "number of different formats in string: " << formatLength;
630
630
    formatArray = (CharacterFormat*) blockList.allocate(sizeof(CharacterFormat)*formatLength);
631
631
    Q_ASSERT (formatArray!=NULL);
632
632
    text = (quint16*) blockList.allocate(sizeof(quint16)*line.size());
633
633
    Q_ASSERT (text!=NULL);
634
 
  
 
634
 
635
635
    length=line.size();
636
636
    formatLength=formatLength;
637
637
    wrapped=false;
638
 
  
 
638
 
639
639
    // record formats and their positions in the format array
640
640
    c=line[0];
641
641
    formatArray[0].setFormat ( c );
642
642
    formatArray[0].startPos=0;                        // there's always at least 1 format (for the entire line, unless a change happens)
643
 
  
 
643
 
644
644
    k=1;                                              // look for possible format changes
645
645
    int j=1;
646
646
    while ( k<length && j<formatLength )
655
655
      }
656
656
      k++;
657
657
    }
658
 
  
 
658
 
659
659
    // copy character values
660
660
    for ( int i=0; i<line.size(); i++ )
661
661
    {
673
673
    blockList.deallocate(text);
674
674
    blockList.deallocate(formatArray);
675
675
  }
676
 
  blockList.deallocate(this);  
 
676
  blockList.deallocate(this);
677
677
}
678
678
 
679
679
void CompactHistoryLine::getCharacter ( int index, Character &r )
918
918
 
919
919
HistoryScroll* HistoryTypeFile::scroll(HistoryScroll *old) const
920
920
{
921
 
  if (dynamic_cast<HistoryFile *>(old)) 
 
921
  if (dynamic_cast<HistoryFile *>(old))
922
922
     return old; // Unchanged.
923
923
 
924
924
  HistoryScroll *newScroll = new HistoryScrollFile(m_fileName);
945
945
  }
946
946
 
947
947
  delete old;
948
 
  return newScroll; 
 
948
  return newScroll;
949
949
}
950
950
 
951
951
int HistoryTypeFile::maximumLineCount() const