for (it = files.cbegin(); it != files.cend(); ++it) {
QFileInfo file(*it);
if (file.exists()) {
- QString info = file.baseName();
+ QString info = file.fileName();
if (withDate)
info.append("\t").append(
file.lastModified().toString("yyyy.mm.dd/HH:MM:SS"));
class TestReEdit: public ReTest, protected ReEdit {
public:
TestReEdit() :
- ReTest("ReEdit"),
- ReEdit(NULL) {
+ ReTest("ReEdit"),
+ ReEdit(NULL) {
doIt();
}
setLines(&m_lines);
}
void pushKey(int key, const QString& text = "",
- Qt::KeyboardModifiers modifiers = Qt::NoModifier) {
+ Qt::KeyboardModifiers modifiers = Qt::NoModifier) {
QKeyEvent event(QEvent::KeyPress, key, modifiers, text);
keyPressEvent(&event);
}
checkEqu(expectedCol, m_cursorCol);
}
void checkCursorPos(EditorAction action, int expectedLineNo,
- int expectedCol) {
+ int expectedCol) {
editorAction(action);
checkEqu(expectedLineNo, m_cursorLineNo);
checkEqu(expectedCol, m_cursorCol);
log("ok");
}
+ void testIndexToColumn(){
+ /*
+ * <pre>tabulator width: 4
+ * _01230123
+ * _ x index: 0 blanks: 3
+ * _x x index: 1 blanks: 2
+ * _xx x index: 2 blanks: 1
+ * _xxx x index: 3 blanks: 0
+ * </pre>
+ */
+ int tabWidth = 4;
+ checkEqu(0, ReParagraphs::indexToColumn(0, tabWidth, "\tx"));
+ checkEqu(4, ReParagraphs::indexToColumn(1, tabWidth, "\tx"));
+ checkEqu(5, ReParagraphs::indexToColumn(2, tabWidth, "\tx"));
+ checkEqu(5, ReParagraphs::indexToColumn(3, tabWidth, "\tx"));
+
+ checkEqu(1, ReParagraphs::indexToColumn(1, tabWidth, "1\tx"));
+ checkEqu(4, ReParagraphs::indexToColumn(2, tabWidth, "1\tx"));
+ checkEqu(5, ReParagraphs::indexToColumn(3, tabWidth, "1\tx"));
+
+ checkEqu(1, ReParagraphs::indexToColumn(1, tabWidth, "12\tx"));
+ checkEqu(2, ReParagraphs::indexToColumn(2, tabWidth, "12\tx"));
+ checkEqu(4, ReParagraphs::indexToColumn(3, tabWidth, "12\tx"));
+ checkEqu(5, ReParagraphs::indexToColumn(5, tabWidth, "12\tx"));
+
+ checkEqu(1, ReParagraphs::indexToColumn(1, tabWidth, "123\tx"));
+ checkEqu(2, ReParagraphs::indexToColumn(2, tabWidth, "123\tx"));
+ checkEqu(3, ReParagraphs::indexToColumn(3, tabWidth, "123\tx"));
+ checkEqu(4, ReParagraphs::indexToColumn(4, tabWidth, "123\tx"));
+ }
+
virtual void run() {
+ testIndexToColumn();
testDeleteLine();
testDeleteText();
testEnterText();
QStringList ReParagraphs::m_tabStrings;
// RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
QChar ReParagraphs::m_tabChar = QChar(0xBB);
-int ReParagraphs::m_tabWidth = 3;
+int ReParagraphs::m_tabWidth = 4;
/**
* Calculates the full line height (with gap between lines)
assignColorsStandard();
- setTabStrings(3);
+ setTabStrings(4);
appendBuilder(new ReParagraphBuilder());
appendBuilder(new ReCursortLineBuilder());
assignKeysStandard();
ReLook* lookStd = lookOf(ReLook::FG_STANDARD, ReLook::BG_STANDARD);
int maxIx = min(m_list.length(), m_lines->lineCount() - m_firstLine);
for (int ix = 0; ix < maxIx; ix++, lineNo++) {
- QString number = QString::number(lineNo) + ":";
+ QString number = QString::number(lineNo);
ReLook* look =
lineNo == m_cursorLineNo + 1 ?
lookOf(ReLook::FG_CURRENT_LINE, ReLook::BG_CURRENT_LINE) :
&& m_cursorLineNo < firstLine + pageSize) {
ReParagraph* cursorPara = cursorParagraph();
int col = min(m_cursorCol, cursorPara->m_columns - 1);
- if (col != -1)
- col = indexToColumn(col, m_tabWidth,
- m_lines->lineAt(m_cursorLineNo)) - m_firstCol;
+ col = indexToColumn(col + 1, m_tabWidth,
+ m_lines->lineAt(m_cursorLineNo)) - m_firstCol;
int x = rect.left() + m_widthLineNumbers + 1
- + (col + 1) * lookStd->m_metrics->width('x');
+ + col * 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);
m_tabStrings.clear();
QString blanks;
blanks.fill(' ', tabWidth);
- for (int ix = 0; ix <= tabWidth - 1; ix++) {
+ for (int ix = 0; ix < tabWidth; ix++) {
m_tabStrings.append(m_tabChar + blanks.mid(0, tabWidth - 1 - ix));
}
}
int rc = 0;
if (column < 0)
rc = -1;
+ else if (column == 0)
+ rc = 0;
else {
int cursor = 0;
int length = string.length();
int ReParagraphs::indexToColumn(int index, int tabWidth,
const QString& string) {
int rc = 0;
- if (index >= 0) {
+ if (index > 0) {
int length = string.length();
for (int cursor = 0; cursor < index && cursor < length; cursor++) {
- if (string.at(cursor) != m_tabChar)
+ if (string.at(cursor) != '\t')
rc++;
else {
// if the cursor points to the last char (tab): do not expand!
- if (cursor < index - 1)
- rc += tabWidth - 1 - (cursor % tabWidth);
+ if (cursor < index)
+ rc += tabWidth - (cursor % tabWidth);
}
}
}
}
cursor += length;
}
- QString tabs = ReEdit::tabString(cursor + 1);
+ QString tabs = ReEdit::tabString(cursor);
length = tabs.length();
if (cursor + length > firstCol && cursor < maxCol) {
if (cursor < firstCol)
void drawScrollbars(QPainter& painter, const QRect& rect,
double sizeVertical, double posVertical, double sizeHorizontal,
double posHorizontal);
- void ensureCursorVisible();
-protected slots:
+ void ensureCursorVisible();protected slots:
void keyPressEvent(QKeyEvent* event);
void paintEvent(QPaintEvent *);
void mouseMoveEvent(QMouseEvent* event);
--- /dev/null
+Tabwidth 4
+ x
+1 x
+12 x
+123 x
+1234 x
+ y
+1 y
+12 y
+123 y
+1234 x