-rw-r--r-- | noncore/apps/tinykate/libkate/view/kateview.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/noncore/apps/tinykate/libkate/view/kateview.cpp b/noncore/apps/tinykate/libkate/view/kateview.cpp index c5673a5..b9ebb1a 100644 --- a/noncore/apps/tinykate/libkate/view/kateview.cpp +++ b/noncore/apps/tinykate/libkate/view/kateview.cpp | |||
@@ -2153,385 +2153,386 @@ void KateView::exposeFound(PointStruc &cursor, int slen, int flags, bool replace | |||
2153 | y1 = myDoc->fontHeight*cursor.y -10; | 2153 | y1 = myDoc->fontHeight*cursor.y -10; |
2154 | y2 = y1 + myDoc->fontHeight +30; | 2154 | y2 = y1 + myDoc->fontHeight +30; |
2155 | 2155 | ||
2156 | xPos = myViewInternal->xPos; | 2156 | xPos = myViewInternal->xPos; |
2157 | yPos = myViewInternal->yPos; | 2157 | yPos = myViewInternal->yPos; |
2158 | 2158 | ||
2159 | if (x1 < 0) x1 = 0; | 2159 | if (x1 < 0) x1 = 0; |
2160 | if (replace) y2 += 90; | 2160 | if (replace) y2 += 90; |
2161 | 2161 | ||
2162 | if (x1 < xPos || x2 > xPos + myViewInternal->width()) { | 2162 | if (x1 < xPos || x2 > xPos + myViewInternal->width()) { |
2163 | xPos = x2 - myViewInternal->width(); | 2163 | xPos = x2 - myViewInternal->width(); |
2164 | } | 2164 | } |
2165 | if (y1 < yPos || y2 > yPos + myViewInternal->height()) { | 2165 | if (y1 < yPos || y2 > yPos + myViewInternal->height()) { |
2166 | xPos = x2 - myViewInternal->width(); | 2166 | xPos = x2 - myViewInternal->width(); |
2167 | yPos = myDoc->fontHeight*cursor.y - height()/3; | 2167 | yPos = myDoc->fontHeight*cursor.y - height()/3; |
2168 | } | 2168 | } |
2169 | myViewInternal->setPos(xPos, yPos); | 2169 | myViewInternal->setPos(xPos, yPos); |
2170 | myViewInternal->updateView(flags);// | ufPos,xPos,yPos); | 2170 | myViewInternal->updateView(flags);// | ufPos,xPos,yPos); |
2171 | myDoc->updateViews(this); | 2171 | myDoc->updateViews(this); |
2172 | } | 2172 | } |
2173 | 2173 | ||
2174 | void KateView::deleteReplacePrompt() { | 2174 | void KateView::deleteReplacePrompt() { |
2175 | myDoc->setPseudoModal(0L); | 2175 | myDoc->setPseudoModal(0L); |
2176 | } | 2176 | } |
2177 | 2177 | ||
2178 | bool KateView::askReplaceEnd() { | 2178 | bool KateView::askReplaceEnd() { |
2179 | QString str; | 2179 | QString str; |
2180 | int query; | 2180 | int query; |
2181 | 2181 | ||
2182 | myDoc->updateViews(); | 2182 | myDoc->updateViews(); |
2183 | if (s.flags & KateView::sfFinished) { | 2183 | if (s.flags & KateView::sfFinished) { |
2184 | // replace finished | 2184 | // replace finished |
2185 | str = i18n("%1 replacement(s) made").arg(replaces); | 2185 | str = i18n("%1 replacement(s) made").arg(replaces); |
2186 | KMessageBox::information(this, str, i18n("Replace")); | 2186 | KMessageBox::information(this, str, i18n("Replace")); |
2187 | return true; | 2187 | return true; |
2188 | } | 2188 | } |
2189 | 2189 | ||
2190 | // ask for continue | 2190 | // ask for continue |
2191 | if (!(s.flags & KateView::sfBackward)) { | 2191 | if (!(s.flags & KateView::sfBackward)) { |
2192 | // forward search | 2192 | // forward search |
2193 | str = i18n("%1 replacement(s) made.\n" | 2193 | str = i18n("%1 replacement(s) made.\n" |
2194 | "End of document reached.\n" | 2194 | "End of document reached.\n" |
2195 | "Continue from the beginning?").arg(replaces); | 2195 | "Continue from the beginning?").arg(replaces); |
2196 | query = KMessageBox::questionYesNo(this, str, i18n("Replace"), | 2196 | query = KMessageBox::questionYesNo(this, str, i18n("Replace"), |
2197 | i18n("Continue"), i18n("Stop")); | 2197 | i18n("Continue"), i18n("Stop")); |
2198 | } else { | 2198 | } else { |
2199 | // backward search | 2199 | // backward search |
2200 | str = i18n("%1 replacement(s) made.\n" | 2200 | str = i18n("%1 replacement(s) made.\n" |
2201 | "Beginning of document reached.\n" | 2201 | "Beginning of document reached.\n" |
2202 | "Continue from the end?").arg(replaces); | 2202 | "Continue from the end?").arg(replaces); |
2203 | query = KMessageBox::questionYesNo(this, str, i18n("Replace"), | 2203 | query = KMessageBox::questionYesNo(this, str, i18n("Replace"), |
2204 | i18n("Continue"), i18n("Stop")); | 2204 | i18n("Continue"), i18n("Stop")); |
2205 | } | 2205 | } |
2206 | replaces = 0; | 2206 | replaces = 0; |
2207 | continueSearch(s); | 2207 | continueSearch(s); |
2208 | return (query == KMessageBox::No); | 2208 | return (query == KMessageBox::No); |
2209 | } | 2209 | } |
2210 | 2210 | ||
2211 | void KateView::replaceSlot() { | 2211 | void KateView::replaceSlot() { |
2212 | doReplaceAction(replacePrompt->result(),true); | 2212 | doReplaceAction(replacePrompt->result(),true); |
2213 | } | 2213 | } |
2214 | 2214 | ||
2215 | void KateView::installPopup(QPopupMenu *rmb_Menu) | 2215 | void KateView::installPopup(QPopupMenu *rmb_Menu) |
2216 | { | 2216 | { |
2217 | rmbMenu = rmb_Menu; | 2217 | rmbMenu = rmb_Menu; |
2218 | } | 2218 | } |
2219 | 2219 | ||
2220 | void KateView::readConfig() | 2220 | void KateView::readConfig() |
2221 | { | 2221 | { |
2222 | KateConfig *config = KGlobal::config(); | 2222 | KateConfig *config = KGlobal::config(); |
2223 | config->setGroup("Kate View"); | 2223 | config->setGroup("Kate View"); |
2224 | 2224 | ||
2225 | searchFlags = config->readNumEntry("SearchFlags", KateView::sfPrompt); | 2225 | searchFlags = config->readNumEntry("SearchFlags", KateView::sfPrompt); |
2226 | configFlags = config->readNumEntry("ConfigFlags", configFlags) & ~KateView::cfMark; | 2226 | configFlags = config->readNumEntry("ConfigFlags", configFlags) & ~KateView::cfMark; |
2227 | 2227 | ||
2228 | // config->sync(); | 2228 | // config->sync(); |
2229 | } | 2229 | } |
2230 | 2230 | ||
2231 | void KateView::writeConfig() | 2231 | void KateView::writeConfig() |
2232 | { | 2232 | { |
2233 | KateConfig *config = KGlobal::config(); | 2233 | KateConfig *config = KGlobal::config(); |
2234 | config->setGroup("Kate View"); | 2234 | config->setGroup("Kate View"); |
2235 | 2235 | ||
2236 | config->writeEntry("SearchFlags",searchFlags); | 2236 | config->writeEntry("SearchFlags",searchFlags); |
2237 | config->writeEntry("ConfigFlags",configFlags); | 2237 | config->writeEntry("ConfigFlags",configFlags); |
2238 | 2238 | ||
2239 | // config->sync(); | 2239 | // config->sync(); |
2240 | } | 2240 | } |
2241 | 2241 | ||
2242 | void KateView::readSessionConfig(KateConfig *config) | 2242 | void KateView::readSessionConfig(KateConfig *config) |
2243 | { | 2243 | { |
2244 | PointStruc cursor; | 2244 | PointStruc cursor; |
2245 | 2245 | ||
2246 | myViewInternal->xPos = config->readNumEntry("XPos"); | 2246 | myViewInternal->xPos = config->readNumEntry("XPos"); |
2247 | myViewInternal->yPos = config->readNumEntry("YPos"); | 2247 | myViewInternal->yPos = config->readNumEntry("YPos"); |
2248 | cursor.x = config->readNumEntry("CursorX"); | 2248 | cursor.x = config->readNumEntry("CursorX"); |
2249 | cursor.y = config->readNumEntry("CursorY"); | 2249 | cursor.y = config->readNumEntry("CursorY"); |
2250 | myViewInternal->updateCursor(cursor); | 2250 | myViewInternal->updateCursor(cursor); |
2251 | myIconBorder = config->readBoolEntry("IconBorder on"); | 2251 | myIconBorder = config->readBoolEntry("IconBorder on"); |
2252 | setIconBorder(myIconBorder); | 2252 | setIconBorder(myIconBorder); |
2253 | } | 2253 | } |
2254 | 2254 | ||
2255 | void KateView::writeSessionConfig(KateConfig *config) | 2255 | void KateView::writeSessionConfig(KateConfig *config) |
2256 | { | 2256 | { |
2257 | config->writeEntry("XPos",myViewInternal->xPos); | 2257 | config->writeEntry("XPos",myViewInternal->xPos); |
2258 | config->writeEntry("YPos",myViewInternal->yPos); | 2258 | config->writeEntry("YPos",myViewInternal->yPos); |
2259 | config->writeEntry("CursorX",myViewInternal->cursor.x); | 2259 | config->writeEntry("CursorX",myViewInternal->cursor.x); |
2260 | config->writeEntry("CursorY",myViewInternal->cursor.y); | 2260 | config->writeEntry("CursorY",myViewInternal->cursor.y); |
2261 | config->writeEntry("IconBorder on", myIconBorder); | 2261 | config->writeEntry("IconBorder on", myIconBorder); |
2262 | } | 2262 | } |
2263 | 2263 | ||
2264 | void KateView::configDialog() | 2264 | void KateView::configDialog() |
2265 | { | 2265 | { |
2266 | 2266 | ||
2267 | #warning fixme | 2267 | #warning fixme |
2268 | 2268 | ||
2269 | #if 1 | 2269 | #if 1 |
2270 | KDialogBase *kd = new KDialogBase(KDialogBase::IconList, | 2270 | KDialogBase *kd = new KDialogBase(KDialogBase::IconList, |
2271 | i18n("Configure Editor"), | 2271 | i18n("Configure Editor"), |
2272 | KDialogBase::Ok | KDialogBase::Cancel | | 2272 | KDialogBase::Ok | KDialogBase::Cancel | |
2273 | KDialogBase::Help , | 2273 | KDialogBase::Help , |
2274 | KDialogBase::Ok, this, "tabdialog"); | 2274 | KDialogBase::Ok, this, "tabdialog"); |
2275 | 2275 | ||
2276 | // color options | 2276 | // color options |
2277 | QFrame *page=kd->addPage(i18n("Colors")); | 2277 | QFrame *page=kd->addPage(i18n("Colors")); |
2278 | (new QVBoxLayout(page))->setAutoAdd(true); | 2278 | (new QVBoxLayout(page))->setAutoAdd(true); |
2279 | ColorConfig *colorConfig = new ColorConfig(page); | 2279 | ColorConfig *colorConfig = new ColorConfig(page); |
2280 | QColor* colors = getColors(); | 2280 | QColor* colors = getColors(); |
2281 | colorConfig->setColors(colors); | 2281 | colorConfig->setColors(colors); |
2282 | 2282 | ||
2283 | page = kd->addPage(i18n("Fonts")); | 2283 | page = kd->addPage(i18n("Fonts")); |
2284 | (new QVBoxLayout(page))->setAutoAdd(true); | 2284 | (new QVBoxLayout(page))->setAutoAdd(true); |
2285 | 2285 | ||
2286 | FontConfig *fontConfig = new FontConfig(page); | 2286 | FontConfig *fontConfig = new FontConfig(page); |
2287 | fontConfig->setFont (myDoc->getFont()); | 2287 | fontConfig->setFont (myDoc->getFont()); |
2288 | 2288 | ||
2289 | // indent options | 2289 | // indent options |
2290 | page=kd->addPage(i18n("Indent")); | 2290 | page=kd->addPage(i18n("Indent")); |
2291 | (new QVBoxLayout(page))->setAutoAdd(true); | 2291 | (new QVBoxLayout(page))->setAutoAdd(true); |
2292 | 2292 | ||
2293 | IndentConfigTab *indentConfig = new IndentConfigTab(page, this); | 2293 | IndentConfigTab *indentConfig = new IndentConfigTab(page, this); |
2294 | 2294 | ||
2295 | // select options | 2295 | // select options |
2296 | page=kd->addPage(i18n("Select")); | 2296 | page=kd->addPage(i18n("Select")); |
2297 | (new QVBoxLayout(page))->setAutoAdd(true); | 2297 | (new QVBoxLayout(page))->setAutoAdd(true); |
2298 | 2298 | ||
2299 | SelectConfigTab *selectConfig = new SelectConfigTab(page, this); | 2299 | SelectConfigTab *selectConfig = new SelectConfigTab(page, this); |
2300 | 2300 | ||
2301 | // edit options | 2301 | // edit options |
2302 | page=kd->addPage(i18n("Edit")); | 2302 | page=kd->addPage(i18n("Edit")); |
2303 | (new QVBoxLayout(page))->setAutoAdd(true); | 2303 | (new QVBoxLayout(page))->setAutoAdd(true); |
2304 | 2304 | ||
2305 | EditConfigTab *editConfig = new EditConfigTab(page, this); | 2305 | EditConfigTab *editConfig = new EditConfigTab(page, this); |
2306 | 2306 | ||
2307 | 2307 | ||
2308 | 2308 | ||
2309 | HighlightDialogPage *hlPage; | 2309 | HighlightDialogPage *hlPage; |
2310 | HlManager *hlManager; | 2310 | HlManager *hlManager; |
2311 | HlDataList hlDataList; | 2311 | HlDataList hlDataList; |
2312 | ItemStyleList defaultStyleList; | 2312 | ItemStyleList defaultStyleList; |
2313 | 2313 | ||
2314 | hlManager = HlManager::self(); | 2314 | hlManager = HlManager::self(); |
2315 | 2315 | ||
2316 | defaultStyleList.setAutoDelete(true); | 2316 | defaultStyleList.setAutoDelete(true); |
2317 | hlManager->getDefaults(defaultStyleList); | 2317 | hlManager->getDefaults(defaultStyleList); |
2318 | 2318 | ||
2319 | hlDataList.setAutoDelete(true); | 2319 | hlDataList.setAutoDelete(true); |
2320 | //this gets the data from the KateConfig object | 2320 | //this gets the data from the KateConfig object |
2321 | hlManager->getHlDataList(hlDataList); | 2321 | hlManager->getHlDataList(hlDataList); |
2322 | 2322 | ||
2323 | page=kd->addPage(i18n("Highlighting")); | 2323 | page=kd->addPage(i18n("Highlighting")); |
2324 | (new QVBoxLayout(page))->setAutoAdd(true); | 2324 | (new QVBoxLayout(page))->setAutoAdd(true); |
2325 | 2325 | ||
2326 | hlPage = new HighlightDialogPage(hlManager, &defaultStyleList, &hlDataList, 0, page); | 2326 | hlPage = new HighlightDialogPage(hlManager, &defaultStyleList, &hlDataList, 0, page); |
2327 | if ( QPEApplication::execDialog( kd )) { | 2327 | if ( QPEApplication::execDialog( kd )) { |
2328 | // color options | 2328 | // color options |
2329 | colorConfig->getColors(colors); | 2329 | colorConfig->getColors(colors); |
2330 | myDoc->setFont (fontConfig->getFont()); | 2330 | myDoc->setFont (fontConfig->getFont()); |
2331 | 2331 | ||
2332 | applyColors(); | 2332 | applyColors(); |
2333 | // indent options | 2333 | // indent options |
2334 | indentConfig->getData(this); | 2334 | indentConfig->getData(this); |
2335 | // select options | 2335 | // select options |
2336 | selectConfig->getData(this); | 2336 | selectConfig->getData(this); |
2337 | // edit options | 2337 | // edit options |
2338 | editConfig->getData(this); | 2338 | editConfig->getData(this); |
2339 | // spell checker | 2339 | // spell checker |
2340 | hlManager->setHlDataList(hlDataList); | 2340 | hlManager->setHlDataList(hlDataList); |
2341 | hlManager->setDefaults(defaultStyleList); | 2341 | hlManager->setDefaults(defaultStyleList); |
2342 | hlPage->saveData(); | 2342 | hlPage->saveData(); |
2343 | } | 2343 | } |
2344 | 2344 | ||
2345 | // delete kd; | 2345 | qApp->processEvents(); |
2346 | delete kd; | ||
2346 | 2347 | ||
2347 | #endif | 2348 | #endif |
2348 | } | 2349 | } |
2349 | 2350 | ||
2350 | int KateView::getHl() { | 2351 | int KateView::getHl() { |
2351 | return myDoc->highlightNum(); | 2352 | return myDoc->highlightNum(); |
2352 | } | 2353 | } |
2353 | 2354 | ||
2354 | void KateView::setDontChangeHlOnSave() | 2355 | void KateView::setDontChangeHlOnSave() |
2355 | { | 2356 | { |
2356 | myDoc->setDontChangeHlOnSave(); | 2357 | myDoc->setDontChangeHlOnSave(); |
2357 | } | 2358 | } |
2358 | 2359 | ||
2359 | void KateView::setHl(int n) { | 2360 | void KateView::setHl(int n) { |
2360 | myDoc->setHighlight(n); | 2361 | myDoc->setHighlight(n); |
2361 | myDoc->setDontChangeHlOnSave(); | 2362 | myDoc->setDontChangeHlOnSave(); |
2362 | myDoc->updateViews(); | 2363 | myDoc->updateViews(); |
2363 | } | 2364 | } |
2364 | 2365 | ||
2365 | int KateView::getEol() { | 2366 | int KateView::getEol() { |
2366 | return myDoc->eolMode; | 2367 | return myDoc->eolMode; |
2367 | } | 2368 | } |
2368 | 2369 | ||
2369 | void KateView::setEol(int eol) { | 2370 | void KateView::setEol(int eol) { |
2370 | if (isReadOnly()) | 2371 | if (isReadOnly()) |
2371 | return; | 2372 | return; |
2372 | 2373 | ||
2373 | myDoc->eolMode = eol; | 2374 | myDoc->eolMode = eol; |
2374 | myDoc->setModified(true); | 2375 | myDoc->setModified(true); |
2375 | } | 2376 | } |
2376 | 2377 | ||
2377 | 2378 | ||
2378 | 2379 | ||
2379 | void KateView::paintEvent(QPaintEvent *e) { | 2380 | void KateView::paintEvent(QPaintEvent *e) { |
2380 | int x, y; | 2381 | int x, y; |
2381 | 2382 | ||
2382 | QRect updateR = e->rect(); // update rectangle | 2383 | QRect updateR = e->rect(); // update rectangle |
2383 | // debug("Update rect = ( %i, %i, %i, %i )", | 2384 | // debug("Update rect = ( %i, %i, %i, %i )", |
2384 | // updateR.x(),updateR.y(), updateR.width(), updateR.height() ); | 2385 | // updateR.x(),updateR.y(), updateR.width(), updateR.height() ); |
2385 | 2386 | ||
2386 | int ux1 = updateR.x(); | 2387 | int ux1 = updateR.x(); |
2387 | int uy1 = updateR.y(); | 2388 | int uy1 = updateR.y(); |
2388 | int ux2 = ux1 + updateR.width(); | 2389 | int ux2 = ux1 + updateR.width(); |
2389 | int uy2 = uy1 + updateR.height(); | 2390 | int uy2 = uy1 + updateR.height(); |
2390 | 2391 | ||
2391 | QPainter paint; | 2392 | QPainter paint; |
2392 | paint.begin(this); | 2393 | paint.begin(this); |
2393 | 2394 | ||
2394 | QColorGroup g = colorGroup(); | 2395 | QColorGroup g = colorGroup(); |
2395 | x = width(); | 2396 | x = width(); |
2396 | y = height(); | 2397 | y = height(); |
2397 | 2398 | ||
2398 | paint.setPen(g.dark()); | 2399 | paint.setPen(g.dark()); |
2399 | if (uy1 <= 0) paint.drawLine(0,0,x-2,0); | 2400 | if (uy1 <= 0) paint.drawLine(0,0,x-2,0); |
2400 | if (ux1 <= 0) paint.drawLine(0,1,0,y-2); | 2401 | if (ux1 <= 0) paint.drawLine(0,1,0,y-2); |
2401 | 2402 | ||
2402 | paint.setPen(black); | 2403 | paint.setPen(black); |
2403 | if (uy1 <= 1) paint.drawLine(1,1,x-3,1); | 2404 | if (uy1 <= 1) paint.drawLine(1,1,x-3,1); |
2404 | if (ux1 <= 1) paint.drawLine(1,2,1,y-3); | 2405 | if (ux1 <= 1) paint.drawLine(1,2,1,y-3); |
2405 | 2406 | ||
2406 | paint.setPen(g.midlight()); | 2407 | paint.setPen(g.midlight()); |
2407 | if (uy2 >= y-1) paint.drawLine(1,y-2,x-3,y-2); | 2408 | if (uy2 >= y-1) paint.drawLine(1,y-2,x-3,y-2); |
2408 | if (ux2 >= x-1) paint.drawLine(x-2,1,x-2,y-2); | 2409 | if (ux2 >= x-1) paint.drawLine(x-2,1,x-2,y-2); |
2409 | 2410 | ||
2410 | paint.setPen(g.light()); | 2411 | paint.setPen(g.light()); |
2411 | if (uy2 >= y) paint.drawLine(0,y-1,x-2,y-1); | 2412 | if (uy2 >= y) paint.drawLine(0,y-1,x-2,y-1); |
2412 | if (ux2 >= x) paint.drawLine(x-1,0,x-1,y-1); | 2413 | if (ux2 >= x) paint.drawLine(x-1,0,x-1,y-1); |
2413 | 2414 | ||
2414 | x -= 2 + 16; | 2415 | x -= 2 + 16; |
2415 | y -= 2 + 16; | 2416 | y -= 2 + 16; |
2416 | if (ux2 > x && uy2 > y) { | 2417 | if (ux2 > x && uy2 > y) { |
2417 | paint.fillRect(x,y,16,16,g.background()); | 2418 | paint.fillRect(x,y,16,16,g.background()); |
2418 | } | 2419 | } |
2419 | paint.end(); | 2420 | paint.end(); |
2420 | } | 2421 | } |
2421 | 2422 | ||
2422 | void KateView::resizeEvent(QResizeEvent *) { | 2423 | void KateView::resizeEvent(QResizeEvent *) { |
2423 | 2424 | ||
2424 | // debug("Resize %d, %d",e->size().width(),e->size().height()); | 2425 | // debug("Resize %d, %d",e->size().width(),e->size().height()); |
2425 | 2426 | ||
2426 | //myViewInternal->resize(width() -20, height() -20); | 2427 | //myViewInternal->resize(width() -20, height() -20); |
2427 | myViewInternal->tagAll(); | 2428 | myViewInternal->tagAll(); |
2428 | myViewInternal->updateView(0/*ufNoScroll*/); | 2429 | myViewInternal->updateView(0/*ufNoScroll*/); |
2429 | } | 2430 | } |
2430 | 2431 | ||
2431 | 2432 | ||
2432 | // Applies a new pattern to the search context. | 2433 | // Applies a new pattern to the search context. |
2433 | void SConfig::setPattern(QString &newPattern) { | 2434 | void SConfig::setPattern(QString &newPattern) { |
2434 | bool regExp = (flags & KateView::sfRegularExpression); | 2435 | bool regExp = (flags & KateView::sfRegularExpression); |
2435 | 2436 | ||
2436 | m_pattern = newPattern; | 2437 | m_pattern = newPattern; |
2437 | if (regExp) { | 2438 | if (regExp) { |
2438 | m_regExp.setCaseSensitive(flags & KateView::sfCaseSensitive); | 2439 | m_regExp.setCaseSensitive(flags & KateView::sfCaseSensitive); |
2439 | m_regExp.setPattern(m_pattern); | 2440 | m_regExp.setPattern(m_pattern); |
2440 | } | 2441 | } |
2441 | } | 2442 | } |
2442 | 2443 | ||
2443 | // Applies the search context to the given string, and returns whether a match was found. If one is, | 2444 | // Applies the search context to the given string, and returns whether a match was found. If one is, |
2444 | // the length of the string matched is also returned. | 2445 | // the length of the string matched is also returned. |
2445 | int SConfig::search(QString &text, int index) { | 2446 | int SConfig::search(QString &text, int index) { |
2446 | bool regExp = (flags & KateView::sfRegularExpression); | 2447 | bool regExp = (flags & KateView::sfRegularExpression); |
2447 | bool caseSensitive = (flags & KateView::sfCaseSensitive); | 2448 | bool caseSensitive = (flags & KateView::sfCaseSensitive); |
2448 | 2449 | ||
2449 | if (flags & KateView::sfBackward) { | 2450 | if (flags & KateView::sfBackward) { |
2450 | if (regExp) { | 2451 | if (regExp) { |
2451 | index = text.findRev(m_regExp, index); | 2452 | index = text.findRev(m_regExp, index); |
2452 | } | 2453 | } |
2453 | else { | 2454 | else { |
2454 | index = text.findRev(m_pattern, index, caseSensitive); | 2455 | index = text.findRev(m_pattern, index, caseSensitive); |
2455 | } | 2456 | } |
2456 | } | 2457 | } |
2457 | else { | 2458 | else { |
2458 | if (regExp) { | 2459 | if (regExp) { |
2459 | index = text.find(m_regExp, index); | 2460 | index = text.find(m_regExp, index); |
2460 | } | 2461 | } |
2461 | else { | 2462 | else { |
2462 | index = text.find(m_pattern, index, caseSensitive); | 2463 | index = text.find(m_pattern, index, caseSensitive); |
2463 | } | 2464 | } |
2464 | } | 2465 | } |
2465 | 2466 | ||
2466 | // Work out the matched length. | 2467 | // Work out the matched length. |
2467 | if (index != -1) | 2468 | if (index != -1) |
2468 | { | 2469 | { |
2469 | if (regExp) { | 2470 | if (regExp) { |
2470 | m_regExp.match(text, index, &matchedLength, false); | 2471 | m_regExp.match(text, index, &matchedLength, false); |
2471 | } | 2472 | } |
2472 | else { | 2473 | else { |
2473 | matchedLength = m_pattern.length(); | 2474 | matchedLength = m_pattern.length(); |
2474 | } | 2475 | } |
2475 | } | 2476 | } |
2476 | return index; | 2477 | return index; |
2477 | } | 2478 | } |
2478 | 2479 | ||
2479 | void KateView::setActive (bool b) | 2480 | void KateView::setActive (bool b) |
2480 | { | 2481 | { |
2481 | active = b; | 2482 | active = b; |
2482 | } | 2483 | } |
2483 | 2484 | ||
2484 | bool KateView::isActive () | 2485 | bool KateView::isActive () |
2485 | { | 2486 | { |
2486 | return active; | 2487 | return active; |
2487 | } | 2488 | } |
2488 | 2489 | ||
2489 | void KateView::setFocus () | 2490 | void KateView::setFocus () |
2490 | { | 2491 | { |
2491 | QWidget::setFocus (); | 2492 | QWidget::setFocus (); |
2492 | 2493 | ||
2493 | emit gotFocus (this); | 2494 | emit gotFocus (this); |
2494 | } | 2495 | } |
2495 | 2496 | ||
2496 | bool KateView::eventFilter (QObject *object, QEvent *event) | 2497 | bool KateView::eventFilter (QObject *object, QEvent *event) |
2497 | { | 2498 | { |
2498 | 2499 | ||
2499 | if ( (event->type() == QEvent::FocusIn) ) | 2500 | if ( (event->type() == QEvent::FocusIn) ) |
2500 | emit gotFocus (this); | 2501 | emit gotFocus (this); |
2501 | 2502 | ||
2502 | if ( (event->type() == QEvent::KeyPress) ) | 2503 | if ( (event->type() == QEvent::KeyPress) ) |
2503 | { | 2504 | { |
2504 | QKeyEvent * ke=(QKeyEvent *)event; | 2505 | QKeyEvent * ke=(QKeyEvent *)event; |
2505 | 2506 | ||
2506 | if ((ke->key()==Qt::Key_Tab) || (ke->key()==Qt::Key_BackTab)) | 2507 | if ((ke->key()==Qt::Key_Tab) || (ke->key()==Qt::Key_BackTab)) |
2507 | { | 2508 | { |
2508 | myViewInternal->keyPressEvent(ke); | 2509 | myViewInternal->keyPressEvent(ke); |
2509 | return true; | 2510 | return true; |
2510 | } | 2511 | } |
2511 | } | 2512 | } |
2512 | return QWidget::eventFilter (object, event); | 2513 | return QWidget::eventFilter (object, event); |
2513 | } | 2514 | } |
2514 | 2515 | ||
2515 | void KateView::findAgain (bool back) | 2516 | void KateView::findAgain (bool back) |
2516 | { | 2517 | { |
2517 | bool b= (searchFlags & sfBackward) > 0; | 2518 | bool b= (searchFlags & sfBackward) > 0; |
2518 | initSearch(s, (searchFlags & ((b==back)?~sfBackward:~0) & ~sfFromBeginning) // clear flag for forward searching | 2519 | initSearch(s, (searchFlags & ((b==back)?~sfBackward:~0) & ~sfFromBeginning) // clear flag for forward searching |
2519 | | sfPrompt | sfAgain | ((b!=back)?sfBackward:0) ); | 2520 | | sfPrompt | sfAgain | ((b!=back)?sfBackward:0) ); |
2520 | if (s.flags & sfReplace) | 2521 | if (s.flags & sfReplace) |
2521 | replaceAgain(); | 2522 | replaceAgain(); |
2522 | else | 2523 | else |
2523 | KateView::findAgain(s); | 2524 | KateView::findAgain(s); |
2524 | } | 2525 | } |
2525 | 2526 | ||
2526 | void KateView::slotEditCommand () | 2527 | void KateView::slotEditCommand () |
2527 | { | 2528 | { |
2528 | #warning fixme | 2529 | #warning fixme |
2529 | /* | 2530 | /* |
2530 | bool ok; | 2531 | bool ok; |
2531 | QString cmd = KLineEditDlg::getText("Editing Command", "", &ok, this); | 2532 | QString cmd = KLineEditDlg::getText("Editing Command", "", &ok, this); |
2532 | 2533 | ||
2533 | if (ok) | 2534 | if (ok) |
2534 | myDoc->cmd()->execCmd (cmd, this);*/ | 2535 | myDoc->cmd()->execCmd (cmd, this);*/ |
2535 | } | 2536 | } |
2536 | 2537 | ||
2537 | void KateView::setIconBorder (bool enable) | 2538 | void KateView::setIconBorder (bool enable) |