Mercurial > octave-nkf
comparison libqterminal/unix/TerminalView.cpp @ 15678:a1bcffac7fa8
fixed cursor position
Signed-off-by: Jacob Dawid <jacob.dawid@gmail.com>
author | Jen Stewart <jen.stewart.london@gmail.com> |
---|---|
date | Sat, 28 Jul 2012 08:43:35 -0400 |
parents | aa6cba8ae88b |
children |
comparison
equal
deleted
inserted
replaced
15677:f620ecde2566 | 15678:a1bcffac7fa8 |
---|---|
132 xterm fonts have these at 0x00..0x1f. | 132 xterm fonts have these at 0x00..0x1f. |
133 | 133 |
134 QT's iso mapping leaves 0x00..0x7f without any changes. But the graphicals | 134 QT's iso mapping leaves 0x00..0x7f without any changes. But the graphicals |
135 come in here as proper unicode characters. | 135 come in here as proper unicode characters. |
136 | 136 |
137 We treat non-iso10646 fonts as VT100 extended and do the requiered mapping | 137 We treat non-iso10646 fonts as VT100 extended and do the required mapping |
138 from unicode to 0x00..0x1f. The remaining translation is then left to the | 138 from unicode to 0x00..0x1f. The remaining translation is then left to the |
139 QCodec. | 139 QCodec. |
140 */ | 140 */ |
141 | 141 |
142 static inline bool isLineChar(quint16 c) { return ((c & 0xFF80) == 0x2500);} | 142 static inline bool isLineChar(quint16 c) { return ((c & 0xFF80) == 0x2500);} |
164 | 164 |
165 // waba TerminalDisplay 1.123: | 165 // waba TerminalDisplay 1.123: |
166 // "Base character width on widest ASCII character. This prevents too wide | 166 // "Base character width on widest ASCII character. This prevents too wide |
167 // characters in the presence of double wide (e.g. Japanese) characters." | 167 // characters in the presence of double wide (e.g. Japanese) characters." |
168 // Get the width from representative normal width characters | 168 // Get the width from representative normal width characters |
169 _fontWidth = qRound((double)fm.width(REPCHAR)/(double)strlen(REPCHAR)); | 169 _fontWidth = (double)fm.width(REPCHAR)/(double)strlen(REPCHAR); |
170 | 170 |
171 _fixedFont = true; | 171 _fixedFont = true; |
172 | 172 |
173 int fw = fm.width(REPCHAR[0]); | 173 int fw = fm.width(REPCHAR[0]); |
174 for(unsigned int i=1; i< strlen(REPCHAR); i++) | 174 for(unsigned int i=1; i< strlen(REPCHAR); i++) |
180 } | 180 } |
181 } | 181 } |
182 | 182 |
183 | 183 |
184 if (_fontWidth < 1) | 184 if (_fontWidth < 1) |
185 _fontWidth=1; | 185 _fontWidth = 1; |
186 | 186 |
187 _fontAscent = fm.ascent(); | 187 _fontAscent = fm.ascent(); |
188 | 188 |
189 emit changedFontMetricSignal( _fontHeight, _fontWidth ); | 189 emit changedFontMetricSignal( _fontHeight, _fontWidth ); |
190 //parentWidget()->setFixedWidth(_fontWidth * 80 + _leftMargin); | 190 //parentWidget()->setFixedWidth(_fontWidth * 80 + _leftMargin); |
1189 // are strange hopping effects during a resize when the view does no match | 1189 // are strange hopping effects during a resize when the view does no match |
1190 // exactly the widget width. | 1190 // exactly the widget width. |
1191 // int topLeftX = (_contentWidth - _usedColumns * _fontWidth) / 2; | 1191 // int topLeftX = (_contentWidth - _usedColumns * _fontWidth) / 2; |
1192 int topLeftX = 0; | 1192 int topLeftX = 0; |
1193 | 1193 |
1194 int leftUpperX = qMin(_usedColumns-1, qMax(0,(rect.left() - topLeftX - _leftMargin ) / _fontWidth)); | 1194 int leftUpperX = qMin(_usedColumns-1, qMax(0, qRound((rect.left() - topLeftX - _leftMargin ) / _fontWidth))); |
1195 int leftUpperY = qMin(_usedLines-1, qMax(0, (rect.top() - topLeftY - _topMargin ) / _fontHeight)); | 1195 int leftUpperY = qMin(_usedLines-1, qMax(0, qRound((rect.top() - topLeftY - _topMargin ) / _fontHeight))); |
1196 int rightLowerX = qMin(_usedColumns-1, qMax(0, (rect.right() - topLeftX - _leftMargin ) / _fontWidth)); | 1196 int rightLowerX = qMin(_usedColumns-1, qMax(0, qRound((rect.right() - topLeftX - _leftMargin ) / _fontWidth))); |
1197 int rightLowerY = qMin(_usedLines-1, qMax(0, (rect.bottom() - topLeftY - _topMargin ) / _fontHeight)); | 1197 int rightLowerY = qMin(_usedLines-1, qMax(0, qRound((rect.bottom() - topLeftY - _topMargin ) / _fontHeight))); |
1198 | 1198 |
1199 const int bufferSize = _usedColumns; | 1199 const int bufferSize = _usedColumns; |
1200 QChar *disstrU = new QChar[bufferSize]; | 1200 QChar *disstrU = new QChar[bufferSize]; |
1201 for (int y = leftUpperY; y <= rightLowerY; y++) | 1201 for (int y = leftUpperY; y <= rightLowerY; y++) |
1202 { | 1202 { |
2471 _contentHeight = contentsRect().height() - 2 * DEFAULT_TOP_MARGIN + /* mysterious */ 1; | 2471 _contentHeight = contentsRect().height() - 2 * DEFAULT_TOP_MARGIN + /* mysterious */ 1; |
2472 | 2472 |
2473 if (!_isFixedSize) | 2473 if (!_isFixedSize) |
2474 { | 2474 { |
2475 // ensure that display is always at least one column wide | 2475 // ensure that display is always at least one column wide |
2476 _columns = qMax(1,_contentWidth / _fontWidth); | 2476 _columns = qMax(1,qRound(_contentWidth / _fontWidth)); |
2477 _usedColumns = qMin(_usedColumns,_columns); | 2477 _usedColumns = qMin(_usedColumns,_columns); |
2478 | 2478 |
2479 // ensure that display is always at least one line high | 2479 // ensure that display is always at least one line high |
2480 _lines = qMax(1,_contentHeight / _fontHeight); | 2480 _lines = qMax(1, qRound(_contentHeight / _fontHeight)); |
2481 _usedLines = qMin(_usedLines,_lines); | 2481 _usedLines = qMin(_usedLines,_lines); |
2482 } | 2482 } |
2483 } | 2483 } |
2484 | 2484 |
2485 void TerminalView::makeImage() | 2485 void TerminalView::makeImage() |