* Constructor.
*/
ReLines::ReLines() :
- QStringList(),
- m_empty() {
+ QStringList(),
+ m_empty() {
}
/**
* Destructor.
* <code>false</code>: undo is impossible
*/
void ReLines::insertPart(int lineNo, int col, const QString& text,
- bool withUndo) {
+ bool withUndo) {
if (lineNo >= 0 && lineNo < lineCount() && col >= 0) {
if (withUndo)
storeInsertPart(lineNo, col, text.length());
if (lastEoLn != endOfLine) {
int oldCount = lineCount();
insertLines(lineNo + 1,
- text.mid(endOfLine + 1, lastEoLn - endOfLine), true);
+ text.mid(endOfLine + 1, lastEoLn - endOfLine), true);
newLines = lineCount() - oldCount;
}
if (lastEoLn != text.length() - 1) {
replace(lineNo, current.mid(0, col));
else
replace(lineNo,
- current.mid(0, col) + current.mid(col + count));
+ current.mid(0, col) + current.mid(col + count));
}
}
}
* @param filename name of the file
*/
ReFile::ReFile(const QString& filename, bool readOnly, ReLogger* logger) :
- ReLineSource(),
- ReLines(),
- m_endOfLine(),
- m_filename(filename),
- m_file(filename),
- m_block(NULL),
- // in 32-bit address space we allocate only 10 MByte, in 64-bit environments 100 GByte
- m_blocksize(
- sizeof(void*) <= 4 ?
- 10 * 1024 * 1024ll : 0x100ll * 0x10000 * 0x10000),
- m_blockOffset(0),
- m_filesize(0),
- m_startOfLine(NULL),
- m_lineLength(0),
- m_lineOffset(0),
- m_currentLineNo(0),
- m_maxLineLength(0x10000),
- m_content(),
- m_readOnly(readOnly),
- m_logger(logger) {
+ ReLineSource(),
+ ReLines(),
+ m_endOfLine(),
+ m_filename(filename),
+ m_file(filename),
+ m_block(NULL),
+ // in 32-bit address space we allocate only 10 MByte, in 64-bit environments 100 GByte
+ m_blocksize(
+ sizeof(void*) <= 4 ?
+ 10 * 1024 * 1024ll : 0x100ll * 0x10000 * 0x10000),
+ m_blockOffset(0),
+ m_filesize(0),
+ m_startOfLine(NULL),
+ m_lineLength(0),
+ m_lineOffset(0),
+ m_currentLineNo(0),
+ m_maxLineLength(0x10000),
+ m_content(),
+ m_readOnly(readOnly),
+ m_logger(logger) {
#if defined __linux__
setEndOfLine("\n");
#elif defined __WIN32__
* false: a line has not been found
*/
bool ReFile::findLine(const char* toFind, bool ignoreCase, int& lineNo,
- QString* line) {
+ QString* line) {
bool rc = false;
int length;
int sourceLength = strlen(toFind);
const char* ptr = start;
int restLength = length - sourceLength + 1;
while (restLength > 0
- && (ptr = reinterpret_cast<const char*>(
- ignoreCase ?
- memchr(start, first, restLength) :
- memichr(start, first, restLength))) != NULL) {
+ && (ptr = reinterpret_cast<const char*>(
+ ignoreCase ?
+ memchr(start, first, restLength) :
+ memichr(start, first, restLength))) != NULL) {
if ((
- ignoreCase ?
- _memicmp(ptr, toFind, sourceLength) :
- memcmp(ptr, toFind, sourceLength)) == 0) {
+ ignoreCase ?
+ _memicmp(ptr, toFind, sourceLength) :
+ memcmp(ptr, toFind, sourceLength)) == 0) {
rc = true;
lineNo = m_currentLineNo;
QByteArray buffer(m_startOfLine, m_lineLength);
}
return rc;
}
-
/**
* Finds the next line with the given conditions.
*
* false: a line has not been found
*/
bool ReFile::findLine(const QString& includePattern, bool includeIsRegExpr,
- bool includeIgnoreCase, const QString& excludePattern,
- bool excludeIsRegExpr, bool excludeIgnoreCase, int& lineNo, QString* line) {
+ bool includeIgnoreCase, const QString& excludePattern,
+ bool excludeIsRegExpr, bool excludeIgnoreCase, int& lineNo, QString* line) {
bool rc = false;
if (line != NULL)
*line = "";
int ReFile::hasMoreLines(int index) {
bool rc = false;
-#if 0
+#if 1
+ ReUseParameter(index);
+#else
if (m_countLines >= 0) {
rc = index < m_countLines - 1;
} else {
if (m_currentLineNo == 65639)
m_currentLineNo += 0;
rc = m_startOfLine = remap(m_lineOffset += m_lineLength,
- m_maxLineLength, lineLength);
+ m_maxLineLength, lineLength);
const char* ptr = reinterpret_cast<const char*>(memchr(rc, '\n',
- lineLength));
+ lineLength));
if (ptr != NULL)
lineLength = ptr - rc + 1;
length = m_lineLength = lineLength;
size = m_filesize - offset;
// Note: size <= m_blocksize
if (m_block != NULL && offset >= m_blockOffset
- && offset + size <= m_blockOffset + m_blocksize) {
+ && offset + size <= m_blockOffset + m_blocksize) {
// new block is inside the internal block:
// no remapping needed
rc = m_block + (offset - m_blockOffset);
if (m_block != NULL)
m_file.unmap(reinterpret_cast<uchar*>(m_block));
m_block = reinterpret_cast<char*>(m_file.map(m_blockOffset,
- m_blocksize));
+ m_blocksize));
rc = m_block + (offset - m_blockOffset);
length = m_blocksize - (rc - m_block);
if (length > size)
* @return the name of an existing directory
*/
QByteArray ReFile::tempDir(const char* node, const char* parent,
- bool withSeparator) {
+ bool withSeparator) {
#if defined __linux__
QByteArray temp("/tmp");
static const char* firstVar = "TMP";
* @return the full name of a temporary file
*/
QByteArray ReFile::tempFile(const char* node, const char* parent,
- bool deleteIfExists) {
+ bool deleteIfExists) {
QByteArray rc(tempDir(parent));
if (!rc.endsWith('/'))
rc += '/';
* @param mode file write mode: "w" (write) or "a" (append)
*/
void ReFile::writeToFile(const char* filename, const char* content,
- size_t contentLength, const char* mode) {
+ size_t contentLength, const char* mode) {
FILE* fp = fopen(filename, mode);
if (fp != NULL) {
if (contentLength == (size_t) - 1)
* Constructor.
*/
ReUndoList::ReUndoList() :
- m_list(),
- m_current(NULL),
- m_lastLine(-1),
- m_lastPosition(-1),
- m_maxUndoSize(10 * 1024 * 1024),
- m_currentUndoSize(0) {
+ m_list(),
+ m_current(NULL),
+ m_lastLine(-1),
+ m_lastPosition(-1),
+ m_maxUndoSize(10 * 1024 * 1024),
+ m_currentUndoSize(0) {
}
/**
* @param list the list containing the lines for extracting the line content
*/
void ReUndoList::storeRemoveLines(int lineNo, int count,
- const QStringList& list) {
+ const QStringList& list) {
qint64 size = 0;
// Calculate the additional space
for (int ii = lineNo + count - 1; ii >= lineNo; ii--)
* @param edit the parent
*/
ReLook::ReLook() :
- m_font(NULL),
- m_metrics(NULL),
- m_foreground(FG_STANDARD),
- m_background(BG_STANDARD),
- m_edit(NULL) {
+ m_font(NULL),
+ m_metrics(NULL),
+ m_foreground(FG_STANDARD),
+ m_background(BG_STANDARD),
+ m_edit(NULL) {
}
/**
* @param look the presentation of the text
*/
ReEditText::ReEditText(const QString& text, ReLook* look) :
- m_text(text),
- m_look(look) {
+ m_text(text),
+ m_look(look) {
}
* @param edit the edit field (parent)
*/
void ReCursortLineBuilder::buildParagraph(ReParagraph& paragraph, int lineNo,
- ReEdit* edit) {
+ ReEdit* edit) {
if (lineNo == edit->cursorLineNo()) {
for (int ix = 0; ix < paragraph.length(); ix++) {
ReEditText* text = paragraph.at(ix);
* @param parent NULL or a widget which destroy the instance
*/
ReEdit::ReEdit(QWidget* parent) :
- QWidget(parent),
- ReMouseCatcher(),
- m_widthEdit(0),
- m_heightEdit(0),
- m_insertMode(true),
- m_breakLines(false),
- m_widthLineNo(50),
- m_widthVScrollBar(16),
- m_heightHScrollBar(16),
- m_looks(),
- m_standardBrush(new QBrush(Qt::SolidPattern)),
- m_scrollbarBrush(new QBrush(Qt::SolidPattern)),
- m_sliderBrush(new QBrush(Qt::ConicalGradientPattern)),
- m_brushColors(),
- m_standardPen(new QPen(Qt::SolidLine)),
- m_standardFont(NULL),
- m_standardMetrics(NULL),
- m_fontColors(),
- m_keyAlt(),
- m_keyAltControl(),
- m_keyAltControlShift(),
- m_keyAltShift(),
- m_keyControl(),
- m_keyControlShift(),
- m_keyRaw(),
- m_keyShift() {
+ QWidget(parent),
+ ReMouseCatcher(),
+ m_widthEdit(0),
+ m_heightEdit(0),
+ m_insertMode(true),
+ m_breakLines(false),
+ m_widthLineNumbers(50),
+ m_widthVScrollBar(16),
+ m_heightHScrollBar(16),
+ m_looks(),
+ m_standardBrush(new QBrush(Qt::SolidPattern)),
+ m_scrollbarBrush(new QBrush(Qt::SolidPattern)),
+ m_sliderBrush(new QBrush(Qt::ConicalGradientPattern)),
+ m_brushColors(),
+ m_standardPen(new QPen(Qt::SolidLine)),
+ m_standardFont(NULL),
+ m_standardMetrics(NULL),
+ m_fontColors(),
+ m_keyAlt(),
+ m_keyAltControl(),
+ m_keyAltControlShift(),
+ m_keyAltShift(),
+ m_keyControl(),
+ m_keyControlShift(),
+ m_keyRaw(),
+ m_keyShift() {
setFocusPolicy(Qt::WheelFocus);
m_standardFont = new QFont("Courier");
m_standardFont->setStyleHint(QFont::TypeWriter);
* @param length OUT: the slider length in pixel
*/
void calcSliderSize(int size, int minSize, double sizeFactor, double posFactor,
- int& position, int& length) {
+ int& position, int& length) {
if (sizeFactor > 1.0)
sizeFactor = 1.0;
if (posFactor > 100)
* @param posHorizontal the position of the scrollbar as factor [0..1]
*/
void ReEdit::drawScrollbars(QPainter& painter, const QRect& rect,
- double sizeVertical, double posVertical, double sizeHorizontal,
- double posHorizontal) {
+ double sizeVertical, double posVertical, double sizeHorizontal,
+ double posHorizontal) {
// We paint the vertical scrollbar:
QBrush brush(*m_brushColors[ReLook::BG_SCROLLBAR], Qt::SolidPattern);
painter.setBrush(brush);
static int width = 1;
static int width2 = 2 * width;
m_vScrollBar->setRect(x + width2, rect.top(), m_widthVScrollBar - width2,
- rect.height() - m_heightHScrollBar - width);
+ rect.height() - m_heightHScrollBar - width);
painter.drawRect(*m_vScrollBar);
// We paint the horizontal scrollbar:
- m_hScrollBar->setRect(rect.left() + m_widthLineNo,
- rect.bottom() - m_heightHScrollBar + width,
- rect.width() - m_widthVScrollBar - m_widthLineNo,
- m_heightHScrollBar - width2);
+ m_hScrollBar->setRect(rect.left() + m_widthLineNumbers,
+ rect.bottom() - m_heightHScrollBar + width,
+ rect.width() - m_widthVScrollBar - m_widthLineNumbers,
+ m_heightHScrollBar - width2);
painter.drawRect(*m_hScrollBar);
// Slider (vertical)
int sliderSize = 0;
int sliderPos = 0;
calcSliderSize(rect.height() - m_heightHScrollBar, m_heightHScrollBar,
- sizeVertical, posVertical, sliderPos, sliderSize);
+ sizeVertical, posVertical, sliderPos, sliderSize);
m_vSlider->setRect(x + width2, rect.top() + sliderPos + width,
- m_widthVScrollBar - width2, sliderSize - width2);
+ m_widthVScrollBar - width2, sliderSize - width2);
painter.drawRect(*m_vSlider);
// Slider (horizontal)
- calcSliderSize(rect.width() - m_widthLineNo - m_widthVScrollBar,
- m_heightHScrollBar, sizeHorizontal, posHorizontal, sliderPos,
- sliderSize);
- m_hSlider->setRect(rect.left() + m_widthLineNo + sliderPos,
- rect.bottom() - m_heightHScrollBar + width, sliderSize - width,
- m_heightHScrollBar - width2);
+ calcSliderSize(rect.width() - m_widthLineNumbers - m_widthVScrollBar,
+ m_heightHScrollBar, sizeHorizontal, posHorizontal, sliderPos,
+ sliderSize);
+ m_hSlider->setRect(rect.left() + m_widthLineNumbers + sliderPos,
+ rect.bottom() - m_heightHScrollBar + width, sliderSize - width,
+ m_heightHScrollBar - width2);
painter.drawRect(*m_hSlider);
}
ensureCursorVisible();
break;
case EA_BEGIN_OF_FILE:
- ensureCursorVisible(0);
+ m_cursorLineNo = 0;
+ m_cursorCol = -1;
+ ensureCursorVisible();
break;
case EA_END_OF_FILE:
- ensureCursorVisible(m_lines->lineCount() - 1);
+ m_cursorLineNo = m_lines->lineCount() - 1;
+ ensureCursorVisible();
break;
case EA_PAGE_UP:
// Do not change cursor line!
}
/**
- * Ensures that the cursor line is visible.
- *
- * @param cursorLine -1 or number of the new cursor line
+ * Ensures that the cursor is visible.
*/
-void ReEdit::ensureCursorVisible(int cursorLine) {
- if (cursorLine >= 0)
- m_cursorLineNo = cursorLine;
+void ReEdit::ensureCursorVisible() {
if (m_cursorLineNo < m_firstLine
- || m_cursorLineNo >= m_firstLine + pageSize()) {
+ || m_cursorLineNo >= m_firstLine + pageSize()) {
reposition(m_cursorLineNo, m_cursorCol);
}
+ if (m_cursorCol < 0)
+ m_firstCol = 0;
+ else if ( m_cursorCol < m_firstCol) {
+ m_firstCol = m_cursorCol;
+ } else if (m_cursorCol >= m_firstCol + m_screenWidth){
+ int length = m_lines->lineAt(m_cursorLineNo).length();
+ m_firstCol = max(0, min(m_cursorCol, length - m_screenWidth));
+ }
}
/**
m_cursorCol = m_lines->lineAt(m_cursorLineNo - 1).length() - 1;
}
if (m_lines->removePart(m_cursorLineNo, columnToIndex(currentCol),
- 1, true))
+ 1, true))
m_cursorLineNo = max(0, m_cursorLineNo - 1);
break;
}
break;
}
} else if (shift && !keyText.isEmpty() && key != Qt::Key_Delete
- && key != Qt::Key_Backspace) {
+ && key != Qt::Key_Backspace) {
m_lines->insertText(m_cursorLineNo, m_cursorCol + 1, keyText);
m_cursorCol++;
} else {
* @return
*/
ReLook* ReEdit::lookOf(ReLook::ForeGround foreground,
- ReLook::BackGround background) {
+ ReLook::BackGround background) {
int index = foreground * ReLook::BG_COUNT + background;
ReLook* rc = m_looks[index];
if (rc == NULL) {
*/
void ReEdit::mouseMoveEvent(QMouseEvent* event) {
if (m_lastMousePosition.x() >= 0
- && (handleHScrollBar(event, true, this)
- || handleVScrollBar(event, true, this))) {
+ && (handleHScrollBar(event, true, this)
+ || handleVScrollBar(event, true, this))) {
emit repaint();
}
}
} else {
QPoint position = event->pos();
m_cursorLineNo = position.y()
- / heightToFullHeight(m_standardMetrics->height()) + m_firstLine;
+ / heightToFullHeight(m_standardMetrics->height()) + m_firstLine;
int x = position.x();
int charWidth = m_standardMetrics->width('x');
- if (x >= m_widthLineNo && x < m_widthEdit - m_widthVScrollBar) {
- if (x <= m_widthLineNo + charWidth / 2)
- m_cursorCol = -1;
+ x -= m_widthLineNumbers;
+ if (x >= 0 && x < m_widthEdit - m_widthLineNumbers - m_widthVScrollBar) {
+ if (x <= + charWidth / 2)
+ m_cursorCol = m_firstCol - 1;
else
- m_cursorCol = columnToIndex((x - m_widthLineNo) / charWidth);
+ m_cursorCol = m_firstCol + columnToIndex(x / charWidth);
}
}
m_lastMousePosition = event->pos();
* @param event the description of the mouse click
*/
void ReEdit::mouseReleaseEvent(QMouseEvent* event) {
+ // avoid warning:
+ ReUseParameter(event);
m_lastMousePosition.setX(-1);
m_lastMousePosition.setY(-1);
}
int lineHeight = heightToFullHeight(m_standardMetrics->height());
int pageSize = (rect.height() - m_heightHScrollBar) / lineHeight;
int charWidth = m_standardMetrics->averageCharWidth();
- int pageWidth = (rect.width() - m_widthVScrollBar - m_widthLineNo)
- / charWidth;
+ int pageWidth = (rect.width() - m_widthVScrollBar - m_widthLineNumbers)
+ / charWidth;
int firstLine = m_firstLine;
load(firstLine, pageSize, pageWidth, this);
QPainter painter(this);
ReLook* look = lookOf(ReLook::FG_STANDARD, ReLook::BG_STANDARD);
painter.setBrush(*look->m_brush);
- QRect editArea(rect.left() + m_widthLineNo, rect.top(),
- rect.right() - m_widthVScrollBar, rect.bottom() - m_heightHScrollBar);
+ QRect editArea(rect.left() + m_widthLineNumbers, rect.top(),
+ rect.right() - m_widthVScrollBar, rect.bottom() - m_heightHScrollBar);
painter.drawRect(editArea);
- draw(painter, rect.top(), rect.left() + m_widthLineNo);
- int left = rect.left() + m_widthLineNo - 3;
+ draw(painter, rect.top(), rect.left() + m_widthLineNumbers);
+ int left = rect.left() + m_widthLineNumbers - 3;
left = rect.left();
int y = 0;
int lineNo = firstLine + 1;
for (int ix = 0; ix < m_list.length(); ix++, lineNo++) {
QString number = QString::number(lineNo) + ":";
ReLook* look =
- lineNo == m_cursorLineNo + 1 ?
- lookOf(ReLook::FG_CURRENT_LINE, ReLook::BG_CURRENT_LINE) :
- lookStd;
+ lineNo == m_cursorLineNo + 1 ?
+ lookOf(ReLook::FG_CURRENT_LINE, ReLook::BG_CURRENT_LINE) :
+ lookStd;
int width = look->m_metrics->width(number);
if (ix == 0)
y = rect.top() + look->m_metrics->height()
- - look->m_metrics->descent();
+ - look->m_metrics->descent();
painter.setFont(*look->m_font);
painter.setPen(*look->m_pen);
- painter.drawText(left + m_widthLineNo - width - 5, y, number);
+ painter.drawText(left + m_widthLineNumbers - width - 5, y, number);
y += lineHeight;
}
// We paint the cursor:
if (m_cursorVisible && m_cursorLineNo >= firstLine
- && m_cursorLineNo < firstLine + pageSize) {
+ && m_cursorLineNo < firstLine + pageSize) {
ReParagraph* cursorPara = cursorParagraph();
- int col = max(m_cursorCol, cursorPara->m_columns - 1);
- col = indexToColumn(col, m_tabWidth, m_lines->lineAt(m_cursorLineNo))
- - m_firstCol;
- int x = rect.left() + m_widthLineNo + 1
- + (col + 1) * lookStd->m_metrics->width('x');
+ int col = min(m_cursorCol, cursorPara->m_columns - 1);
+ if (col != -1)
+ col = indexToColumn(col, m_tabWidth, m_lines->lineAt(m_cursorLineNo))
+ - m_firstCol;
+ int x = rect.left() + m_widthLineNumbers + 1
+ + (col + 1) * lookStd->m_metrics->width('x');
int y = rect.top() + (m_cursorLineNo - firstLine) * lineHeight;
painter.setPen(*look->m_pen);
painter.drawLine(x, y, x, y + lineHeight);
}
int maxLines = max(1, m_lines->lineCount() - pageSize);
drawScrollbars(painter, rect, double(pageSize) / maxLines,
- double(m_firstLine) / maxLines,
- m_maxCols == 0 ? 1.0 : (double) m_screenWidth / m_maxCols,
- m_maxCols == 0 ? 0.0 : (double) m_firstCol / m_maxCols);
+ double(m_firstLine) / maxLines,
+ m_maxCols == 0 ? 1.0 : (double) m_screenWidth / m_maxCols,
+ m_maxCols == 0 ? 0.0 : (double) m_firstCol / m_maxCols);
ReLogger::globalLogger()->logv(LOG_INFO, 3, "draw: %.4f",
- double(clock() - start) / CLOCKS_PER_SEC);
+ double(clock() - start) / CLOCKS_PER_SEC);
}
/**
* Constructor.
*/
ReParagraphs::ReParagraphs() :
- m_builders(),
- m_firstLine(0),
- m_firstCol(0),
- m_cursorLineNo(0),
- m_cursorCol(-1),
- m_lines(NULL),
- m_list(),
- m_cursorVisible(true),
- m_maxCols(0),
- m_screenWidth(0) {
+ m_builders(),
+ m_firstLine(0),
+ m_firstCol(0),
+ m_cursorLineNo(0),
+ m_cursorCol(-1),
+ m_lines(NULL),
+ m_list(),
+ m_maxCols(0),
+ m_screenWidth(0),
+ m_cursorVisible(true) {
}
/**
* expanded tabs
*/
int ReParagraphs::columnToIndex(int column, int tabWidth,
- const QString& string) {
+ const QString& string) {
int rc = 0;
if (column < 0)
rc = -1;
ReParagraph* ReParagraphs::cursorParagraph() {
ReParagraph* rc = NULL;
if (m_cursorLineNo >= m_firstLine
- && m_cursorLineNo < m_firstLine + m_list.length()) {
+ && m_cursorLineNo < m_firstLine + m_list.length()) {
rc = m_list.at(m_cursorLineNo - m_firstLine);
}
return rc;
*/
int ReParagraphs::columnToIndex(int cursorCol) {
int rc = columnToIndex(cursorCol, m_tabWidth,
- m_lines->lineAt(m_cursorLineNo));
+ m_lines->lineAt(m_cursorLineNo));
return rc;
}
* @return
*/
int ReParagraphs::indexToColumn(int index, int tabWidth,
- const QString& string) {
+ const QString& string) {
int rc = 0;
if (index >= 0) {
int length = string.length();
* @param edit the parent, the edit field
*/
void ReParagraphBuilder::buildParagraph(ReParagraph& paragraph, int lineNo,
- ReEdit* edit) {
+ ReEdit* edit) {
if (paragraph.length() == 0) {
int firstCol = edit->m_firstCol;
const QString& text = edit->lines().lineAt(lineNo);
ReLook* look = edit->lookOf(ReLook::FG_STANDARD, ReLook::BG_STANDARD);
ReLook* lookTab = edit->lookOf(ReLook::FG_GREY_LIGHT,
- ReLook::BG_STANDARD);
+ ReLook::BG_STANDARD);
paragraph.m_columns = 0;
int ixTab;
ReEditText* part;
* Constructor.
*/
ReMouseCatcher::ReMouseCatcher() :
- m_clickObjects(),
- m_vScrollBar(new ClickPosition(CO_VSCROLLBAR)),
- m_hScrollBar(new ClickPosition(CO_HSCROLLBAR)),
- m_hSlider(new ClickPosition(CO_HSLIDER)),
- m_vSlider(new ClickPosition(CO_VSLIDER)),
- m_lastMousePosition(),
- m_lastTopVSlider(0),
- m_lastLeftHSlider(0) {
+ m_clickObjects(),
+ m_vScrollBar(new ClickPosition(CO_VSCROLLBAR)),
+ m_hScrollBar(new ClickPosition(CO_HSCROLLBAR)),
+ m_hSlider(new ClickPosition(CO_HSLIDER)),
+ m_vSlider(new ClickPosition(CO_VSLIDER)),
+ m_lastMousePosition(),
+ m_lastTopVSlider(0),
+ m_lastLeftHSlider(0) {
}
/**
* @return <code>true</code>: the mouse click is inside the horizontal sb
*/
bool ReMouseCatcher::handleHScrollBar(QMouseEvent* event, bool isDragged,
- ReEdit* edit) {
+ ReEdit* edit) {
QPoint pos = event->pos();
bool rc = rectContains(*m_hScrollBar, pos, "hScrollBar");
if (rc) {
int moveGap = m_hScrollBar->width() - m_hSlider->width();
double position = moveGap == 0 ? 0.0 : double(sliderPos) / moveGap;
int col = roundInt(
- (edit->m_maxCols - edit->m_screenWidth)
- * max(0.0, min(position, 1.0)));
+ (edit->m_maxCols - edit->m_screenWidth)
+ * max(0.0, min(position, 1.0)));
edit->reposition(edit->m_cursorLineNo, col);
} else {
if (pos.y() < m_hSlider->left())
* @return <code>true</code>: the mouse click is inside the vertical sb
*/
bool ReMouseCatcher::handleVScrollBar(QMouseEvent* event, bool isDragged,
- ReEdit* edit) {
+ ReEdit* edit) {
QPoint pos = event->pos();
bool rc = rectContains(*m_vScrollBar, pos, "vScrollBar")
- || (isDragged && m_vScrollBar->contains(m_lastMousePosition));
+ || (isDragged && m_vScrollBar->contains(m_lastMousePosition));
if (rc) {
if (isDragged) {
int distance = pos.y() - m_lastMousePosition.y();
int moveGap = m_vScrollBar->height() - m_vSlider->height();
double position = moveGap == 0 ? 0.0 : double(sliderPos) / moveGap;
int line = roundInt(
- (edit->lines().lineCount() - edit->pageSize())
- * max(0.0, min(position, 1.0)));
+ (edit->lines().lineCount() - edit->pageSize())
+ * max(0.0, min(position, 1.0)));
edit->reposition(line, edit->m_cursorCol);
} else {
if (pos.y() < m_vSlider->top())