summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/tinykate/libkate/view/kateview.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/noncore/apps/tinykate/libkate/view/kateview.cpp b/noncore/apps/tinykate/libkate/view/kateview.cpp
index 423634b..c5673a5 100644
--- a/noncore/apps/tinykate/libkate/view/kateview.cpp
+++ b/noncore/apps/tinykate/libkate/view/kateview.cpp
@@ -1128,1595 +1128,1598 @@ void KateViewInternal::paintEvent(QPaintEvent *e) {
1128 int h; 1128 int h;
1129 int line, y, yEnd; 1129 int line, y, yEnd;
1130 1130
1131 QRect updateR = e->rect(); 1131 QRect updateR = e->rect();
1132 1132
1133 if (!drawBuffer) return; 1133 if (!drawBuffer) return;
1134 if (drawBuffer->isNull()) return; 1134 if (drawBuffer->isNull()) return;
1135 1135
1136 QPainter paint; 1136 QPainter paint;
1137 paint.begin(drawBuffer); 1137 paint.begin(drawBuffer);
1138 1138
1139 xStart = xPos-2 + updateR.x(); 1139 xStart = xPos-2 + updateR.x();
1140 xEnd = xStart + updateR.width(); 1140 xEnd = xStart + updateR.width();
1141 1141
1142 h = myDoc->fontHeight; 1142 h = myDoc->fontHeight;
1143 line = (yPos + updateR.y()) / h; 1143 line = (yPos + updateR.y()) / h;
1144 y = line*h - yPos; 1144 y = line*h - yPos;
1145 yEnd = updateR.y() + updateR.height(); 1145 yEnd = updateR.y() + updateR.height();
1146 waitForPreHighlight=myDoc->needPreHighlight(waitForPreHighlight=line+((long)(yEnd-y)/h)+5); 1146 waitForPreHighlight=myDoc->needPreHighlight(waitForPreHighlight=line+((long)(yEnd-y)/h)+5);
1147 1147
1148 while (y < yEnd) 1148 while (y < yEnd)
1149 { 1149 {
1150 TextLine *textLine; 1150 TextLine *textLine;
1151 int ctxNum = 0; 1151 int ctxNum = 0;
1152 myDoc->paintTextLine(paint, line, xStart, xEnd, myView->configFlags & KateView::cfShowTabs); 1152 myDoc->paintTextLine(paint, line, xStart, xEnd, myView->configFlags & KateView::cfShowTabs);
1153 bitBlt(this, updateR.x(), y, drawBuffer, 0, 0, updateR.width(), h); 1153 bitBlt(this, updateR.x(), y, drawBuffer, 0, 0, updateR.width(), h);
1154 leftBorder->paintLine(line); 1154 leftBorder->paintLine(line);
1155 line++; 1155 line++;
1156 y += h; 1156 y += h;
1157 } 1157 }
1158 paint.end(); 1158 paint.end();
1159 1159
1160 if (cursorOn) paintCursor(); 1160 if (cursorOn) paintCursor();
1161 if (bm.eXPos > bm.sXPos) paintBracketMark(); 1161 if (bm.eXPos > bm.sXPos) paintBracketMark();
1162} 1162}
1163 1163
1164void KateViewInternal::resizeEvent(QResizeEvent *) 1164void KateViewInternal::resizeEvent(QResizeEvent *)
1165{ 1165{
1166 drawBuffer->resize (width(), myDoc->fontHeight); 1166 drawBuffer->resize (width(), myDoc->fontHeight);
1167 leftBorder->resize(iconBorderWidth, height()); 1167 leftBorder->resize(iconBorderWidth, height());
1168} 1168}
1169 1169
1170void KateViewInternal::timerEvent(QTimerEvent *e) { 1170void KateViewInternal::timerEvent(QTimerEvent *e) {
1171 if (e->timerId() == cursorTimer) { 1171 if (e->timerId() == cursorTimer) {
1172 cursorOn = !cursorOn; 1172 cursorOn = !cursorOn;
1173 paintCursor(); 1173 paintCursor();
1174 } 1174 }
1175 if (e->timerId() == scrollTimer && (scrollX | scrollY)) { 1175 if (e->timerId() == scrollTimer && (scrollX | scrollY)) {
1176 xScroll->setValue(xPos + scrollX); 1176 xScroll->setValue(xPos + scrollX);
1177 yScroll->setValue(yPos + scrollY); 1177 yScroll->setValue(yPos + scrollY);
1178 1178
1179 placeCursor(mouseX, mouseY, KateView::cfMark); 1179 placeCursor(mouseX, mouseY, KateView::cfMark);
1180 myDoc->updateViews(/*ufNoScroll*/); 1180 myDoc->updateViews(/*ufNoScroll*/);
1181 } 1181 }
1182} 1182}
1183 1183
1184uint KateView::uniqueID = 0; 1184uint KateView::uniqueID = 0;
1185 1185
1186KateView::KateView(KateDocument *doc, QWidget *parent, const char * name) : Kate::View (doc, parent, name) 1186KateView::KateView(KateDocument *doc, QWidget *parent, const char * name) : Kate::View (doc, parent, name)
1187{ 1187{
1188 1188
1189 myViewID = uniqueID; 1189 myViewID = uniqueID;
1190 uniqueID++; 1190 uniqueID++;
1191 1191
1192 active = false; 1192 active = false;
1193 myIconBorder = false; 1193 myIconBorder = false;
1194 1194
1195 myDoc = doc; 1195 myDoc = doc;
1196 myViewInternal = new KateViewInternal (this,doc); 1196 myViewInternal = new KateViewInternal (this,doc);
1197 myViewInternal->move(2, 2); 1197 myViewInternal->move(2, 2);
1198 myViewInternal->leftBorder = new KateIconBorder(this, myViewInternal); 1198 myViewInternal->leftBorder = new KateIconBorder(this, myViewInternal);
1199 myViewInternal->leftBorder->setGeometry(2, 2, myViewInternal->iconBorderWidth, myViewInternal->iconBorderHeight); 1199 myViewInternal->leftBorder->setGeometry(2, 2, myViewInternal->iconBorderWidth, myViewInternal->iconBorderHeight);
1200 myViewInternal->leftBorder->hide(); 1200 myViewInternal->leftBorder->hide();
1201 1201
1202 doc->addView( this ); 1202 doc->addView( this );
1203 1203
1204 1204
1205 // some defaults 1205 // some defaults
1206 configFlags = KateView::cfAutoIndent | KateView::cfBackspaceIndents 1206 configFlags = KateView::cfAutoIndent | KateView::cfBackspaceIndents
1207 | KateView::cfTabIndents | KateView::cfKeepIndentProfile 1207 | KateView::cfTabIndents | KateView::cfKeepIndentProfile
1208 | KateView::cfRemoveSpaces 1208 | KateView::cfRemoveSpaces
1209 | KateView::cfDelOnInput | KateView::cfMouseAutoCopy | KateView::cfWrapCursor 1209 | KateView::cfDelOnInput | KateView::cfMouseAutoCopy | KateView::cfWrapCursor
1210 | KateView::cfGroupUndo | KateView::cfShowTabs | KateView::cfSmartHome; 1210 | KateView::cfGroupUndo | KateView::cfShowTabs | KateView::cfSmartHome;
1211 1211
1212 searchFlags = 0; 1212 searchFlags = 0;
1213 replacePrompt = 0L; 1213 replacePrompt = 0L;
1214 rmbMenu = 0L; 1214 rmbMenu = 0L;
1215 1215
1216 1216
1217 setFocusProxy( myViewInternal ); 1217 setFocusProxy( myViewInternal );
1218 myViewInternal->setFocus(); 1218 myViewInternal->setFocus();
1219 resize(parent->width() -4, parent->height() -4); 1219 resize(parent->width() -4, parent->height() -4);
1220 1220
1221 1221
1222 myViewInternal->installEventFilter( this ); 1222 myViewInternal->installEventFilter( this );
1223 1223
1224 //setupActions(); 1224 //setupActions();
1225 1225
1226 connect( this, SIGNAL( newStatus() ), this, SLOT( slotUpdate() ) ); 1226 connect( this, SIGNAL( newStatus() ), this, SLOT( slotUpdate() ) );
1227 connect( this, SIGNAL( newUndo() ), this, SLOT( slotNewUndo() ) ); 1227 connect( this, SIGNAL( newUndo() ), this, SLOT( slotNewUndo() ) );
1228 connect( doc, SIGNAL( fileNameChanged() ), this, SLOT( slotFileStatusChanged() ) ); 1228 connect( doc, SIGNAL( fileNameChanged() ), this, SLOT( slotFileStatusChanged() ) );
1229 connect( doc, SIGNAL( highlightChanged() ), this, SLOT( slotHighlightChanged() ) ); 1229 connect( doc, SIGNAL( highlightChanged() ), this, SLOT( slotHighlightChanged() ) );
1230 1230
1231 readConfig(); 1231 readConfig();
1232// setHighlight->setCurrentItem(getHl()); 1232// setHighlight->setCurrentItem(getHl());
1233 slotUpdate(); 1233 slotUpdate();
1234} 1234}
1235 1235
1236KateView::~KateView() 1236KateView::~KateView()
1237{ 1237{
1238 writeConfig(); 1238 writeConfig();
1239 1239
1240 if (myDoc && !myDoc->m_bSingleViewMode) 1240 if (myDoc && !myDoc->m_bSingleViewMode)
1241 myDoc->removeView( this ); 1241 myDoc->removeView( this );
1242 1242
1243 delete myViewInternal; 1243 delete myViewInternal;
1244} 1244}
1245 1245
1246#if 0 1246#if 0
1247void KateView::setupActions() 1247void KateView::setupActions()
1248{ 1248{
1249#if 0 1249#if 0
1250 KStdAction::close( this, SLOT(flush()), actionCollection(), "file_close" ); 1250 KStdAction::close( this, SLOT(flush()), actionCollection(), "file_close" );
1251 1251
1252 KStdAction::save(this, SLOT(save()), actionCollection()); 1252 KStdAction::save(this, SLOT(save()), actionCollection());
1253 1253
1254 // setup edit menu 1254 // setup edit menu
1255 editUndo = KStdAction::undo(this, SLOT(undo()), actionCollection()); 1255 editUndo = KStdAction::undo(this, SLOT(undo()), actionCollection());
1256 editRedo = KStdAction::redo(this, SLOT(redo()), actionCollection()); 1256 editRedo = KStdAction::redo(this, SLOT(redo()), actionCollection());
1257 editUndoHist = new KAction(i18n("Undo/Redo &History..."), 0, this, SLOT(undoHistory()), 1257 editUndoHist = new KAction(i18n("Undo/Redo &History..."), 0, this, SLOT(undoHistory()),
1258 actionCollection(), "edit_undoHistory"); 1258 actionCollection(), "edit_undoHistory");
1259 KStdAction::cut(this, SLOT(cut()), actionCollection()); 1259 KStdAction::cut(this, SLOT(cut()), actionCollection());
1260 KStdAction::copy(this, SLOT(copy()), actionCollection()); 1260 KStdAction::copy(this, SLOT(copy()), actionCollection());
1261 KStdAction::paste(this, SLOT(paste()), actionCollection()); 1261 KStdAction::paste(this, SLOT(paste()), actionCollection());
1262 1262
1263 if ( myDoc->hasBrowserExtension() ) 1263 if ( myDoc->hasBrowserExtension() )
1264 { 1264 {
1265 KStdAction::saveAs(this, SLOT(saveAs()), myDoc->actionCollection()); 1265 KStdAction::saveAs(this, SLOT(saveAs()), myDoc->actionCollection());
1266 KStdAction::find(this, SLOT(find()), myDoc->actionCollection(), "find"); 1266 KStdAction::find(this, SLOT(find()), myDoc->actionCollection(), "find");
1267 KStdAction::findNext(this, SLOT(findAgain()), myDoc->actionCollection(), "find_again"); 1267 KStdAction::findNext(this, SLOT(findAgain()), myDoc->actionCollection(), "find_again");
1268 KStdAction::findPrev(this, SLOT(findPrev()), myDoc->actionCollection(), "find_prev"); 1268 KStdAction::findPrev(this, SLOT(findPrev()), myDoc->actionCollection(), "find_prev");
1269 KStdAction::gotoLine(this, SLOT(gotoLine()), myDoc->actionCollection(), "goto_line" ); 1269 KStdAction::gotoLine(this, SLOT(gotoLine()), myDoc->actionCollection(), "goto_line" );
1270 new KAction(i18n("&Configure Editor..."), 0, this, SLOT(configDialog()),myDoc->actionCollection(), "set_confdlg"); 1270 new KAction(i18n("&Configure Editor..."), 0, this, SLOT(configDialog()),myDoc->actionCollection(), "set_confdlg");
1271 setHighlight = new KSelectAction(i18n("&Highlight Mode"), 0, myDoc->actionCollection(), "set_highlight"); 1271 setHighlight = new KSelectAction(i18n("&Highlight Mode"), 0, myDoc->actionCollection(), "set_highlight");
1272 KStdAction::selectAll(this, SLOT(selectAll()), myDoc->actionCollection(), "select_all"); 1272 KStdAction::selectAll(this, SLOT(selectAll()), myDoc->actionCollection(), "select_all");
1273 new KAction(i18n("&Deselect All"), 0, this, SLOT(deselectAll()), 1273 new KAction(i18n("&Deselect All"), 0, this, SLOT(deselectAll()),
1274 myDoc->actionCollection(), "unselect_all"); 1274 myDoc->actionCollection(), "unselect_all");
1275 new KAction(i18n("Invert &Selection"), 0, this, SLOT(invertSelection()), 1275 new KAction(i18n("Invert &Selection"), 0, this, SLOT(invertSelection()),
1276 myDoc->actionCollection(), "invert_select"); 1276 myDoc->actionCollection(), "invert_select");
1277 1277
1278 new KAction(i18n("Increase Font Sizes"), "viewmag+", 0, this, SLOT(slotIncFontSizes()), 1278 new KAction(i18n("Increase Font Sizes"), "viewmag+", 0, this, SLOT(slotIncFontSizes()),
1279 myDoc->actionCollection(), "incFontSizes"); 1279 myDoc->actionCollection(), "incFontSizes");
1280 new KAction(i18n("Decrease Font Sizes"), "viewmag-", 0, this, SLOT(slotDecFontSizes()), 1280 new KAction(i18n("Decrease Font Sizes"), "viewmag-", 0, this, SLOT(slotDecFontSizes()),
1281 myDoc->actionCollection(), "decFontSizes"); 1281 myDoc->actionCollection(), "decFontSizes");
1282 } 1282 }
1283 else 1283 else
1284 { 1284 {
1285 KStdAction::saveAs(this, SLOT(saveAs()), actionCollection()); 1285 KStdAction::saveAs(this, SLOT(saveAs()), actionCollection());
1286 KStdAction::find(this, SLOT(find()), actionCollection()); 1286 KStdAction::find(this, SLOT(find()), actionCollection());
1287 KStdAction::findNext(this, SLOT(findAgain()), actionCollection()); 1287 KStdAction::findNext(this, SLOT(findAgain()), actionCollection());
1288 KStdAction::findPrev(this, SLOT(findPrev()), actionCollection(), "edit_find_prev"); 1288 KStdAction::findPrev(this, SLOT(findPrev()), actionCollection(), "edit_find_prev");
1289 KStdAction::gotoLine(this, SLOT(gotoLine()), actionCollection()); 1289 KStdAction::gotoLine(this, SLOT(gotoLine()), actionCollection());
1290 new KAction(i18n("&Configure Editor..."), 0, this, SLOT(configDialog()),actionCollection(), "set_confdlg"); 1290 new KAction(i18n("&Configure Editor..."), 0, this, SLOT(configDialog()),actionCollection(), "set_confdlg");
1291 setHighlight = new KSelectAction(i18n("&Highlight Mode"), 0, actionCollection(), "set_highlight"); 1291 setHighlight = new KSelectAction(i18n("&Highlight Mode"), 0, actionCollection(), "set_highlight");
1292 KStdAction::selectAll(this, SLOT(selectAll()), actionCollection()); 1292 KStdAction::selectAll(this, SLOT(selectAll()), actionCollection());
1293 new KAction(i18n("&Deselect All"), 0, this, SLOT(deselectAll()), 1293 new KAction(i18n("&Deselect All"), 0, this, SLOT(deselectAll()),
1294 actionCollection(), "edit_deselectAll"); 1294 actionCollection(), "edit_deselectAll");
1295 new KAction(i18n("Invert &Selection"), 0, this, SLOT(invertSelection()), 1295 new KAction(i18n("Invert &Selection"), 0, this, SLOT(invertSelection()),
1296 actionCollection(), "edit_invertSelection"); 1296 actionCollection(), "edit_invertSelection");
1297 1297
1298 new KAction(i18n("Increase Font Sizes"), "viewmag+", 0, this, SLOT(slotIncFontSizes()), 1298 new KAction(i18n("Increase Font Sizes"), "viewmag+", 0, this, SLOT(slotIncFontSizes()),
1299 actionCollection(), "incFontSizes"); 1299 actionCollection(), "incFontSizes");
1300 new KAction(i18n("Decrease Font Sizes"), "viewmag-", 0, this, SLOT(slotDecFontSizes()), 1300 new KAction(i18n("Decrease Font Sizes"), "viewmag-", 0, this, SLOT(slotDecFontSizes()),
1301 actionCollection(), "decFontSizes"); 1301 actionCollection(), "decFontSizes");
1302 } 1302 }
1303 1303
1304 new KAction(i18n("Apply Word Wrap"), 0, myDoc, SLOT(applyWordWrap()), actionCollection(), "edit_apply_wordwrap"); 1304 new KAction(i18n("Apply Word Wrap"), 0, myDoc, SLOT(applyWordWrap()), actionCollection(), "edit_apply_wordwrap");
1305 1305
1306 KStdAction::replace(this, SLOT(replace()), actionCollection()); 1306 KStdAction::replace(this, SLOT(replace()), actionCollection());
1307 1307
1308 new KAction(i18n("Editing Co&mmand"), Qt::CTRL+Qt::Key_M, this, SLOT(slotEditCommand()), 1308 new KAction(i18n("Editing Co&mmand"), Qt::CTRL+Qt::Key_M, this, SLOT(slotEditCommand()),
1309 actionCollection(), "edit_cmd"); 1309 actionCollection(), "edit_cmd");
1310 1310
1311 // setup bookmark menu 1311 // setup bookmark menu
1312 bookmarkToggle = new KAction(i18n("Toggle &Bookmark"), Qt::CTRL+Qt::Key_B, this, SLOT(toggleBookmark()), actionCollection(), "edit_bookmarkToggle"); 1312 bookmarkToggle = new KAction(i18n("Toggle &Bookmark"), Qt::CTRL+Qt::Key_B, this, SLOT(toggleBookmark()), actionCollection(), "edit_bookmarkToggle");
1313 bookmarkClear = new KAction(i18n("Clear Bookmarks"), 0, this, SLOT(clearBookmarks()), actionCollection(), "edit_bookmarksClear"); 1313 bookmarkClear = new KAction(i18n("Clear Bookmarks"), 0, this, SLOT(clearBookmarks()), actionCollection(), "edit_bookmarksClear");
1314 1314
1315 // connect settings menu aboutToshow 1315 // connect settings menu aboutToshow
1316 bookmarkMenu = new KActionMenu(i18n("&Bookmarks"), actionCollection(), "bookmarks"); 1316 bookmarkMenu = new KActionMenu(i18n("&Bookmarks"), actionCollection(), "bookmarks");
1317 connect(bookmarkMenu->popupMenu(), SIGNAL(aboutToShow()), this, SLOT(bookmarkMenuAboutToShow())); 1317 connect(bookmarkMenu->popupMenu(), SIGNAL(aboutToShow()), this, SLOT(bookmarkMenuAboutToShow()));
1318 1318
1319 new KToggleAction(i18n("Show &IconBorder"), Key_F6, this, SLOT(toggleIconBorder()), actionCollection(), "view_border"); 1319 new KToggleAction(i18n("Show &IconBorder"), Key_F6, this, SLOT(toggleIconBorder()), actionCollection(), "view_border");
1320 1320
1321 // setup Tools menu 1321 // setup Tools menu
1322 KStdAction::spelling(this, SLOT(spellcheck()), actionCollection()); 1322 KStdAction::spelling(this, SLOT(spellcheck()), actionCollection());
1323 new KAction(i18n("&Indent"), "indent", Qt::CTRL+Qt::Key_I, this, SLOT(indent()), 1323 new KAction(i18n("&Indent"), "indent", Qt::CTRL+Qt::Key_I, this, SLOT(indent()),
1324 actionCollection(), "tools_indent"); 1324 actionCollection(), "tools_indent");
1325 new KAction(i18n("&Unindent"), "unindent", Qt::CTRL+Qt::Key_U, this, SLOT(unIndent()), 1325 new KAction(i18n("&Unindent"), "unindent", Qt::CTRL+Qt::Key_U, this, SLOT(unIndent()),
1326 actionCollection(), "tools_unindent"); 1326 actionCollection(), "tools_unindent");
1327 new KAction(i18n("&Clean Indentation"), 0, this, SLOT(cleanIndent()), 1327 new KAction(i18n("&Clean Indentation"), 0, this, SLOT(cleanIndent()),
1328 actionCollection(), "tools_cleanIndent"); 1328 actionCollection(), "tools_cleanIndent");
1329 new KAction(i18n("C&omment"), CTRL+Qt::Key_NumberSign, this, SLOT(comment()), 1329 new KAction(i18n("C&omment"), CTRL+Qt::Key_NumberSign, this, SLOT(comment()),
1330 actionCollection(), "tools_comment"); 1330 actionCollection(), "tools_comment");
1331 new KAction(i18n("Unco&mment"), CTRL+SHIFT+Qt::Key_NumberSign, this, SLOT(uncomment()), 1331 new KAction(i18n("Unco&mment"), CTRL+SHIFT+Qt::Key_NumberSign, this, SLOT(uncomment()),
1332 actionCollection(), "tools_uncomment"); 1332 actionCollection(), "tools_uncomment");
1333 1333
1334 setVerticalSelection = new KToggleAction(i18n("&Vertical Selection"), Key_F4, this, SLOT(toggleVertical()), 1334 setVerticalSelection = new KToggleAction(i18n("&Vertical Selection"), Key_F4, this, SLOT(toggleVertical()),
1335 actionCollection(), "set_verticalSelect"); 1335 actionCollection(), "set_verticalSelect");
1336 1336
1337 connect(setHighlight, SIGNAL(activated(int)), this, SLOT(setHl(int))); 1337 connect(setHighlight, SIGNAL(activated(int)), this, SLOT(setHl(int)));
1338 QStringList list; 1338 QStringList list;
1339 for (int z = 0; z < HlManager::self()->highlights(); z++) 1339 for (int z = 0; z < HlManager::self()->highlights(); z++)
1340 list.append(HlManager::self()->hlName(z)); 1340 list.append(HlManager::self()->hlName(z));
1341 setHighlight->setItems(list); 1341 setHighlight->setItems(list);
1342 1342
1343 setEndOfLine = new KSelectAction(i18n("&End Of Line"), 0, actionCollection(), "set_eol"); 1343 setEndOfLine = new KSelectAction(i18n("&End Of Line"), 0, actionCollection(), "set_eol");
1344 connect(setEndOfLine, SIGNAL(activated(int)), this, SLOT(setEol(int))); 1344 connect(setEndOfLine, SIGNAL(activated(int)), this, SLOT(setEol(int)));
1345 list.clear(); 1345 list.clear();
1346 list.append("&Unix"); 1346 list.append("&Unix");
1347 list.append("&Windows/Dos"); 1347 list.append("&Windows/Dos");
1348 list.append("&Macintosh"); 1348 list.append("&Macintosh");
1349 setEndOfLine->setItems(list); 1349 setEndOfLine->setItems(list);
1350#endif 1350#endif
1351} 1351}
1352#endif 1352#endif
1353 1353
1354void KateView::slotUpdate() 1354void KateView::slotUpdate()
1355{ 1355{
1356 int cfg = config(); 1356 int cfg = config();
1357 1357
1358#warning fixme setVerticalSelection->setChecked(cfg & KateView::cfVerticalSelect); 1358#warning fixme setVerticalSelection->setChecked(cfg & KateView::cfVerticalSelect);
1359 1359
1360 slotNewUndo(); 1360 slotNewUndo();
1361} 1361}
1362void KateView::slotFileStatusChanged() 1362void KateView::slotFileStatusChanged()
1363{ 1363{
1364 int eol = getEol(); 1364 int eol = getEol();
1365 eol = eol>=1 ? eol : 0; 1365 eol = eol>=1 ? eol : 0;
1366 1366
1367#warning fixme setEndOfLine->setCurrentItem(eol); 1367#warning fixme setEndOfLine->setCurrentItem(eol);
1368} 1368}
1369void KateView::slotNewUndo() 1369void KateView::slotNewUndo()
1370{ 1370{
1371#if 0 1371#if 0
1372 int state = undoState(); 1372 int state = undoState();
1373 1373
1374 editUndoHist->setEnabled(state & 1 || state & 2); 1374 editUndoHist->setEnabled(state & 1 || state & 2);
1375 1375
1376 QString t = i18n("Und&o"); // it would be nicer to fetch the original string 1376 QString t = i18n("Und&o"); // it would be nicer to fetch the original string
1377 if (state & 1) { 1377 if (state & 1) {
1378 editUndo->setEnabled(true); 1378 editUndo->setEnabled(true);
1379 t += ' '; 1379 t += ' ';
1380 t += i18n(undoTypeName(nextUndoType())); 1380 t += i18n(undoTypeName(nextUndoType()));
1381 } else { 1381 } else {
1382 editUndo->setEnabled(false); 1382 editUndo->setEnabled(false);
1383 } 1383 }
1384 editUndo->setText(t); 1384 editUndo->setText(t);
1385 1385
1386 t = i18n("Re&do"); // it would be nicer to fetch the original string 1386 t = i18n("Re&do"); // it would be nicer to fetch the original string
1387 if (state & 2) { 1387 if (state & 2) {
1388 editRedo->setEnabled(true); 1388 editRedo->setEnabled(true);
1389 t += ' '; 1389 t += ' ';
1390 t += i18n(undoTypeName(nextRedoType())); 1390 t += i18n(undoTypeName(nextRedoType()));
1391 } else { 1391 } else {
1392 editRedo->setEnabled(false); 1392 editRedo->setEnabled(false);
1393 } 1393 }
1394 editRedo->setText(t); 1394 editRedo->setText(t);
1395#endif 1395#endif
1396} 1396}
1397 1397
1398void KateView::slotHighlightChanged() 1398void KateView::slotHighlightChanged()
1399{ 1399{
1400// setHighlight->setCurrentItem(getHl()); 1400// setHighlight->setCurrentItem(getHl());
1401} 1401}
1402 1402
1403 1403
1404void KateView::keyPressEvent( QKeyEvent *ev ) 1404void KateView::keyPressEvent( QKeyEvent *ev )
1405{ 1405{
1406 switch ( ev->key() ) 1406 switch ( ev->key() )
1407 { 1407 {
1408 case Key_Left: 1408 case Key_Left:
1409 if ( ev->state() & ShiftButton ) 1409 if ( ev->state() & ShiftButton )
1410 { 1410 {
1411 if ( ev->state() & ControlButton ) 1411 if ( ev->state() & ControlButton )
1412 shiftWordLeft(); 1412 shiftWordLeft();
1413 else 1413 else
1414 shiftCursorLeft(); 1414 shiftCursorLeft();
1415 } 1415 }
1416 else if ( ev->state() & ControlButton ) 1416 else if ( ev->state() & ControlButton )
1417 wordLeft(); 1417 wordLeft();
1418 else 1418 else
1419 cursorLeft(); 1419 cursorLeft();
1420 break; 1420 break;
1421 case Key_Right: 1421 case Key_Right:
1422 if ( ev->state() & ShiftButton ) 1422 if ( ev->state() & ShiftButton )
1423 { 1423 {
1424 if ( ev->state() & ControlButton ) 1424 if ( ev->state() & ControlButton )
1425 shiftWordRight(); 1425 shiftWordRight();
1426 else 1426 else
1427 shiftCursorRight(); 1427 shiftCursorRight();
1428 } 1428 }
1429 else if ( ev->state() & ControlButton ) 1429 else if ( ev->state() & ControlButton )
1430 wordRight(); 1430 wordRight();
1431 else 1431 else
1432 cursorRight(); 1432 cursorRight();
1433 break; 1433 break;
1434 case Key_Home: 1434 case Key_Home:
1435 if ( ev->state() & ShiftButton ) 1435 if ( ev->state() & ShiftButton )
1436 { 1436 {
1437 if ( ev->state() & ControlButton ) 1437 if ( ev->state() & ControlButton )
1438 shiftTop(); 1438 shiftTop();
1439 else 1439 else
1440 shiftHome(); 1440 shiftHome();
1441 } 1441 }
1442 else if ( ev->state() & ControlButton ) 1442 else if ( ev->state() & ControlButton )
1443 top(); 1443 top();
1444 else 1444 else
1445 home(); 1445 home();
1446 break; 1446 break;
1447 case Key_End: 1447 case Key_End:
1448 if ( ev->state() & ShiftButton ) 1448 if ( ev->state() & ShiftButton )
1449 { 1449 {
1450 if ( ev->state() & ControlButton ) 1450 if ( ev->state() & ControlButton )
1451 shiftBottom(); 1451 shiftBottom();
1452 else 1452 else
1453 shiftEnd(); 1453 shiftEnd();
1454 } 1454 }
1455 else if ( ev->state() & ControlButton ) 1455 else if ( ev->state() & ControlButton )
1456 bottom(); 1456 bottom();
1457 else 1457 else
1458 end(); 1458 end();
1459 break; 1459 break;
1460 case Key_Up: 1460 case Key_Up:
1461 if ( ev->state() & ShiftButton ) 1461 if ( ev->state() & ShiftButton )
1462 shiftUp(); 1462 shiftUp();
1463 else if ( ev->state() & ControlButton ) 1463 else if ( ev->state() & ControlButton )
1464 scrollUp(); 1464 scrollUp();
1465 else 1465 else
1466 up(); 1466 up();
1467 break; 1467 break;
1468 case Key_Down: 1468 case Key_Down:
1469 if ( ev->state() & ShiftButton ) 1469 if ( ev->state() & ShiftButton )
1470 shiftDown(); 1470 shiftDown();
1471 else if ( ev->state() & ControlButton ) 1471 else if ( ev->state() & ControlButton )
1472 scrollDown(); 1472 scrollDown();
1473 else 1473 else
1474 down(); 1474 down();
1475 break; 1475 break;
1476 case Key_PageUp: 1476 case Key_PageUp:
1477 if ( ev->state() & ShiftButton ) 1477 if ( ev->state() & ShiftButton )
1478 shiftPageUp(); 1478 shiftPageUp();
1479 else if ( ev->state() & ControlButton ) 1479 else if ( ev->state() & ControlButton )
1480 topOfView(); 1480 topOfView();
1481 else 1481 else
1482 pageUp(); 1482 pageUp();
1483 break; 1483 break;
1484 case Key_PageDown: 1484 case Key_PageDown:
1485 if ( ev->state() & ShiftButton ) 1485 if ( ev->state() & ShiftButton )
1486 shiftPageDown(); 1486 shiftPageDown();
1487 else if ( ev->state() & ControlButton ) 1487 else if ( ev->state() & ControlButton )
1488 bottomOfView(); 1488 bottomOfView();
1489 else 1489 else
1490 pageDown(); 1490 pageDown();
1491 break; 1491 break;
1492 case Key_Return: 1492 case Key_Return:
1493 case Key_Enter: 1493 case Key_Enter:
1494 keyReturn(); 1494 keyReturn();
1495 break; 1495 break;
1496 case Key_Delete: 1496 case Key_Delete:
1497 if ( ev->state() & ControlButton ) 1497 if ( ev->state() & ControlButton )
1498 { 1498 {
1499 VConfig c; 1499 VConfig c;
1500 shiftWordRight(); 1500 shiftWordRight();
1501 myViewInternal->getVConfig(c); 1501 myViewInternal->getVConfig(c);
1502 myDoc->delMarkedText(c); 1502 myDoc->delMarkedText(c);
1503 myViewInternal->update(); 1503 myViewInternal->update();
1504 } 1504 }
1505 else keyDelete(); 1505 else keyDelete();
1506 break; 1506 break;
1507 case Key_Backspace: 1507 case Key_Backspace:
1508 if ( ev->state() & ControlButton ) 1508 if ( ev->state() & ControlButton )
1509 { 1509 {
1510 VConfig c; 1510 VConfig c;
1511 shiftWordLeft(); 1511 shiftWordLeft();
1512 myViewInternal->getVConfig(c); 1512 myViewInternal->getVConfig(c);
1513 myDoc->delMarkedText(c); 1513 myDoc->delMarkedText(c);
1514 myViewInternal->update(); 1514 myViewInternal->update();
1515 } 1515 }
1516 else backspace(); 1516 else backspace();
1517 break; 1517 break;
1518 case Key_Insert: 1518 case Key_Insert:
1519 toggleInsert(); 1519 toggleInsert();
1520 break; 1520 break;
1521 case Key_K: 1521 case Key_K:
1522 if ( ev->state() & ControlButton ) 1522 if ( ev->state() & ControlButton )
1523 { 1523 {
1524 killLine(); 1524 killLine();
1525 break; 1525 break;
1526 } 1526 }
1527 default: 1527 default:
1528 KTextEditor::View::keyPressEvent( ev ); 1528 KTextEditor::View::keyPressEvent( ev );
1529 return; 1529 return;
1530 break; 1530 break;
1531 } 1531 }
1532 ev->accept(); 1532 ev->accept();
1533} 1533}
1534 1534
1535 1535
1536void KateView::setCursorPosition( int line, int col, bool /*mark*/ ) 1536void KateView::setCursorPosition( int line, int col, bool /*mark*/ )
1537{ 1537{
1538 setCursorPositionInternal( line, col ); 1538 setCursorPositionInternal( line, col );
1539} 1539}
1540 1540
1541void KateView::getCursorPosition( int *line, int *col ) 1541void KateView::getCursorPosition( int *line, int *col )
1542{ 1542{
1543 if ( line ) 1543 if ( line )
1544 *line = currentLine(); 1544 *line = currentLine();
1545 1545
1546 if ( col ) 1546 if ( col )
1547 *col = currentColumn(); 1547 *col = currentColumn();
1548} 1548}
1549 1549
1550 1550
1551int KateView::currentLine() { 1551int KateView::currentLine() {
1552 return myViewInternal->cursor.y; 1552 return myViewInternal->cursor.y;
1553} 1553}
1554 1554
1555int KateView::currentColumn() { 1555int KateView::currentColumn() {
1556 return myDoc->currentColumn(myViewInternal->cursor); 1556 return myDoc->currentColumn(myViewInternal->cursor);
1557} 1557}
1558 1558
1559int KateView::currentCharNum() { 1559int KateView::currentCharNum() {
1560 return myViewInternal->cursor.x; 1560 return myViewInternal->cursor.x;
1561} 1561}
1562 1562
1563void KateView::setCursorPositionInternal(int line, int col) { 1563void KateView::setCursorPositionInternal(int line, int col) {
1564 PointStruc cursor; 1564 PointStruc cursor;
1565 1565
1566 cursor.x = col; 1566 cursor.x = col;
1567 cursor.y = line; 1567 cursor.y = line;
1568 myViewInternal->updateCursor(cursor); 1568 myViewInternal->updateCursor(cursor);
1569 myViewInternal->center(); 1569 myViewInternal->center();
1570// myViewInternal->updateView(ufPos, 0, line*myDoc->fontHeight - height()/2); 1570// myViewInternal->updateView(ufPos, 0, line*myDoc->fontHeight - height()/2);
1571// myDoc->updateViews(myViewInternal); //uptade all other views except this one 1571// myDoc->updateViews(myViewInternal); //uptade all other views except this one
1572 myDoc->updateViews(); 1572 myDoc->updateViews();
1573} 1573}
1574 1574
1575int KateView::config() { 1575int KateView::config() {
1576 int flags; 1576 int flags;
1577 1577
1578 flags = configFlags; 1578 flags = configFlags;
1579 if (myDoc->singleSelection()) flags |= KateView::cfSingleSelection; 1579 if (myDoc->singleSelection()) flags |= KateView::cfSingleSelection;
1580 return flags; 1580 return flags;
1581} 1581}
1582 1582
1583void KateView::setConfig(int flags) { 1583void KateView::setConfig(int flags) {
1584 bool updateView; 1584 bool updateView;
1585 1585
1586 // cfSingleSelection is a doc-property 1586 // cfSingleSelection is a doc-property
1587 myDoc->setSingleSelection(flags & KateView::cfSingleSelection); 1587 myDoc->setSingleSelection(flags & KateView::cfSingleSelection);
1588 flags &= ~KateView::cfSingleSelection; 1588 flags &= ~KateView::cfSingleSelection;
1589 1589
1590 if (flags != configFlags) { 1590 if (flags != configFlags) {
1591 // update the view if visibility of tabs has changed 1591 // update the view if visibility of tabs has changed
1592 updateView = (flags ^ configFlags) & KateView::cfShowTabs; 1592 updateView = (flags ^ configFlags) & KateView::cfShowTabs;
1593 configFlags = flags; 1593 configFlags = flags;
1594 emit newStatus(); 1594 emit newStatus();
1595 if (updateView) myViewInternal->update(); 1595 if (updateView) myViewInternal->update();
1596 } 1596 }
1597} 1597}
1598 1598
1599int KateView::tabWidth() { 1599int KateView::tabWidth() {
1600 return myDoc->tabChars; 1600 return myDoc->tabChars;
1601} 1601}
1602 1602
1603void KateView::setTabWidth(int w) { 1603void KateView::setTabWidth(int w) {
1604 myDoc->setTabWidth(w); 1604 myDoc->setTabWidth(w);
1605 myDoc->updateViews(); 1605 myDoc->updateViews();
1606} 1606}
1607 1607
1608void KateView::setEncoding (QString e) { 1608void KateView::setEncoding (QString e) {
1609 myDoc->setEncoding (e); 1609 myDoc->setEncoding (e);
1610 myDoc->updateViews(); 1610 myDoc->updateViews();
1611} 1611}
1612 1612
1613int KateView::undoSteps() { 1613int KateView::undoSteps() {
1614 return myDoc->undoSteps; 1614 return myDoc->undoSteps;
1615} 1615}
1616 1616
1617void KateView::setUndoSteps(int s) { 1617void KateView::setUndoSteps(int s) {
1618 myDoc->setUndoSteps(s); 1618 myDoc->setUndoSteps(s);
1619} 1619}
1620 1620
1621bool KateView::isReadOnly() { 1621bool KateView::isReadOnly() {
1622 return myDoc->readOnly; 1622 return myDoc->readOnly;
1623} 1623}
1624 1624
1625bool KateView::isModified() { 1625bool KateView::isModified() {
1626 return myDoc->modified; 1626 return myDoc->modified;
1627} 1627}
1628 1628
1629void KateView::setReadOnly(bool m) { 1629void KateView::setReadOnly(bool m) {
1630 myDoc->setReadOnly(m); 1630 myDoc->setReadOnly(m);
1631} 1631}
1632 1632
1633void KateView::setModified(bool m) { 1633void KateView::setModified(bool m) {
1634 myDoc->setModified(m); 1634 myDoc->setModified(m);
1635} 1635}
1636 1636
1637bool KateView::isLastView() { 1637bool KateView::isLastView() {
1638 return myDoc->isLastView(1); 1638 return myDoc->isLastView(1);
1639} 1639}
1640 1640
1641KateDocument *KateView::doc() { 1641KateDocument *KateView::doc() {
1642 return myDoc; 1642 return myDoc;
1643} 1643}
1644 1644
1645int KateView::undoState() { 1645int KateView::undoState() {
1646 if (isReadOnly()) 1646 if (isReadOnly())
1647 return 0; 1647 return 0;
1648 else 1648 else
1649 return myDoc->undoState; 1649 return myDoc->undoState;
1650} 1650}
1651 1651
1652int KateView::nextUndoType() { 1652int KateView::nextUndoType() {
1653 return myDoc->nextUndoType(); 1653 return myDoc->nextUndoType();
1654} 1654}
1655 1655
1656int KateView::nextRedoType() { 1656int KateView::nextRedoType() {
1657 return myDoc->nextRedoType(); 1657 return myDoc->nextRedoType();
1658} 1658}
1659 1659
1660void KateView::undoTypeList(QValueList<int> &lst) 1660void KateView::undoTypeList(QValueList<int> &lst)
1661{ 1661{
1662 myDoc->undoTypeList(lst); 1662 myDoc->undoTypeList(lst);
1663} 1663}
1664 1664
1665void KateView::redoTypeList(QValueList<int> &lst) 1665void KateView::redoTypeList(QValueList<int> &lst)
1666{ 1666{
1667 myDoc->redoTypeList(lst); 1667 myDoc->redoTypeList(lst);
1668} 1668}
1669 1669
1670const char * KateView::undoTypeName(int type) { 1670const char * KateView::undoTypeName(int type) {
1671 return KateActionGroup::typeName(type); 1671 return KateActionGroup::typeName(type);
1672} 1672}
1673 1673
1674QColor* KateView::getColors() 1674QColor* KateView::getColors()
1675{ 1675{
1676 return myDoc->colors; 1676 return myDoc->colors;
1677} 1677}
1678 1678
1679void KateView::applyColors() 1679void KateView::applyColors()
1680{ 1680{
1681 myDoc->tagAll(); 1681 myDoc->tagAll();
1682 myDoc->updateViews(); 1682 myDoc->updateViews();
1683} 1683}
1684 1684
1685bool KateView::isOverwriteMode() const 1685bool KateView::isOverwriteMode() const
1686{ 1686{
1687 return ( configFlags & KateView::cfOvr ); 1687 return ( configFlags & KateView::cfOvr );
1688} 1688}
1689 1689
1690void KateView::setOverwriteMode( bool b ) 1690void KateView::setOverwriteMode( bool b )
1691{ 1691{
1692 if ( isOverwriteMode() && !b ) 1692 if ( isOverwriteMode() && !b )
1693 setConfig( configFlags ^ KateView::cfOvr ); 1693 setConfig( configFlags ^ KateView::cfOvr );
1694 else 1694 else
1695 setConfig( configFlags | KateView::cfOvr ); 1695 setConfig( configFlags | KateView::cfOvr );
1696} 1696}
1697 1697
1698void KateView::toggleInsert() { 1698void KateView::toggleInsert() {
1699 setConfig(configFlags ^ KateView::cfOvr); 1699 setConfig(configFlags ^ KateView::cfOvr);
1700} 1700}
1701 1701
1702void KateView::toggleVertical() 1702void KateView::toggleVertical()
1703{ 1703{
1704 setConfig(configFlags ^ KateView::cfVerticalSelect); 1704 setConfig(configFlags ^ KateView::cfVerticalSelect);
1705} 1705}
1706 1706
1707 1707
1708int KateView::numLines() { 1708int KateView::numLines() {
1709 return myDoc->numLines(); 1709 return myDoc->numLines();
1710} 1710}
1711 1711
1712QString KateView::text() { 1712QString KateView::text() {
1713 return myDoc->text(); 1713 return myDoc->text();
1714} 1714}
1715 1715
1716QString KateView::currentTextLine() { 1716QString KateView::currentTextLine() {
1717 TextLine::Ptr textLine = myDoc->getTextLine(myViewInternal->cursor.y); 1717 TextLine::Ptr textLine = myDoc->getTextLine(myViewInternal->cursor.y);
1718 return QString(textLine->getText(), textLine->length()); 1718 return QString(textLine->getText(), textLine->length());
1719} 1719}
1720 1720
1721QString KateView::textLine(int num) { 1721QString KateView::textLine(int num) {
1722 TextLine::Ptr textLine = myDoc->getTextLine(num); 1722 TextLine::Ptr textLine = myDoc->getTextLine(num);
1723 return QString(textLine->getText(), textLine->length()); 1723 return QString(textLine->getText(), textLine->length());
1724} 1724}
1725 1725
1726QString KateView::currentWord() { 1726QString KateView::currentWord() {
1727 return myDoc->getWord(myViewInternal->cursor); 1727 return myDoc->getWord(myViewInternal->cursor);
1728} 1728}
1729 1729
1730QString KateView::word(int x, int y) { 1730QString KateView::word(int x, int y) {
1731 PointStruc cursor; 1731 PointStruc cursor;
1732 cursor.y = (myViewInternal->yPos + y)/myDoc->fontHeight; 1732 cursor.y = (myViewInternal->yPos + y)/myDoc->fontHeight;
1733 if (cursor.y < 0 || cursor.y > myDoc->lastLine()) return QString(); 1733 if (cursor.y < 0 || cursor.y > myDoc->lastLine()) return QString();
1734 cursor.x = myDoc->textPos(myDoc->getTextLine(cursor.y), myViewInternal->xPos-2 + x); 1734 cursor.x = myDoc->textPos(myDoc->getTextLine(cursor.y), myViewInternal->xPos-2 + x);
1735 return myDoc->getWord(cursor); 1735 return myDoc->getWord(cursor);
1736} 1736}
1737 1737
1738void KateView::setText(const QString &s) { 1738void KateView::setText(const QString &s) {
1739 myDoc->setText(s); 1739 myDoc->setText(s);
1740 myDoc->updateViews(); 1740 myDoc->updateViews();
1741} 1741}
1742 1742
1743void KateView::insertText(const QString &s, bool /*mark*/) { 1743void KateView::insertText(const QString &s, bool /*mark*/) {
1744 VConfig c; 1744 VConfig c;
1745 myViewInternal->getVConfig(c); 1745 myViewInternal->getVConfig(c);
1746 myDoc->insert(c, s); 1746 myDoc->insert(c, s);
1747 myDoc->updateViews(); 1747 myDoc->updateViews();
1748} 1748}
1749 1749
1750bool KateView::hasMarkedText() { 1750bool KateView::hasMarkedText() {
1751 return myDoc->hasMarkedText(); 1751 return myDoc->hasMarkedText();
1752} 1752}
1753 1753
1754QString KateView::markedText() { 1754QString KateView::markedText() {
1755 return myDoc->markedText(configFlags); 1755 return myDoc->markedText(configFlags);
1756} 1756}
1757 1757
1758bool KateView::canDiscard() { 1758bool KateView::canDiscard() {
1759 int query; 1759 int query;
1760 1760
1761 if (isModified()) { 1761 if (isModified()) {
1762 query = KMessageBox::warningYesNoCancel(this, 1762 query = KMessageBox::warningYesNoCancel(this,
1763 i18n("The current Document has been modified.\nWould you like to save it?")); 1763 i18n("The current Document has been modified.\nWould you like to save it?"));
1764 switch (query) { 1764 switch (query) {
1765 case KMessageBox::Yes: //yes 1765 case KMessageBox::Yes: //yes
1766 if (save() == CANCEL) return false; 1766 if (save() == CANCEL) return false;
1767 if (isModified()) { 1767 if (isModified()) {
1768 query = KMessageBox::warningContinueCancel(this, 1768 query = KMessageBox::warningContinueCancel(this,
1769 i18n("Could not save the document.\nDiscard it and continue?"), 1769 i18n("Could not save the document.\nDiscard it and continue?"),
1770 QString::null, i18n("&Discard")); 1770 QString::null, i18n("&Discard"));
1771 if (query == KMessageBox::Cancel) return false; 1771 if (query == KMessageBox::Cancel) return false;
1772 } 1772 }
1773 break; 1773 break;
1774 case KMessageBox::Cancel: //cancel 1774 case KMessageBox::Cancel: //cancel
1775 return false; 1775 return false;
1776 } 1776 }
1777 } 1777 }
1778 return true; 1778 return true;
1779} 1779}
1780 1780
1781void KateView::flush() 1781void KateView::flush()
1782{ 1782{
1783 if (canDiscard()) myDoc->flush(); 1783 if (canDiscard()) myDoc->flush();
1784} 1784}
1785 1785
1786KateView::fileResult KateView::save() { 1786KateView::fileResult KateView::save() {
1787 int query = KMessageBox::Yes; 1787 int query = KMessageBox::Yes;
1788 if (isModified()) { 1788 if (isModified()) {
1789 return saveAs(); 1789 return saveAs();
1790 } 1790 }
1791 return OK; 1791 return OK;
1792} 1792}
1793 1793
1794KateView::fileResult KateView::saveAs() { 1794KateView::fileResult KateView::saveAs() {
1795 return OK; 1795 return OK;
1796} 1796}
1797 1797
1798void KateView::doCursorCommand(int cmdNum) { 1798void KateView::doCursorCommand(int cmdNum) {
1799 VConfig c; 1799 VConfig c;
1800 myViewInternal->getVConfig(c); 1800 myViewInternal->getVConfig(c);
1801 if (cmdNum & selectFlag) c.flags |= KateView::cfMark; 1801 if (cmdNum & selectFlag) c.flags |= KateView::cfMark;
1802 if (cmdNum & multiSelectFlag) c.flags |= KateView::cfMark | KateView::cfKeepSelection; 1802 if (cmdNum & multiSelectFlag) c.flags |= KateView::cfMark | KateView::cfKeepSelection;
1803 cmdNum &= ~(selectFlag | multiSelectFlag); 1803 cmdNum &= ~(selectFlag | multiSelectFlag);
1804 myViewInternal->doCursorCommand(c, cmdNum); 1804 myViewInternal->doCursorCommand(c, cmdNum);
1805 myDoc->updateViews(); 1805 myDoc->updateViews();
1806} 1806}
1807 1807
1808void KateView::doEditCommand(int cmdNum) { 1808void KateView::doEditCommand(int cmdNum) {
1809 VConfig c; 1809 VConfig c;
1810 myViewInternal->getVConfig(c); 1810 myViewInternal->getVConfig(c);
1811 myViewInternal->doEditCommand(c, cmdNum); 1811 myViewInternal->doEditCommand(c, cmdNum);
1812 myDoc->updateViews(); 1812 myDoc->updateViews();
1813} 1813}
1814 1814
1815void KateView::undoMultiple(int count) { 1815void KateView::undoMultiple(int count) {
1816 if (isReadOnly()) 1816 if (isReadOnly())
1817 return; 1817 return;
1818 1818
1819 VConfig c; 1819 VConfig c;
1820 myViewInternal->getVConfig(c); 1820 myViewInternal->getVConfig(c);
1821 myDoc->undo(c, count); 1821 myDoc->undo(c, count);
1822 myDoc->updateViews(); 1822 myDoc->updateViews();
1823} 1823}
1824 1824
1825void KateView::redoMultiple(int count) { 1825void KateView::redoMultiple(int count) {
1826 if (isReadOnly()) 1826 if (isReadOnly())
1827 return; 1827 return;
1828 1828
1829 VConfig c; 1829 VConfig c;
1830 myViewInternal->getVConfig(c); 1830 myViewInternal->getVConfig(c);
1831 myDoc->redo(c, count); 1831 myDoc->redo(c, count);
1832 myDoc->updateViews(); 1832 myDoc->updateViews();
1833} 1833}
1834 1834
1835void KateView::undoHistory() 1835void KateView::undoHistory()
1836{ 1836{
1837 UndoHistory *undoH; 1837 UndoHistory *undoH;
1838 1838
1839 undoH = new UndoHistory(this, this, "UndoHistory", true); 1839 undoH = new UndoHistory(this, this, "UndoHistory", true);
1840 1840
1841 undoH->setCaption(i18n("Undo/Redo History")); 1841 undoH->setCaption(i18n("Undo/Redo History"));
1842 1842
1843 connect(this,SIGNAL(newUndo()),undoH,SLOT(newUndo())); 1843 connect(this,SIGNAL(newUndo()),undoH,SLOT(newUndo()));
1844 connect(undoH,SIGNAL(undo(int)),this,SLOT(undoMultiple(int))); 1844 connect(undoH,SIGNAL(undo(int)),this,SLOT(undoMultiple(int)));
1845 connect(undoH,SIGNAL(redo(int)),this,SLOT(redoMultiple(int))); 1845 connect(undoH,SIGNAL(redo(int)),this,SLOT(redoMultiple(int)));
1846 1846
1847 undoH->exec(); 1847 undoH->exec();
1848 1848
1849 delete undoH; 1849 delete undoH;
1850} 1850}
1851 1851
1852static void kwview_addToStrList(QStringList &list, const QString &str) { 1852static void kwview_addToStrList(QStringList &list, const QString &str) {
1853 if (list.count() > 0) { 1853 if (list.count() > 0) {
1854 if (list.first() == str) return; 1854 if (list.first() == str) return;
1855 QStringList::Iterator it; 1855 QStringList::Iterator it;
1856 it = list.find(str); 1856 it = list.find(str);
1857 if (*it != 0L) list.remove(it); 1857 if (*it != 0L) list.remove(it);
1858 if (list.count() >= 16) list.remove(list.fromLast()); 1858 if (list.count() >= 16) list.remove(list.fromLast());
1859 } 1859 }
1860 list.prepend(str); 1860 list.prepend(str);
1861} 1861}
1862 1862
1863void KateView::find() { 1863void KateView::find() {
1864 SearchDialog *searchDialog; 1864 SearchDialog *searchDialog;
1865 1865
1866 if (!myDoc->hasMarkedText()) searchFlags &= ~KateView::sfSelected; 1866 if (!myDoc->hasMarkedText()) searchFlags &= ~KateView::sfSelected;
1867 1867
1868 searchDialog = new SearchDialog(this, myDoc->searchForList, myDoc->replaceWithList, 1868 searchDialog = new SearchDialog(this, myDoc->searchForList, myDoc->replaceWithList,
1869 searchFlags & ~KateView::sfReplace); 1869 searchFlags & ~KateView::sfReplace);
1870 1870
1871 // If the user has marked some text we use that otherwise 1871 // If the user has marked some text we use that otherwise
1872 // use the word under the cursor. 1872 // use the word under the cursor.
1873 QString str; 1873 QString str;
1874 if (myDoc->hasMarkedText()) 1874 if (myDoc->hasMarkedText())
1875 str = markedText(); 1875 str = markedText();
1876 1876
1877 if (str.isEmpty()) 1877 if (str.isEmpty())
1878 str = currentWord(); 1878 str = currentWord();
1879 1879
1880 if (!str.isEmpty()) 1880 if (!str.isEmpty())
1881 { 1881 {
1882 str.replace(QRegExp("^\n"), ""); 1882 str.replace(QRegExp("^\n"), "");
1883 int pos=str.find("\n"); 1883 int pos=str.find("\n");
1884 if (pos>-1) 1884 if (pos>-1)
1885 str=str.left(pos); 1885 str=str.left(pos);
1886 searchDialog->setSearchText( str ); 1886 searchDialog->setSearchText( str );
1887 } 1887 }
1888 1888
1889 myViewInternal->focusOutEvent(0L);// QT bug ? 1889 myViewInternal->focusOutEvent(0L);// QT bug ?
1890 if (searchDialog->exec() == QDialog::Accepted) { 1890 if (searchDialog->exec() == QDialog::Accepted) {
1891 kwview_addToStrList(myDoc->searchForList, searchDialog->getSearchFor()); 1891 kwview_addToStrList(myDoc->searchForList, searchDialog->getSearchFor());
1892 searchFlags = searchDialog->getFlags() | (searchFlags & KateView::sfPrompt); 1892 searchFlags = searchDialog->getFlags() | (searchFlags & KateView::sfPrompt);
1893 initSearch(s, searchFlags); 1893 initSearch(s, searchFlags);
1894 findAgain(s); 1894 findAgain(s);
1895 } 1895 }
1896 qApp->processEvents();
1896 delete searchDialog; 1897 delete searchDialog;
1897} 1898}
1898 1899
1899void KateView::replace() { 1900void KateView::replace() {
1900 SearchDialog *searchDialog; 1901 SearchDialog *searchDialog;
1901 1902
1902 if (isReadOnly()) return; 1903 if (isReadOnly()) return;
1903 1904
1904 if (!myDoc->hasMarkedText()) searchFlags &= ~KateView::sfSelected; 1905 if (!myDoc->hasMarkedText()) searchFlags &= ~KateView::sfSelected;
1905 searchDialog = new SearchDialog(this, myDoc->searchForList, myDoc->replaceWithList, 1906 searchDialog = new SearchDialog(this, myDoc->searchForList, myDoc->replaceWithList,
1906 searchFlags | KateView::sfReplace); 1907 searchFlags | KateView::sfReplace);
1907 1908
1908 // If the user has marked some text we use that otherwise 1909 // If the user has marked some text we use that otherwise
1909 // use the word under the cursor. 1910 // use the word under the cursor.
1910 QString str; 1911 QString str;
1911 if (myDoc->hasMarkedText()) 1912 if (myDoc->hasMarkedText())
1912 str = markedText(); 1913 str = markedText();
1913 1914
1914 if (str.isEmpty()) 1915 if (str.isEmpty())
1915 str = currentWord(); 1916 str = currentWord();
1916 1917
1917 if (!str.isEmpty()) 1918 if (!str.isEmpty())
1918 { 1919 {
1919 str.replace(QRegExp("^\n"), ""); 1920 str.replace(QRegExp("^\n"), "");
1920 int pos=str.find("\n"); 1921 int pos=str.find("\n");
1921 if (pos>-1) 1922 if (pos>-1)
1922 str=str.left(pos); 1923 str=str.left(pos);
1923 searchDialog->setSearchText( str ); 1924 searchDialog->setSearchText( str );
1924 } 1925 }
1925 1926
1926 myViewInternal->focusOutEvent(0L);// QT bug ? 1927 myViewInternal->focusOutEvent(0L);// QT bug ?
1927 if (searchDialog->exec() == QDialog::Accepted) { 1928 if (searchDialog->exec() == QDialog::Accepted) {
1928// myDoc->recordReset(); 1929// myDoc->recordReset();
1929 kwview_addToStrList(myDoc->searchForList, searchDialog->getSearchFor()); 1930 kwview_addToStrList(myDoc->searchForList, searchDialog->getSearchFor());
1930 kwview_addToStrList(myDoc->replaceWithList, searchDialog->getReplaceWith()); 1931 kwview_addToStrList(myDoc->replaceWithList, searchDialog->getReplaceWith());
1931 searchFlags = searchDialog->getFlags(); 1932 searchFlags = searchDialog->getFlags();
1932 initSearch(s, searchFlags); 1933 initSearch(s, searchFlags);
1933 replaceAgain(); 1934 replaceAgain();
1934 } 1935 }
1936 qApp->processEvents();
1935 delete searchDialog; 1937 delete searchDialog;
1936} 1938}
1937 1939
1938void KateView::gotoLine() { 1940void KateView::gotoLine() {
1939 GotoLineDialog *dlg; 1941 GotoLineDialog *dlg;
1940 PointStruc cursor; 1942 PointStruc cursor;
1941 1943
1942 dlg = new GotoLineDialog(this, myViewInternal->cursor.y + 1, myDoc->numLines()); 1944 dlg = new GotoLineDialog(this, myViewInternal->cursor.y + 1, myDoc->numLines());
1943// dlg = new GotoLineDialog(myViewInternal->cursor.y + 1, this); 1945// dlg = new GotoLineDialog(myViewInternal->cursor.y + 1, this);
1944 1946
1945 if (dlg->exec() == QDialog::Accepted) { 1947 if (dlg->exec() == QDialog::Accepted) {
1946// myDoc->recordReset(); 1948// myDoc->recordReset();
1947 cursor.x = 0; 1949 cursor.x = 0;
1948 cursor.y = dlg->getLine() - 1; 1950 cursor.y = dlg->getLine() - 1;
1949 myDoc->needPreHighlight(cursor.y); 1951 myDoc->needPreHighlight(cursor.y);
1950 myViewInternal->updateCursor(cursor); 1952 myViewInternal->updateCursor(cursor);
1951 myViewInternal->center(); 1953 myViewInternal->center();
1952 myViewInternal->updateView(KateView::ufUpdateOnScroll); 1954 myViewInternal->updateView(KateView::ufUpdateOnScroll);
1953 myDoc->updateViews(this); //uptade all other views except this one 1955 myDoc->updateViews(this); //uptade all other views except this one
1954 } 1956 }
1957 qApp->processEvents();
1955 delete dlg; 1958 delete dlg;
1956} 1959}
1957 1960
1958 1961
1959void KateView::initSearch(SConfig &s, int flags) { 1962void KateView::initSearch(SConfig &s, int flags) {
1960 1963
1961 s.flags = flags; 1964 s.flags = flags;
1962 s.setPattern(myDoc->searchForList.first()); 1965 s.setPattern(myDoc->searchForList.first());
1963 1966
1964 if (!(s.flags & KateView::sfFromBeginning)) { 1967 if (!(s.flags & KateView::sfFromBeginning)) {
1965 // If we are continuing a backward search, make sure we do not get stuck 1968 // If we are continuing a backward search, make sure we do not get stuck
1966 // at an existing match. 1969 // at an existing match.
1967 s.cursor = myViewInternal->cursor; 1970 s.cursor = myViewInternal->cursor;
1968 TextLine::Ptr textLine = myDoc->getTextLine(s.cursor.y); 1971 TextLine::Ptr textLine = myDoc->getTextLine(s.cursor.y);
1969 QString const txt(textLine->getText(),textLine->length()); 1972 QString const txt(textLine->getText(),textLine->length());
1970 const QString searchFor= myDoc->searchForList.first(); 1973 const QString searchFor= myDoc->searchForList.first();
1971 int pos = s.cursor.x-searchFor.length()-1; 1974 int pos = s.cursor.x-searchFor.length()-1;
1972 if ( pos < 0 ) pos = 0; 1975 if ( pos < 0 ) pos = 0;
1973 pos= txt.find(searchFor, pos, s.flags & KateView::sfCaseSensitive); 1976 pos= txt.find(searchFor, pos, s.flags & KateView::sfCaseSensitive);
1974 if ( s.flags & KateView::sfBackward ) 1977 if ( s.flags & KateView::sfBackward )
1975 { 1978 {
1976 if ( pos <= s.cursor.x ) s.cursor.x= pos-1; 1979 if ( pos <= s.cursor.x ) s.cursor.x= pos-1;
1977 } 1980 }
1978 else 1981 else
1979 if ( pos == s.cursor.x ) s.cursor.x++; 1982 if ( pos == s.cursor.x ) s.cursor.x++;
1980 } else { 1983 } else {
1981 if (!(s.flags & KateView::sfBackward)) { 1984 if (!(s.flags & KateView::sfBackward)) {
1982 s.cursor.x = 0; 1985 s.cursor.x = 0;
1983 s.cursor.y = 0; 1986 s.cursor.y = 0;
1984 } else { 1987 } else {
1985 s.cursor.x = -1; 1988 s.cursor.x = -1;
1986 s.cursor.y = myDoc->lastLine(); 1989 s.cursor.y = myDoc->lastLine();
1987 } 1990 }
1988 s.flags |= KateView::sfFinished; 1991 s.flags |= KateView::sfFinished;
1989 } 1992 }
1990 if (!(s.flags & KateView::sfBackward)) { 1993 if (!(s.flags & KateView::sfBackward)) {
1991 if (!(s.cursor.x || s.cursor.y)) 1994 if (!(s.cursor.x || s.cursor.y))
1992 s.flags |= KateView::sfFinished; 1995 s.flags |= KateView::sfFinished;
1993 } 1996 }
1994 s.startCursor = s.cursor; 1997 s.startCursor = s.cursor;
1995} 1998}
1996 1999
1997void KateView::continueSearch(SConfig &s) { 2000void KateView::continueSearch(SConfig &s) {
1998 2001
1999 if (!(s.flags & KateView::sfBackward)) { 2002 if (!(s.flags & KateView::sfBackward)) {
2000 s.cursor.x = 0; 2003 s.cursor.x = 0;
2001 s.cursor.y = 0; 2004 s.cursor.y = 0;
2002 } else { 2005 } else {
2003 s.cursor.x = -1; 2006 s.cursor.x = -1;
2004 s.cursor.y = myDoc->lastLine(); 2007 s.cursor.y = myDoc->lastLine();
2005 } 2008 }
2006 s.flags |= KateView::sfFinished; 2009 s.flags |= KateView::sfFinished;
2007 s.flags &= ~KateView::sfAgain; 2010 s.flags &= ~KateView::sfAgain;
2008} 2011}
2009 2012
2010void KateView::findAgain(SConfig &s) { 2013void KateView::findAgain(SConfig &s) {
2011 int query; 2014 int query;
2012 PointStruc cursor; 2015 PointStruc cursor;
2013 QString str; 2016 QString str;
2014 2017
2015 QString searchFor = myDoc->searchForList.first(); 2018 QString searchFor = myDoc->searchForList.first();
2016 2019
2017 if( searchFor.isEmpty() ) { 2020 if( searchFor.isEmpty() ) {
2018 find(); 2021 find();
2019 return; 2022 return;
2020 } 2023 }
2021 2024
2022 do { 2025 do {
2023 query = KMessageBox::Cancel; 2026 query = KMessageBox::Cancel;
2024 if (myDoc->doSearch(s,searchFor)) { 2027 if (myDoc->doSearch(s,searchFor)) {
2025 cursor = s.cursor; 2028 cursor = s.cursor;
2026 if (!(s.flags & KateView::sfBackward)) 2029 if (!(s.flags & KateView::sfBackward))
2027 s.cursor.x += s.matchedLength; 2030 s.cursor.x += s.matchedLength;
2028 myViewInternal->updateCursor(s.cursor); //does deselectAll() 2031 myViewInternal->updateCursor(s.cursor); //does deselectAll()
2029 exposeFound(cursor,s.matchedLength,(s.flags & KateView::sfAgain) ? 0 : KateView::ufUpdateOnScroll,false); 2032 exposeFound(cursor,s.matchedLength,(s.flags & KateView::sfAgain) ? 0 : KateView::ufUpdateOnScroll,false);
2030 } else { 2033 } else {
2031 if (!(s.flags & KateView::sfFinished)) { 2034 if (!(s.flags & KateView::sfFinished)) {
2032 // ask for continue 2035 // ask for continue
2033 if (!(s.flags & KateView::sfBackward)) { 2036 if (!(s.flags & KateView::sfBackward)) {
2034 // forward search 2037 // forward search
2035 str = i18n("End of document reached.\n" 2038 str = i18n("End of document reached.\n"
2036 "Continue from the beginning?"); 2039 "Continue from the beginning?");
2037 query = KMessageBox::warningContinueCancel(this, 2040 query = KMessageBox::warningContinueCancel(this,
2038 str, i18n("Find"), i18n("Continue")); 2041 str, i18n("Find"), i18n("Continue"));
2039 } else { 2042 } else {
2040 // backward search 2043 // backward search
2041 str = i18n("Beginning of document reached.\n" 2044 str = i18n("Beginning of document reached.\n"
2042 "Continue from the end?"); 2045 "Continue from the end?");
2043 query = KMessageBox::warningContinueCancel(this, 2046 query = KMessageBox::warningContinueCancel(this,
2044 str, i18n("Find"), i18n("Continue")); 2047 str, i18n("Find"), i18n("Continue"));
2045 } 2048 }
2046 continueSearch(s); 2049 continueSearch(s);
2047 } else { 2050 } else {
2048 // wrapped 2051 // wrapped
2049 KMessageBox::sorry(this, 2052 KMessageBox::sorry(this,
2050 i18n("Search string '%1' not found!").arg(searchFor), 2053 i18n("Search string '%1' not found!").arg(searchFor),
2051 i18n("Find")); 2054 i18n("Find"));
2052 } 2055 }
2053 } 2056 }
2054 } while (query == KMessageBox::Continue); 2057 } while (query == KMessageBox::Continue);
2055} 2058}
2056 2059
2057void KateView::replaceAgain() { 2060void KateView::replaceAgain() {
2058 if (isReadOnly()) 2061 if (isReadOnly())
2059 return; 2062 return;
2060 2063
2061 replaces = 0; 2064 replaces = 0;
2062 if (s.flags & KateView::sfPrompt) { 2065 if (s.flags & KateView::sfPrompt) {
2063 doReplaceAction(-1); 2066 doReplaceAction(-1);
2064 } else { 2067 } else {
2065 doReplaceAction(KateView::srAll); 2068 doReplaceAction(KateView::srAll);
2066 } 2069 }
2067} 2070}
2068 2071
2069void KateView::doReplaceAction(int result, bool found) { 2072void KateView::doReplaceAction(int result, bool found) {
2070 int rlen; 2073 int rlen;
2071 PointStruc cursor; 2074 PointStruc cursor;
2072 bool started; 2075 bool started;
2073 2076
2074 QString searchFor = myDoc->searchForList.first(); 2077 QString searchFor = myDoc->searchForList.first();
2075 QString replaceWith = myDoc->replaceWithList.first(); 2078 QString replaceWith = myDoc->replaceWithList.first();
2076 rlen = replaceWith.length(); 2079 rlen = replaceWith.length();
2077 2080
2078 switch (result) { 2081 switch (result) {
2079 case KateView::srYes: //yes 2082 case KateView::srYes: //yes
2080 myDoc->recordStart(this, s.cursor, configFlags, 2083 myDoc->recordStart(this, s.cursor, configFlags,
2081 KateActionGroup::ugReplace, true); 2084 KateActionGroup::ugReplace, true);
2082 myDoc->recordReplace(s.cursor, s.matchedLength, replaceWith); 2085 myDoc->recordReplace(s.cursor, s.matchedLength, replaceWith);
2083 replaces++; 2086 replaces++;
2084 if (s.cursor.y == s.startCursor.y && s.cursor.x < s.startCursor.x) 2087 if (s.cursor.y == s.startCursor.y && s.cursor.x < s.startCursor.x)
2085 s.startCursor.x += rlen - s.matchedLength; 2088 s.startCursor.x += rlen - s.matchedLength;
2086 if (!(s.flags & KateView::sfBackward)) s.cursor.x += rlen; 2089 if (!(s.flags & KateView::sfBackward)) s.cursor.x += rlen;
2087 myDoc->recordEnd(this, s.cursor, configFlags | KateView::cfPersistent); 2090 myDoc->recordEnd(this, s.cursor, configFlags | KateView::cfPersistent);
2088 break; 2091 break;
2089 case KateView::srNo: //no 2092 case KateView::srNo: //no
2090 if (!(s.flags & KateView::sfBackward)) s.cursor.x += s.matchedLength; 2093 if (!(s.flags & KateView::sfBackward)) s.cursor.x += s.matchedLength;
2091 break; 2094 break;
2092 case KateView::srAll: //replace all 2095 case KateView::srAll: //replace all
2093 deleteReplacePrompt(); 2096 deleteReplacePrompt();
2094 do { 2097 do {
2095 started = false; 2098 started = false;
2096 while (found || myDoc->doSearch(s,searchFor)) { 2099 while (found || myDoc->doSearch(s,searchFor)) {
2097 if (!started) { 2100 if (!started) {
2098 found = false; 2101 found = false;
2099 myDoc->recordStart(this, s.cursor, configFlags, 2102 myDoc->recordStart(this, s.cursor, configFlags,
2100 KateActionGroup::ugReplace); 2103 KateActionGroup::ugReplace);
2101 started = true; 2104 started = true;
2102 } 2105 }
2103 myDoc->recordReplace(s.cursor, s.matchedLength, replaceWith); 2106 myDoc->recordReplace(s.cursor, s.matchedLength, replaceWith);
2104 replaces++; 2107 replaces++;
2105 if (s.cursor.y == s.startCursor.y && s.cursor.x < s.startCursor.x) 2108 if (s.cursor.y == s.startCursor.y && s.cursor.x < s.startCursor.x)
2106 s.startCursor.x += rlen - s.matchedLength; 2109 s.startCursor.x += rlen - s.matchedLength;
2107 if (!(s.flags & KateView::sfBackward)) s.cursor.x += rlen; 2110 if (!(s.flags & KateView::sfBackward)) s.cursor.x += rlen;
2108 } 2111 }
2109 if (started) myDoc->recordEnd(this, s.cursor, 2112 if (started) myDoc->recordEnd(this, s.cursor,
2110 configFlags | KateView::cfPersistent); 2113 configFlags | KateView::cfPersistent);
2111 } while (!askReplaceEnd()); 2114 } while (!askReplaceEnd());
2112 return; 2115 return;
2113 case KateView::srCancel: //cancel 2116 case KateView::srCancel: //cancel
2114 deleteReplacePrompt(); 2117 deleteReplacePrompt();
2115 return; 2118 return;
2116 default: 2119 default:
2117 replacePrompt = 0L; 2120 replacePrompt = 0L;
2118 } 2121 }
2119 2122
2120 do { 2123 do {
2121 if (myDoc->doSearch(s,searchFor)) { 2124 if (myDoc->doSearch(s,searchFor)) {
2122 //text found: highlight it, show replace prompt if needed and exit 2125 //text found: highlight it, show replace prompt if needed and exit
2123 cursor = s.cursor; 2126 cursor = s.cursor;
2124 if (!(s.flags & KateView::sfBackward)) cursor.x += s.matchedLength; 2127 if (!(s.flags & KateView::sfBackward)) cursor.x += s.matchedLength;
2125 myViewInternal->updateCursor(cursor); //does deselectAll() 2128 myViewInternal->updateCursor(cursor); //does deselectAll()
2126 exposeFound(s.cursor,s.matchedLength,(s.flags & KateView::sfAgain) ? 0 : KateView::ufUpdateOnScroll,true); 2129 exposeFound(s.cursor,s.matchedLength,(s.flags & KateView::sfAgain) ? 0 : KateView::ufUpdateOnScroll,true);
2127 if (replacePrompt == 0L) { 2130 if (replacePrompt == 0L) {
2128 replacePrompt = new ReplacePrompt(this); 2131 replacePrompt = new ReplacePrompt(this);
2129 myDoc->setPseudoModal(replacePrompt);//disable(); 2132 myDoc->setPseudoModal(replacePrompt);//disable();
2130 connect(replacePrompt,SIGNAL(clicked()),this,SLOT(replaceSlot())); 2133 connect(replacePrompt,SIGNAL(clicked()),this,SLOT(replaceSlot()));
2131 replacePrompt->show(); //this is not modal 2134 replacePrompt->show(); //this is not modal
2132 } 2135 }
2133 return; //exit if text found 2136 return; //exit if text found
2134 } 2137 }
2135 //nothing found: repeat until user cancels "repeat from beginning" dialog 2138 //nothing found: repeat until user cancels "repeat from beginning" dialog
2136 } while (!askReplaceEnd()); 2139 } while (!askReplaceEnd());
2137 deleteReplacePrompt(); 2140 deleteReplacePrompt();
2138} 2141}
2139 2142
2140void KateView::exposeFound(PointStruc &cursor, int slen, int flags, bool replace) { 2143void KateView::exposeFound(PointStruc &cursor, int slen, int flags, bool replace) {
2141 int x1, x2, y1, y2, xPos, yPos; 2144 int x1, x2, y1, y2, xPos, yPos;
2142 2145
2143 VConfig c; 2146 VConfig c;
2144 myViewInternal->getVConfig(c); 2147 myViewInternal->getVConfig(c);
2145 myDoc->selectLength(cursor,slen,c.flags); 2148 myDoc->selectLength(cursor,slen,c.flags);
2146 2149
2147 TextLine::Ptr textLine = myDoc->getTextLine(cursor.y); 2150 TextLine::Ptr textLine = myDoc->getTextLine(cursor.y);
2148 x1 = myDoc->textWidth(textLine,cursor.x) -10; 2151 x1 = myDoc->textWidth(textLine,cursor.x) -10;
2149 x2 = myDoc->textWidth(textLine,cursor.x + slen) +20; 2152 x2 = myDoc->textWidth(textLine,cursor.x + slen) +20;
2150 y1 = myDoc->fontHeight*cursor.y -10; 2153 y1 = myDoc->fontHeight*cursor.y -10;
2151 y2 = y1 + myDoc->fontHeight +30; 2154 y2 = y1 + myDoc->fontHeight +30;
2152 2155
2153 xPos = myViewInternal->xPos; 2156 xPos = myViewInternal->xPos;
2154 yPos = myViewInternal->yPos; 2157 yPos = myViewInternal->yPos;
2155 2158
2156 if (x1 < 0) x1 = 0; 2159 if (x1 < 0) x1 = 0;
2157 if (replace) y2 += 90; 2160 if (replace) y2 += 90;
2158 2161
2159 if (x1 < xPos || x2 > xPos + myViewInternal->width()) { 2162 if (x1 < xPos || x2 > xPos + myViewInternal->width()) {
2160 xPos = x2 - myViewInternal->width(); 2163 xPos = x2 - myViewInternal->width();
2161 } 2164 }
2162 if (y1 < yPos || y2 > yPos + myViewInternal->height()) { 2165 if (y1 < yPos || y2 > yPos + myViewInternal->height()) {
2163 xPos = x2 - myViewInternal->width(); 2166 xPos = x2 - myViewInternal->width();
2164 yPos = myDoc->fontHeight*cursor.y - height()/3; 2167 yPos = myDoc->fontHeight*cursor.y - height()/3;
2165 } 2168 }
2166 myViewInternal->setPos(xPos, yPos); 2169 myViewInternal->setPos(xPos, yPos);
2167 myViewInternal->updateView(flags);// | ufPos,xPos,yPos); 2170 myViewInternal->updateView(flags);// | ufPos,xPos,yPos);
2168 myDoc->updateViews(this); 2171 myDoc->updateViews(this);
2169} 2172}
2170 2173
2171void KateView::deleteReplacePrompt() { 2174void KateView::deleteReplacePrompt() {
2172 myDoc->setPseudoModal(0L); 2175 myDoc->setPseudoModal(0L);
2173} 2176}
2174 2177
2175bool KateView::askReplaceEnd() { 2178bool KateView::askReplaceEnd() {
2176 QString str; 2179 QString str;
2177 int query; 2180 int query;
2178 2181
2179 myDoc->updateViews(); 2182 myDoc->updateViews();
2180 if (s.flags & KateView::sfFinished) { 2183 if (s.flags & KateView::sfFinished) {
2181 // replace finished 2184 // replace finished
2182 str = i18n("%1 replacement(s) made").arg(replaces); 2185 str = i18n("%1 replacement(s) made").arg(replaces);
2183 KMessageBox::information(this, str, i18n("Replace")); 2186 KMessageBox::information(this, str, i18n("Replace"));
2184 return true; 2187 return true;
2185 } 2188 }
2186 2189
2187 // ask for continue 2190 // ask for continue
2188 if (!(s.flags & KateView::sfBackward)) { 2191 if (!(s.flags & KateView::sfBackward)) {
2189 // forward search 2192 // forward search
2190 str = i18n("%1 replacement(s) made.\n" 2193 str = i18n("%1 replacement(s) made.\n"
2191 "End of document reached.\n" 2194 "End of document reached.\n"
2192 "Continue from the beginning?").arg(replaces); 2195 "Continue from the beginning?").arg(replaces);
2193 query = KMessageBox::questionYesNo(this, str, i18n("Replace"), 2196 query = KMessageBox::questionYesNo(this, str, i18n("Replace"),
2194 i18n("Continue"), i18n("Stop")); 2197 i18n("Continue"), i18n("Stop"));
2195 } else { 2198 } else {
2196 // backward search 2199 // backward search
2197 str = i18n("%1 replacement(s) made.\n" 2200 str = i18n("%1 replacement(s) made.\n"
2198 "Beginning of document reached.\n" 2201 "Beginning of document reached.\n"
2199 "Continue from the end?").arg(replaces); 2202 "Continue from the end?").arg(replaces);
2200 query = KMessageBox::questionYesNo(this, str, i18n("Replace"), 2203 query = KMessageBox::questionYesNo(this, str, i18n("Replace"),
2201 i18n("Continue"), i18n("Stop")); 2204 i18n("Continue"), i18n("Stop"));
2202 } 2205 }
2203 replaces = 0; 2206 replaces = 0;
2204 continueSearch(s); 2207 continueSearch(s);
2205 return (query == KMessageBox::No); 2208 return (query == KMessageBox::No);
2206} 2209}
2207 2210
2208void KateView::replaceSlot() { 2211void KateView::replaceSlot() {
2209 doReplaceAction(replacePrompt->result(),true); 2212 doReplaceAction(replacePrompt->result(),true);
2210} 2213}
2211 2214
2212void KateView::installPopup(QPopupMenu *rmb_Menu) 2215void KateView::installPopup(QPopupMenu *rmb_Menu)
2213{ 2216{
2214 rmbMenu = rmb_Menu; 2217 rmbMenu = rmb_Menu;
2215} 2218}
2216 2219
2217void KateView::readConfig() 2220void KateView::readConfig()
2218{ 2221{
2219 KateConfig *config = KGlobal::config(); 2222 KateConfig *config = KGlobal::config();
2220 config->setGroup("Kate View"); 2223 config->setGroup("Kate View");
2221 2224
2222 searchFlags = config->readNumEntry("SearchFlags", KateView::sfPrompt); 2225 searchFlags = config->readNumEntry("SearchFlags", KateView::sfPrompt);
2223 configFlags = config->readNumEntry("ConfigFlags", configFlags) & ~KateView::cfMark; 2226 configFlags = config->readNumEntry("ConfigFlags", configFlags) & ~KateView::cfMark;
2224 2227
2225// config->sync(); 2228// config->sync();
2226} 2229}
2227 2230
2228void KateView::writeConfig() 2231void KateView::writeConfig()
2229{ 2232{
2230 KateConfig *config = KGlobal::config(); 2233 KateConfig *config = KGlobal::config();
2231 config->setGroup("Kate View"); 2234 config->setGroup("Kate View");
2232 2235
2233 config->writeEntry("SearchFlags",searchFlags); 2236 config->writeEntry("SearchFlags",searchFlags);
2234 config->writeEntry("ConfigFlags",configFlags); 2237 config->writeEntry("ConfigFlags",configFlags);
2235 2238
2236// config->sync(); 2239// config->sync();
2237} 2240}
2238 2241
2239void KateView::readSessionConfig(KateConfig *config) 2242void KateView::readSessionConfig(KateConfig *config)
2240{ 2243{
2241 PointStruc cursor; 2244 PointStruc cursor;
2242 2245
2243 myViewInternal->xPos = config->readNumEntry("XPos"); 2246 myViewInternal->xPos = config->readNumEntry("XPos");
2244 myViewInternal->yPos = config->readNumEntry("YPos"); 2247 myViewInternal->yPos = config->readNumEntry("YPos");
2245 cursor.x = config->readNumEntry("CursorX"); 2248 cursor.x = config->readNumEntry("CursorX");
2246 cursor.y = config->readNumEntry("CursorY"); 2249 cursor.y = config->readNumEntry("CursorY");
2247 myViewInternal->updateCursor(cursor); 2250 myViewInternal->updateCursor(cursor);
2248 myIconBorder = config->readBoolEntry("IconBorder on"); 2251 myIconBorder = config->readBoolEntry("IconBorder on");
2249 setIconBorder(myIconBorder); 2252 setIconBorder(myIconBorder);
2250} 2253}
2251 2254
2252void KateView::writeSessionConfig(KateConfig *config) 2255void KateView::writeSessionConfig(KateConfig *config)
2253{ 2256{
2254 config->writeEntry("XPos",myViewInternal->xPos); 2257 config->writeEntry("XPos",myViewInternal->xPos);
2255 config->writeEntry("YPos",myViewInternal->yPos); 2258 config->writeEntry("YPos",myViewInternal->yPos);
2256 config->writeEntry("CursorX",myViewInternal->cursor.x); 2259 config->writeEntry("CursorX",myViewInternal->cursor.x);
2257 config->writeEntry("CursorY",myViewInternal->cursor.y); 2260 config->writeEntry("CursorY",myViewInternal->cursor.y);
2258 config->writeEntry("IconBorder on", myIconBorder); 2261 config->writeEntry("IconBorder on", myIconBorder);
2259} 2262}
2260 2263
2261void KateView::configDialog() 2264void KateView::configDialog()
2262{ 2265{
2263 2266
2264#warning fixme 2267#warning fixme
2265 2268
2266#if 1 2269#if 1
2267 KDialogBase *kd = new KDialogBase(KDialogBase::IconList, 2270 KDialogBase *kd = new KDialogBase(KDialogBase::IconList,
2268 i18n("Configure Editor"), 2271 i18n("Configure Editor"),
2269 KDialogBase::Ok | KDialogBase::Cancel | 2272 KDialogBase::Ok | KDialogBase::Cancel |
2270 KDialogBase::Help , 2273 KDialogBase::Help ,
2271 KDialogBase::Ok, this, "tabdialog"); 2274 KDialogBase::Ok, this, "tabdialog");
2272 2275
2273 // color options 2276 // color options
2274 QFrame *page=kd->addPage(i18n("Colors")); 2277 QFrame *page=kd->addPage(i18n("Colors"));
2275 (new QVBoxLayout(page))->setAutoAdd(true); 2278 (new QVBoxLayout(page))->setAutoAdd(true);
2276 ColorConfig *colorConfig = new ColorConfig(page); 2279 ColorConfig *colorConfig = new ColorConfig(page);
2277 QColor* colors = getColors(); 2280 QColor* colors = getColors();
2278 colorConfig->setColors(colors); 2281 colorConfig->setColors(colors);
2279 2282
2280 page = kd->addPage(i18n("Fonts")); 2283 page = kd->addPage(i18n("Fonts"));
2281 (new QVBoxLayout(page))->setAutoAdd(true); 2284 (new QVBoxLayout(page))->setAutoAdd(true);
2282 2285
2283 FontConfig *fontConfig = new FontConfig(page); 2286 FontConfig *fontConfig = new FontConfig(page);
2284 fontConfig->setFont (myDoc->getFont()); 2287 fontConfig->setFont (myDoc->getFont());
2285 2288
2286 // indent options 2289 // indent options
2287 page=kd->addPage(i18n("Indent")); 2290 page=kd->addPage(i18n("Indent"));
2288 (new QVBoxLayout(page))->setAutoAdd(true); 2291 (new QVBoxLayout(page))->setAutoAdd(true);
2289 2292
2290 IndentConfigTab *indentConfig = new IndentConfigTab(page, this); 2293 IndentConfigTab *indentConfig = new IndentConfigTab(page, this);
2291 2294
2292 // select options 2295 // select options
2293 page=kd->addPage(i18n("Select")); 2296 page=kd->addPage(i18n("Select"));
2294 (new QVBoxLayout(page))->setAutoAdd(true); 2297 (new QVBoxLayout(page))->setAutoAdd(true);
2295 2298
2296 SelectConfigTab *selectConfig = new SelectConfigTab(page, this); 2299 SelectConfigTab *selectConfig = new SelectConfigTab(page, this);
2297 2300
2298 // edit options 2301 // edit options
2299 page=kd->addPage(i18n("Edit")); 2302 page=kd->addPage(i18n("Edit"));
2300 (new QVBoxLayout(page))->setAutoAdd(true); 2303 (new QVBoxLayout(page))->setAutoAdd(true);
2301 2304
2302 EditConfigTab *editConfig = new EditConfigTab(page, this); 2305 EditConfigTab *editConfig = new EditConfigTab(page, this);
2303 2306
2304 2307
2305 2308
2306 HighlightDialogPage *hlPage; 2309 HighlightDialogPage *hlPage;
2307 HlManager *hlManager; 2310 HlManager *hlManager;
2308 HlDataList hlDataList; 2311 HlDataList hlDataList;
2309 ItemStyleList defaultStyleList; 2312 ItemStyleList defaultStyleList;
2310 2313
2311 hlManager = HlManager::self(); 2314 hlManager = HlManager::self();
2312 2315
2313 defaultStyleList.setAutoDelete(true); 2316 defaultStyleList.setAutoDelete(true);
2314 hlManager->getDefaults(defaultStyleList); 2317 hlManager->getDefaults(defaultStyleList);
2315 2318
2316 hlDataList.setAutoDelete(true); 2319 hlDataList.setAutoDelete(true);
2317 //this gets the data from the KateConfig object 2320 //this gets the data from the KateConfig object
2318 hlManager->getHlDataList(hlDataList); 2321 hlManager->getHlDataList(hlDataList);
2319 2322
2320 page=kd->addPage(i18n("Highlighting")); 2323 page=kd->addPage(i18n("Highlighting"));
2321 (new QVBoxLayout(page))->setAutoAdd(true); 2324 (new QVBoxLayout(page))->setAutoAdd(true);
2322 2325
2323 hlPage = new HighlightDialogPage(hlManager, &defaultStyleList, &hlDataList, 0, page); 2326 hlPage = new HighlightDialogPage(hlManager, &defaultStyleList, &hlDataList, 0, page);
2324 if ( QPEApplication::execDialog( kd )) { 2327 if ( QPEApplication::execDialog( kd )) {
2325 // color options 2328 // color options
2326 colorConfig->getColors(colors); 2329 colorConfig->getColors(colors);
2327 myDoc->setFont (fontConfig->getFont()); 2330 myDoc->setFont (fontConfig->getFont());
2328 2331
2329 applyColors(); 2332 applyColors();
2330 // indent options 2333 // indent options
2331 indentConfig->getData(this); 2334 indentConfig->getData(this);
2332 // select options 2335 // select options
2333 selectConfig->getData(this); 2336 selectConfig->getData(this);
2334 // edit options 2337 // edit options
2335 editConfig->getData(this); 2338 editConfig->getData(this);
2336 // spell checker 2339 // spell checker
2337 hlManager->setHlDataList(hlDataList); 2340 hlManager->setHlDataList(hlDataList);
2338 hlManager->setDefaults(defaultStyleList); 2341 hlManager->setDefaults(defaultStyleList);
2339 hlPage->saveData(); 2342 hlPage->saveData();
2340 } 2343 }
2341 2344
2342// delete kd; 2345// delete kd;
2343 2346
2344#endif 2347#endif
2345} 2348}
2346 2349
2347int KateView::getHl() { 2350int KateView::getHl() {
2348 return myDoc->highlightNum(); 2351 return myDoc->highlightNum();
2349} 2352}
2350 2353
2351void KateView::setDontChangeHlOnSave() 2354void KateView::setDontChangeHlOnSave()
2352{ 2355{
2353 myDoc->setDontChangeHlOnSave(); 2356 myDoc->setDontChangeHlOnSave();
2354} 2357}
2355 2358
2356void KateView::setHl(int n) { 2359void KateView::setHl(int n) {
2357 myDoc->setHighlight(n); 2360 myDoc->setHighlight(n);
2358 myDoc->setDontChangeHlOnSave(); 2361 myDoc->setDontChangeHlOnSave();
2359 myDoc->updateViews(); 2362 myDoc->updateViews();
2360} 2363}
2361 2364
2362int KateView::getEol() { 2365int KateView::getEol() {
2363 return myDoc->eolMode; 2366 return myDoc->eolMode;
2364} 2367}
2365 2368
2366void KateView::setEol(int eol) { 2369void KateView::setEol(int eol) {
2367 if (isReadOnly()) 2370 if (isReadOnly())
2368 return; 2371 return;
2369 2372
2370 myDoc->eolMode = eol; 2373 myDoc->eolMode = eol;
2371 myDoc->setModified(true); 2374 myDoc->setModified(true);
2372} 2375}
2373 2376
2374 2377
2375 2378
2376void KateView::paintEvent(QPaintEvent *e) { 2379void KateView::paintEvent(QPaintEvent *e) {
2377 int x, y; 2380 int x, y;
2378 2381
2379 QRect updateR = e->rect(); // update rectangle 2382 QRect updateR = e->rect(); // update rectangle
2380// debug("Update rect = ( %i, %i, %i, %i )", 2383// debug("Update rect = ( %i, %i, %i, %i )",
2381// updateR.x(),updateR.y(), updateR.width(), updateR.height() ); 2384// updateR.x(),updateR.y(), updateR.width(), updateR.height() );
2382 2385
2383 int ux1 = updateR.x(); 2386 int ux1 = updateR.x();
2384 int uy1 = updateR.y(); 2387 int uy1 = updateR.y();
2385 int ux2 = ux1 + updateR.width(); 2388 int ux2 = ux1 + updateR.width();
2386 int uy2 = uy1 + updateR.height(); 2389 int uy2 = uy1 + updateR.height();
2387 2390
2388 QPainter paint; 2391 QPainter paint;
2389 paint.begin(this); 2392 paint.begin(this);
2390 2393
2391 QColorGroup g = colorGroup(); 2394 QColorGroup g = colorGroup();
2392 x = width(); 2395 x = width();
2393 y = height(); 2396 y = height();
2394 2397
2395 paint.setPen(g.dark()); 2398 paint.setPen(g.dark());
2396 if (uy1 <= 0) paint.drawLine(0,0,x-2,0); 2399 if (uy1 <= 0) paint.drawLine(0,0,x-2,0);
2397 if (ux1 <= 0) paint.drawLine(0,1,0,y-2); 2400 if (ux1 <= 0) paint.drawLine(0,1,0,y-2);
2398 2401
2399 paint.setPen(black); 2402 paint.setPen(black);
2400 if (uy1 <= 1) paint.drawLine(1,1,x-3,1); 2403 if (uy1 <= 1) paint.drawLine(1,1,x-3,1);
2401 if (ux1 <= 1) paint.drawLine(1,2,1,y-3); 2404 if (ux1 <= 1) paint.drawLine(1,2,1,y-3);
2402 2405
2403 paint.setPen(g.midlight()); 2406 paint.setPen(g.midlight());
2404 if (uy2 >= y-1) paint.drawLine(1,y-2,x-3,y-2); 2407 if (uy2 >= y-1) paint.drawLine(1,y-2,x-3,y-2);
2405 if (ux2 >= x-1) paint.drawLine(x-2,1,x-2,y-2); 2408 if (ux2 >= x-1) paint.drawLine(x-2,1,x-2,y-2);
2406 2409
2407 paint.setPen(g.light()); 2410 paint.setPen(g.light());
2408 if (uy2 >= y) paint.drawLine(0,y-1,x-2,y-1); 2411 if (uy2 >= y) paint.drawLine(0,y-1,x-2,y-1);
2409 if (ux2 >= x) paint.drawLine(x-1,0,x-1,y-1); 2412 if (ux2 >= x) paint.drawLine(x-1,0,x-1,y-1);
2410 2413
2411 x -= 2 + 16; 2414 x -= 2 + 16;
2412 y -= 2 + 16; 2415 y -= 2 + 16;
2413 if (ux2 > x && uy2 > y) { 2416 if (ux2 > x && uy2 > y) {
2414 paint.fillRect(x,y,16,16,g.background()); 2417 paint.fillRect(x,y,16,16,g.background());
2415 } 2418 }
2416 paint.end(); 2419 paint.end();
2417} 2420}
2418 2421
2419void KateView::resizeEvent(QResizeEvent *) { 2422void KateView::resizeEvent(QResizeEvent *) {
2420 2423
2421// debug("Resize %d, %d",e->size().width(),e->size().height()); 2424// debug("Resize %d, %d",e->size().width(),e->size().height());
2422 2425
2423//myViewInternal->resize(width() -20, height() -20); 2426//myViewInternal->resize(width() -20, height() -20);
2424 myViewInternal->tagAll(); 2427 myViewInternal->tagAll();
2425 myViewInternal->updateView(0/*ufNoScroll*/); 2428 myViewInternal->updateView(0/*ufNoScroll*/);
2426} 2429}
2427 2430
2428 2431
2429// Applies a new pattern to the search context. 2432// Applies a new pattern to the search context.
2430void SConfig::setPattern(QString &newPattern) { 2433void SConfig::setPattern(QString &newPattern) {
2431 bool regExp = (flags & KateView::sfRegularExpression); 2434 bool regExp = (flags & KateView::sfRegularExpression);
2432 2435
2433 m_pattern = newPattern; 2436 m_pattern = newPattern;
2434 if (regExp) { 2437 if (regExp) {
2435 m_regExp.setCaseSensitive(flags & KateView::sfCaseSensitive); 2438 m_regExp.setCaseSensitive(flags & KateView::sfCaseSensitive);
2436 m_regExp.setPattern(m_pattern); 2439 m_regExp.setPattern(m_pattern);
2437 } 2440 }
2438} 2441}
2439 2442
2440// Applies the search context to the given string, and returns whether a match was found. If one is, 2443// Applies the search context to the given string, and returns whether a match was found. If one is,
2441// the length of the string matched is also returned. 2444// the length of the string matched is also returned.
2442int SConfig::search(QString &text, int index) { 2445int SConfig::search(QString &text, int index) {
2443 bool regExp = (flags & KateView::sfRegularExpression); 2446 bool regExp = (flags & KateView::sfRegularExpression);
2444 bool caseSensitive = (flags & KateView::sfCaseSensitive); 2447 bool caseSensitive = (flags & KateView::sfCaseSensitive);
2445 2448
2446 if (flags & KateView::sfBackward) { 2449 if (flags & KateView::sfBackward) {
2447 if (regExp) { 2450 if (regExp) {
2448 index = text.findRev(m_regExp, index); 2451 index = text.findRev(m_regExp, index);
2449 } 2452 }
2450 else { 2453 else {
2451 index = text.findRev(m_pattern, index, caseSensitive); 2454 index = text.findRev(m_pattern, index, caseSensitive);
2452 } 2455 }
2453 } 2456 }
2454 else { 2457 else {
2455 if (regExp) { 2458 if (regExp) {
2456 index = text.find(m_regExp, index); 2459 index = text.find(m_regExp, index);
2457 } 2460 }
2458 else { 2461 else {
2459 index = text.find(m_pattern, index, caseSensitive); 2462 index = text.find(m_pattern, index, caseSensitive);
2460 } 2463 }
2461 } 2464 }
2462 2465
2463 // Work out the matched length. 2466 // Work out the matched length.
2464 if (index != -1) 2467 if (index != -1)
2465 { 2468 {
2466 if (regExp) { 2469 if (regExp) {
2467 m_regExp.match(text, index, &matchedLength, false); 2470 m_regExp.match(text, index, &matchedLength, false);
2468 } 2471 }
2469 else { 2472 else {
2470 matchedLength = m_pattern.length(); 2473 matchedLength = m_pattern.length();
2471 } 2474 }
2472 } 2475 }
2473 return index; 2476 return index;
2474} 2477}
2475 2478
2476void KateView::setActive (bool b) 2479void KateView::setActive (bool b)
2477{ 2480{
2478 active = b; 2481 active = b;
2479} 2482}
2480 2483
2481bool KateView::isActive () 2484bool KateView::isActive ()
2482{ 2485{
2483 return active; 2486 return active;
2484} 2487}
2485 2488
2486void KateView::setFocus () 2489void KateView::setFocus ()
2487{ 2490{
2488 QWidget::setFocus (); 2491 QWidget::setFocus ();
2489 2492
2490 emit gotFocus (this); 2493 emit gotFocus (this);
2491} 2494}
2492 2495
2493bool KateView::eventFilter (QObject *object, QEvent *event) 2496bool KateView::eventFilter (QObject *object, QEvent *event)
2494{ 2497{
2495 2498
2496 if ( (event->type() == QEvent::FocusIn) ) 2499 if ( (event->type() == QEvent::FocusIn) )
2497 emit gotFocus (this); 2500 emit gotFocus (this);
2498 2501
2499 if ( (event->type() == QEvent::KeyPress) ) 2502 if ( (event->type() == QEvent::KeyPress) )
2500 { 2503 {
2501 QKeyEvent * ke=(QKeyEvent *)event; 2504 QKeyEvent * ke=(QKeyEvent *)event;
2502 2505
2503 if ((ke->key()==Qt::Key_Tab) || (ke->key()==Qt::Key_BackTab)) 2506 if ((ke->key()==Qt::Key_Tab) || (ke->key()==Qt::Key_BackTab))
2504 { 2507 {
2505 myViewInternal->keyPressEvent(ke); 2508 myViewInternal->keyPressEvent(ke);
2506 return true; 2509 return true;
2507 } 2510 }
2508 } 2511 }
2509 return QWidget::eventFilter (object, event); 2512 return QWidget::eventFilter (object, event);
2510} 2513}
2511 2514
2512void KateView::findAgain (bool back) 2515void KateView::findAgain (bool back)
2513{ 2516{
2514 bool b= (searchFlags & sfBackward) > 0; 2517 bool b= (searchFlags & sfBackward) > 0;
2515 initSearch(s, (searchFlags & ((b==back)?~sfBackward:~0) & ~sfFromBeginning) // clear flag for forward searching 2518 initSearch(s, (searchFlags & ((b==back)?~sfBackward:~0) & ~sfFromBeginning) // clear flag for forward searching
2516 | sfPrompt | sfAgain | ((b!=back)?sfBackward:0) ); 2519 | sfPrompt | sfAgain | ((b!=back)?sfBackward:0) );
2517 if (s.flags & sfReplace) 2520 if (s.flags & sfReplace)
2518 replaceAgain(); 2521 replaceAgain();
2519 else 2522 else
2520 KateView::findAgain(s); 2523 KateView::findAgain(s);
2521} 2524}
2522 2525
2523void KateView::slotEditCommand () 2526void KateView::slotEditCommand ()
2524{ 2527{
2525#warning fixme 2528#warning fixme
2526/* 2529/*
2527 bool ok; 2530 bool ok;
2528 QString cmd = KLineEditDlg::getText("Editing Command", "", &ok, this); 2531 QString cmd = KLineEditDlg::getText("Editing Command", "", &ok, this);
2529 2532
2530 if (ok) 2533 if (ok)
2531 myDoc->cmd()->execCmd (cmd, this);*/ 2534 myDoc->cmd()->execCmd (cmd, this);*/
2532} 2535}
2533 2536
2534void KateView::setIconBorder (bool enable) 2537void KateView::setIconBorder (bool enable)
2535{ 2538{
2536 myIconBorder = enable; 2539 myIconBorder = enable;
2537 2540
2538 if (myIconBorder) 2541 if (myIconBorder)
2539 { 2542 {
2540 myViewInternal->move(myViewInternal->iconBorderWidth+2, 2); 2543 myViewInternal->move(myViewInternal->iconBorderWidth+2, 2);
2541 myViewInternal->leftBorder->show(); 2544 myViewInternal->leftBorder->show();
2542 } 2545 }
2543 else 2546 else
2544 { 2547 {
2545 myViewInternal->leftBorder->hide(); 2548 myViewInternal->leftBorder->hide();
2546 myViewInternal->move(2, 2); 2549 myViewInternal->move(2, 2);
2547 } 2550 }
2548} 2551}
2549 2552
2550void KateView::toggleIconBorder () 2553void KateView::toggleIconBorder ()
2551{ 2554{
2552 setIconBorder (!myIconBorder); 2555 setIconBorder (!myIconBorder);
2553} 2556}
2554 2557
2555void KateView::gotoMark (Kate::Mark *mark) 2558void KateView::gotoMark (Kate::Mark *mark)
2556{ 2559{
2557 PointStruc cursor; 2560 PointStruc cursor;
2558 2561
2559 cursor.x = 0; 2562 cursor.x = 0;
2560 cursor.y = mark->line; 2563 cursor.y = mark->line;
2561 myDoc->needPreHighlight(cursor.y); 2564 myDoc->needPreHighlight(cursor.y);
2562 myViewInternal->updateCursor(cursor); 2565 myViewInternal->updateCursor(cursor);
2563 myViewInternal->center(); 2566 myViewInternal->center();
2564 myViewInternal->updateView(KateView::ufUpdateOnScroll); 2567 myViewInternal->updateView(KateView::ufUpdateOnScroll);
2565 myDoc->updateViews(this); 2568 myDoc->updateViews(this);
2566} 2569}
2567 2570
2568void KateView::toggleBookmark () 2571void KateView::toggleBookmark ()
2569{ 2572{
2570 TextLine::Ptr line = myDoc->getTextLine (currentLine()); 2573 TextLine::Ptr line = myDoc->getTextLine (currentLine());
2571 2574
2572 if (line->mark()&KateDocument::Bookmark) 2575 if (line->mark()&KateDocument::Bookmark)
2573 line->delMark(KateDocument::Bookmark); 2576 line->delMark(KateDocument::Bookmark);
2574 else 2577 else
2575 line->addMark(KateDocument::Bookmark); 2578 line->addMark(KateDocument::Bookmark);
2576 2579
2577 myDoc->tagLines (currentLine(), currentLine()); 2580 myDoc->tagLines (currentLine(), currentLine());
2578 myDoc->updateViews(); 2581 myDoc->updateViews();
2579} 2582}
2580 2583
2581void KateView::clearBookmarks() 2584void KateView::clearBookmarks()
2582{ 2585{
2583 QList<Kate::Mark> list = myDoc->marks(); 2586 QList<Kate::Mark> list = myDoc->marks();
2584 for (int i=0; (uint) i < list.count(); i++) 2587 for (int i=0; (uint) i < list.count(); i++)
2585 { 2588 {
2586 if (list.at(i)->type&KateDocument::Bookmark) 2589 if (list.at(i)->type&KateDocument::Bookmark)
2587 { 2590 {
2588 myDoc->getTextLine(list.at(i)->line)->delMark(KateDocument::Bookmark); 2591 myDoc->getTextLine(list.at(i)->line)->delMark(KateDocument::Bookmark);
2589 myDoc->tagLines(list.at(i)->line, list.at(i)->line); 2592 myDoc->tagLines(list.at(i)->line, list.at(i)->line);
2590 } 2593 }
2591 } 2594 }
2592 2595
2593 myDoc->updateViews(); 2596 myDoc->updateViews();
2594} 2597}
2595 2598
2596void KateView::bookmarkMenuAboutToShow() 2599void KateView::bookmarkMenuAboutToShow()
2597{ 2600{
2598#warning fixme 2601#warning fixme
2599#if 0 2602#if 0
2600 bookmarkMenu->popupMenu()->clear (); 2603 bookmarkMenu->popupMenu()->clear ();
2601 bookmarkToggle->plug (bookmarkMenu->popupMenu()); 2604 bookmarkToggle->plug (bookmarkMenu->popupMenu());
2602 bookmarkClear->plug (bookmarkMenu->popupMenu()); 2605 bookmarkClear->plug (bookmarkMenu->popupMenu());
2603 bookmarkMenu->popupMenu()->insertSeparator (); 2606 bookmarkMenu->popupMenu()->insertSeparator ();
2604 2607
2605 list = myDoc->marks(); 2608 list = myDoc->marks();
2606 for (int i=0; (uint) i < list.count(); i++) 2609 for (int i=0; (uint) i < list.count(); i++)
2607 { 2610 {
2608 if (list.at(i)->type&KateDocument::Bookmark) 2611 if (list.at(i)->type&KateDocument::Bookmark)
2609 { 2612 {
2610 QString bText = textLine(list.at(i)->line); 2613 QString bText = textLine(list.at(i)->line);
2611 bText.truncate(32); 2614 bText.truncate(32);
2612 bText.append ("..."); 2615 bText.append ("...");
2613 bookmarkMenu->popupMenu()->insertItem ( QString("%1 - \"%2\"").arg(list.at(i)->line).arg(bText), this, SLOT (gotoBookmark(int)), 0, i ); 2616 bookmarkMenu->popupMenu()->insertItem ( QString("%1 - \"%2\"").arg(list.at(i)->line).arg(bText), this, SLOT (gotoBookmark(int)), 0, i );
2614 } 2617 }
2615 } 2618 }
2616#endif 2619#endif
2617} 2620}
2618 2621
2619void KateView::gotoBookmark (int n) 2622void KateView::gotoBookmark (int n)
2620{ 2623{
2621 gotoMark (list.at(n)); 2624 gotoMark (list.at(n));
2622} 2625}
2623 2626
2624int KateView::getHlCount () 2627int KateView::getHlCount ()
2625{ 2628{
2626 return HlManager::self()->highlights(); 2629 return HlManager::self()->highlights();
2627} 2630}
2628 2631
2629QString KateView::getHlName (int z) 2632QString KateView::getHlName (int z)
2630{ 2633{
2631 return HlManager::self()->hlName(z); 2634 return HlManager::self()->hlName(z);
2632} 2635}
2633 2636
2634QString KateView::getHlSection (int z) 2637QString KateView::getHlSection (int z)
2635{ 2638{
2636 return HlManager::self()->hlSection (z); 2639 return HlManager::self()->hlSection (z);
2637} 2640}
2638 2641
2639void KateView::slotIncFontSizes () 2642void KateView::slotIncFontSizes ()
2640{ 2643{
2641 QFont font = myDoc->getFont(); 2644 QFont font = myDoc->getFont();
2642 font.setPointSize (font.pointSize()+2); 2645 font.setPointSize (font.pointSize()+2);
2643 myDoc->setFont (font); 2646 myDoc->setFont (font);
2644} 2647}
2645 2648
2646void KateView::slotDecFontSizes () 2649void KateView::slotDecFontSizes ()
2647{ 2650{
2648 QFont font = myDoc->getFont(); 2651 QFont font = myDoc->getFont();
2649 font.setPointSize (font.pointSize()-2); 2652 font.setPointSize (font.pointSize()-2);
2650 myDoc->setFont (font); 2653 myDoc->setFont (font);
2651} 2654}
2652 2655
2653const char*bookmark_xpm[]={ 2656const char*bookmark_xpm[]={
2654"12 16 4 1", 2657"12 16 4 1",
2655"b c #808080", 2658"b c #808080",
2656"a c #000080", 2659"a c #000080",
2657"# c #0000ff", 2660"# c #0000ff",
2658". c None", 2661". c None",
2659"............", 2662"............",
2660"............", 2663"............",
2661"........###.", 2664"........###.",
2662".......#...a", 2665".......#...a",
2663"......#.##.a", 2666"......#.##.a",
2664".....#.#..aa", 2667".....#.#..aa",
2665"....#.#...a.", 2668"....#.#...a.",
2666"...#.#.a.a..", 2669"...#.#.a.a..",
2667"..#.#.a.a...", 2670"..#.#.a.a...",
2668".#.#.a.a....", 2671".#.#.a.a....",
2669"#.#.a.a.....", 2672"#.#.a.a.....",
2670"#.#a.a...bbb", 2673"#.#a.a...bbb",
2671"#...a..bbb..", 2674"#...a..bbb..",
2672".aaa.bbb....", 2675".aaa.bbb....",
2673"............", 2676"............",
2674"............"}; 2677"............"};
2675 2678
2676const char* breakpoint_xpm[]={ 2679const char* breakpoint_xpm[]={
2677"11 16 6 1", 2680"11 16 6 1",
2678"c c #c6c6c6", 2681"c c #c6c6c6",
2679". c None", 2682". c None",
2680"# c #000000", 2683"# c #000000",
2681"d c #840000", 2684"d c #840000",
2682"a c #ffffff", 2685"a c #ffffff",
2683"b c #ff0000", 2686"b c #ff0000",
2684"...........", 2687"...........",
2685"...........", 2688"...........",
2686"...#####...", 2689"...#####...",
2687"..#aaaaa#..", 2690"..#aaaaa#..",
2688".#abbbbbb#.", 2691".#abbbbbb#.",
2689"#abbbbbbbb#", 2692"#abbbbbbbb#",
2690"#abcacacbd#", 2693"#abcacacbd#",
2691"#abbbbbbbb#", 2694"#abbbbbbbb#",
2692"#abcacacbd#", 2695"#abcacacbd#",
2693"#abbbbbbbb#", 2696"#abbbbbbbb#",
2694".#bbbbbbb#.", 2697".#bbbbbbb#.",
2695"..#bdbdb#..", 2698"..#bdbdb#..",
2696"...#####...", 2699"...#####...",
2697"...........", 2700"...........",
2698"...........", 2701"...........",
2699"..........."}; 2702"..........."};
2700 2703
2701const char*breakpoint_bl_xpm[]={ 2704const char*breakpoint_bl_xpm[]={
2702"11 16 7 1", 2705"11 16 7 1",
2703"a c #c0c0ff", 2706"a c #c0c0ff",
2704"# c #000000", 2707"# c #000000",
2705"c c #0000c0", 2708"c c #0000c0",
2706"e c #0000ff", 2709"e c #0000ff",
2707"b c #dcdcdc", 2710"b c #dcdcdc",
2708"d c #ffffff", 2711"d c #ffffff",
2709". c None", 2712". c None",
2710"...........", 2713"...........",
2711"...........", 2714"...........",
2712"...#####...", 2715"...#####...",
2713"..#ababa#..", 2716"..#ababa#..",
2714".#bcccccc#.", 2717".#bcccccc#.",
2715"#acccccccc#", 2718"#acccccccc#",
2716"#bcadadace#", 2719"#bcadadace#",
2717"#acccccccc#", 2720"#acccccccc#",
2718"#bcadadace#", 2721"#bcadadace#",
2719"#acccccccc#", 2722"#acccccccc#",
2720".#ccccccc#.", 2723".#ccccccc#.",
2721"..#cecec#..", 2724"..#cecec#..",
2722"...#####...", 2725"...#####...",