summaryrefslogtreecommitdiff
authorkergoth <kergoth>2003-01-28 03:23:14 (UTC)
committer kergoth <kergoth>2003-01-28 03:23:14 (UTC)
commitde1321a53998bc1d078f9492395c2a26392875ed (patch) (unidiff)
treeb36d59612da5bbafeaddd28cb88a222b699d2645
parent728a7a4966c342be32c80c045cbae500160fc17b (diff)
downloadopie-de1321a53998bc1d078f9492395c2a26392875ed.zip
opie-de1321a53998bc1d078f9492395c2a26392875ed.tar.gz
opie-de1321a53998bc1d078f9492395c2a26392875ed.tar.bz2
Added a Config derivative.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/tinykate/libkate/document/katedocument.cpp23
-rw-r--r--noncore/apps/tinykate/libkate/document/katedocument.h4
-rw-r--r--noncore/apps/tinykate/libkate/document/katehighlight.cpp36
-rw-r--r--noncore/apps/tinykate/libkate/document/katehighlight.h8
-rw-r--r--noncore/apps/tinykate/libkate/document/katesyntaxdocument.cpp12
-rw-r--r--noncore/apps/tinykate/libkate/interfaces/document.h6
-rw-r--r--noncore/apps/tinykate/libkate/interfaces/view.h6
-rw-r--r--noncore/apps/tinykate/libkate/kateconfig.cpp634
-rw-r--r--noncore/apps/tinykate/libkate/kateconfig.h117
-rw-r--r--noncore/apps/tinykate/libkate/libkate.pro9
-rw-r--r--noncore/apps/tinykate/libkate/microkde/kconfig.cpp181
-rw-r--r--noncore/apps/tinykate/libkate/microkde/kconfig.h51
-rw-r--r--noncore/apps/tinykate/libkate/microkde/kglobal.cpp6
-rw-r--r--noncore/apps/tinykate/libkate/microkde/kglobal.h6
-rw-r--r--noncore/apps/tinykate/libkate/view/kateview.cpp18
-rw-r--r--noncore/apps/tinykate/libkate/view/kateview.h9
-rw-r--r--noncore/apps/tinykate/tinykate.cpp10
-rw-r--r--noncore/apps/tinykate/tinykate.h3
-rw-r--r--noncore/apps/tinykate/tinykate.pro4
19 files changed, 835 insertions, 308 deletions
diff --git a/noncore/apps/tinykate/libkate/document/katedocument.cpp b/noncore/apps/tinykate/libkate/document/katedocument.cpp
index df1de8d..6807544 100644
--- a/noncore/apps/tinykate/libkate/document/katedocument.cpp
+++ b/noncore/apps/tinykate/libkate/document/katedocument.cpp
@@ -155,256 +155,257 @@ KateDocument::KateDocument(bool bSingleViewMode, bool bBrowserView,
155 155
156 // NOTE: QFont::CharSet doesn't provide all the charsets KDE supports 156 // NOTE: QFont::CharSet doesn't provide all the charsets KDE supports
157 // (esp. it doesn't distinguish between UTF-8 and iso10646-1) 157 // (esp. it doesn't distinguish between UTF-8 and iso10646-1)
158 158
159 myEncoding = QString::fromLatin1(QTextCodec::codecForLocale()->name()); 159 myEncoding = QString::fromLatin1(QTextCodec::codecForLocale()->name());
160 160
161 maxLength = -1; 161 maxLength = -1;
162 162
163 setFont (KGlobalSettings::generalFont()); 163 setFont (KGlobalSettings::generalFont());
164 164
165 myDocID = uniqueID; 165 myDocID = uniqueID;
166 uniqueID++; 166 uniqueID++;
167 167
168 myDocName = QString (""); 168 myDocName = QString ("");
169 fileInfo = new QFileInfo (); 169 fileInfo = new QFileInfo ();
170 170
171 myCmd = new KateCmd (this); 171 myCmd = new KateCmd (this);
172 172
173 connect(this,SIGNAL(modifiedChanged ()),this,SLOT(slotModChanged ())); 173 connect(this,SIGNAL(modifiedChanged ()),this,SLOT(slotModChanged ()));
174 174
175 buffer = new KWBuffer; 175 buffer = new KWBuffer;
176 connect(buffer, SIGNAL(linesChanged(int)), this, SLOT(slotBufferChanged())); 176 connect(buffer, SIGNAL(linesChanged(int)), this, SLOT(slotBufferChanged()));
177// connect(buffer, SIGNAL(textChanged()), this, SIGNAL(textChanged())); 177// connect(buffer, SIGNAL(textChanged()), this, SIGNAL(textChanged()));
178 connect(buffer, SIGNAL(needHighlight(long,long)),this,SLOT(slotBufferHighlight(long,long))); 178 connect(buffer, SIGNAL(needHighlight(long,long)),this,SLOT(slotBufferHighlight(long,long)));
179 179
180 colors[0] = KGlobalSettings::baseColor(); 180 colors[0] = KGlobalSettings::baseColor();
181 colors[1] = KGlobalSettings::highlightColor(); 181 colors[1] = KGlobalSettings::highlightColor();
182 182
183 m_attribs = new Attribute[maxAttribs]; 183 m_attribs = new Attribute[maxAttribs];
184 184
185 m_highlight = 0L; 185 m_highlight = 0L;
186 tabChars = 8; 186 tabChars = 8;
187 187
188 m_singleSelection = false; 188 m_singleSelection = false;
189 189
190 newDocGeometry = false; 190 newDocGeometry = false;
191 readOnly = false; 191 readOnly = false;
192 newDoc = false; 192 newDoc = false;
193 193
194 modified = false; 194 modified = false;
195 195
196 undoList.setAutoDelete(true); 196 undoList.setAutoDelete(true);
197 undoState = 0; 197 undoState = 0;
198 undoSteps = 50; 198 undoSteps = 50;
199 199
200 pseudoModal = 0L; 200 pseudoModal = 0L;
201 clear(); 201 clear();
202 202
203 setHighlight(0); //calls updateFontData() 203 setHighlight(0); //calls updateFontData()
204 // if the user changes the highlight with the dialog, notify the doc 204 // if the user changes the highlight with the dialog, notify the doc
205 connect(hlManager,SIGNAL(changed()),SLOT(hlChanged())); 205 connect(hlManager,SIGNAL(changed()),SLOT(hlChanged()));
206 206
207 newDocGeometry = false; 207 newDocGeometry = false;
208 208
209 readConfig(); 209 readConfig();
210 210
211 setReadOnly(false); 211 setReadOnly(false);
212} 212}
213 213
214void KateDocument::setDontChangeHlOnSave() 214void KateDocument::setDontChangeHlOnSave()
215{ 215{
216 d(this)->hlSetByUser = true; 216 d(this)->hlSetByUser = true;
217} 217}
218 218
219void KateDocument::setFont (QFont font) 219void KateDocument::setFont (QFont font)
220{ 220{
221 kdDebug()<<"Kate:: setFont"<<endl; 221 kdDebug()<<"Kate:: setFont"<<endl;
222 int oldwidth=myFontMetrics.width('W'); //Quick & Dirty Hack (by JoWenn) //Remove in KDE 3.0 222 int oldwidth=myFontMetrics.width('W'); //Quick & Dirty Hack (by JoWenn) //Remove in KDE 3.0
223 myFont = font; 223 myFont = font;
224 myFontBold = QFont (font); 224 myFontBold = QFont (font);
225 myFontBold.setBold (true); 225 myFontBold.setBold (true);
226 226
227 myFontItalic = QFont (font); 227 myFontItalic = QFont (font);
228 myFontItalic.setItalic (true); 228 myFontItalic.setItalic (true);
229 229
230 myFontBI = QFont (font); 230 myFontBI = QFont (font);
231 myFontBI.setBold (true); 231 myFontBI.setBold (true);
232 myFontBI.setItalic (true); 232 myFontBI.setItalic (true);
233 233
234 myFontMetrics = CachedFontMetrics (myFont); 234 myFontMetrics = CachedFontMetrics (myFont);
235 myFontMetricsBold = CachedFontMetrics (myFontBold); 235 myFontMetricsBold = CachedFontMetrics (myFontBold);
236 myFontMetricsItalic = CachedFontMetrics (myFontItalic); 236 myFontMetricsItalic = CachedFontMetrics (myFontItalic);
237 myFontMetricsBI = CachedFontMetrics (myFontBI); 237 myFontMetricsBI = CachedFontMetrics (myFontBI);
238 int newwidth=myFontMetrics.width('W'); //Quick & Dirty Hack (by JoWenn) //Remove in KDE 3.0 238 int newwidth=myFontMetrics.width('W'); //Quick & Dirty Hack (by JoWenn) //Remove in KDE 3.0
239 maxLength=maxLength*(float)newwidth/(float)oldwidth; //Quick & Dirty Hack (by JoWenn) //Remove in KDE 3.0 239 maxLength=maxLength*(float)newwidth/(float)oldwidth; //Quick & Dirty Hack (by JoWenn) //Remove in KDE 3.0
240 240
241 updateFontData(); 241 updateFontData();
242 updateViews(); //Quick & Dirty Hack (by JoWenn) //Remove in KDE 3.0 242 updateViews(); //Quick & Dirty Hack (by JoWenn) //Remove in KDE 3.0
243 243
244} 244}
245 245
246long KateDocument::needPreHighlight(long till) 246long KateDocument::needPreHighlight(long till)
247{ 247{
248 int max=numLines()-1; 248 int max=numLines()-1;
249 if (till>max) 249 if (till>max)
250 { 250 {
251 till=max; 251 till=max;
252 } 252 }
253 if (PreHighlightedTill>=till) return -1; 253 if (PreHighlightedTill>=till) return -1;
254 254
255 long tmp=RequestPreHighlightTill; 255 long tmp=RequestPreHighlightTill;
256 if (RequestPreHighlightTill<till) 256 if (RequestPreHighlightTill<till)
257 { 257 {
258 RequestPreHighlightTill=till; 258 RequestPreHighlightTill=till;
259 if (tmp<=PreHighlightedTill) QTimer::singleShot(10,this,SLOT(doPreHighlight())); 259 if (tmp<=PreHighlightedTill) QTimer::singleShot(10,this,SLOT(doPreHighlight()));
260 } 260 }
261 return RequestPreHighlightTill; 261 return RequestPreHighlightTill;
262} 262}
263 263
264void KateDocument::doPreHighlight() 264void KateDocument::doPreHighlight()
265{ 265{
266 int from = PreHighlightedTill; 266 int from = PreHighlightedTill;
267 int till = PreHighlightedTill+200; 267 int till = PreHighlightedTill+200;
268 int max = numLines()-1; 268 int max = numLines()-1;
269 if (till > max) 269 if (till > max)
270 { 270 {
271 till = max; 271 till = max;
272 } 272 }
273 PreHighlightedTill = till; 273 PreHighlightedTill = till;
274 updateLines(from,till); 274 updateLines(from,till);
275 emit preHighlightChanged(PreHighlightedTill); 275 emit preHighlightChanged(PreHighlightedTill);
276 if (PreHighlightedTill<RequestPreHighlightTill) 276 if (PreHighlightedTill<RequestPreHighlightTill)
277 QTimer::singleShot(10,this,SLOT(doPreHighlight())); 277 QTimer::singleShot(10,this,SLOT(doPreHighlight()));
278} 278}
279 279
280KateDocument::~KateDocument() 280KateDocument::~KateDocument()
281{ 281{
282 m_highlight->release(); 282 m_highlight->release();
283 writeConfig();
283 284
284 if ( !m_bSingleViewMode ) 285 if ( !m_bSingleViewMode )
285 { 286 {
286 m_views.setAutoDelete( true ); 287 m_views.setAutoDelete( true );
287 m_views.clear(); 288 m_views.clear();
288 m_views.setAutoDelete( false ); 289 m_views.setAutoDelete( false );
289 } 290 }
290 delete_d(this); 291 delete_d(this);
291} 292}
292 293
293void KateDocument::openURL(const QString &filename) 294void KateDocument::openURL(const QString &filename)
294{ 295{
295 296
296 m_file=filename; 297 m_file=filename;
297 fileInfo->setFile (m_file); 298 fileInfo->setFile (m_file);
298 setMTime(); 299 setMTime();
299 300
300 if (!fileInfo->exists() || !fileInfo->isReadable()) 301 if (!fileInfo->exists() || !fileInfo->isReadable())
301 { 302 {
302 qDebug("File doesn't exit or couldn't be read"); 303 qDebug("File doesn't exit or couldn't be read");
303 return ; 304 return ;
304 } 305 }
305 306
306 buffer->clear(); 307 buffer->clear();
307#warning fixme 308#warning fixme
308// buffer->insertFile(0, m_file, KGlobal::charsets()->codecForName(myEncoding)); 309// buffer->insertFile(0, m_file, KGlobal::charsets()->codecForName(myEncoding));
309 qDebug("Telling buffer to open file"); 310 qDebug("Telling buffer to open file");
310 buffer->insertFile(0, m_file, QTextCodec::codecForLocale()); 311 buffer->insertFile(0, m_file, QTextCodec::codecForLocale());
311 312
312 setMTime(); 313 setMTime();
313 314
314 if (myWordWrap) 315 if (myWordWrap)
315 wrapText (myWordWrapAt); 316 wrapText (myWordWrapAt);
316 317
317 int hl = hlManager->wildcardFind( m_file ); 318 int hl = hlManager->wildcardFind( m_file );
318 319
319 setHighlight(hl); 320 setHighlight(hl);
320 321
321 updateLines(); 322 updateLines();
322 updateViews(); 323 updateViews();
323 324
324 emit fileNameChanged(); 325 emit fileNameChanged();
325 326
326 return ; 327 return ;
327} 328}
328 329
329bool KateDocument::saveFile() 330bool KateDocument::saveFile()
330{ 331{
331 332
332 QFile f( m_file ); 333 QFile f( m_file );
333 if ( !f.open( IO_WriteOnly ) ) 334 if ( !f.open( IO_WriteOnly ) )
334 return false; // Error 335 return false; // Error
335 336
336 QTextStream stream(&f); 337 QTextStream stream(&f);
337 338
338 stream.setEncoding(QTextStream::RawUnicode); // disable Unicode headers 339 stream.setEncoding(QTextStream::RawUnicode); // disable Unicode headers
339#warning fixme 340#warning fixme
340// stream.setCodec(KGlobal::charsets()->codecForName(myEncoding)); 341// stream.setCodec(KGlobal::charsets()->codecForName(myEncoding));
341 stream.setCodec(QTextCodec::codecForLocale()); // this line sets the mapper to the correct codec 342 stream.setCodec(QTextCodec::codecForLocale()); // this line sets the mapper to the correct codec
342 343
343 int maxLine = numLines(); 344 int maxLine = numLines();
344 int line = 0; 345 int line = 0;
345 while(true) 346 while(true)
346 { 347 {
347 stream << getTextLine(line)->getString(); 348 stream << getTextLine(line)->getString();
348 line++; 349 line++;
349 if (line >= maxLine) break; 350 if (line >= maxLine) break;
350 351
351 if (eolMode == KateDocument::eolUnix) stream << "\n"; 352 if (eolMode == KateDocument::eolUnix) stream << "\n";
352 else if (eolMode == KateDocument::eolDos) stream << "\r\n"; 353 else if (eolMode == KateDocument::eolDos) stream << "\r\n";
353 else if (eolMode == KateDocument::eolMacintosh) stream << '\r'; 354 else if (eolMode == KateDocument::eolMacintosh) stream << '\r';
354 }; 355 };
355 f.close(); 356 f.close();
356 357
357 fileInfo->setFile (m_file); 358 fileInfo->setFile (m_file);
358 setMTime(); 359 setMTime();
359 360
360 if (!(d(this)->hlSetByUser)) 361 if (!(d(this)->hlSetByUser))
361 { 362 {
362 int hl = hlManager->wildcardFind( m_file ); 363 int hl = hlManager->wildcardFind( m_file );
363 364
364 setHighlight(hl); 365 setHighlight(hl);
365 } 366 }
366 emit fileNameChanged (); 367 emit fileNameChanged ();
367 368
368 return (f.status() == IO_Ok); 369 return (f.status() == IO_Ok);
369} 370}
370 371
371KTextEditor::View *KateDocument::createView( QWidget *parent, const char *name ) 372KTextEditor::View *KateDocument::createView( QWidget *parent, const char *name )
372{ 373{
373 return new KateView( this, parent, name); 374 return new KateView( this, parent, name);
374} 375}
375 376
376QString KateDocument::textLine( int line ) const 377QString KateDocument::textLine( int line ) const
377{ 378{
378 TextLine::Ptr l = getTextLine( line ); 379 TextLine::Ptr l = getTextLine( line );
379 if ( !l ) 380 if ( !l )
380 return QString(); 381 return QString();
381 382
382 return l->getString(); 383 return l->getString();
383} 384}
384 385
385void KateDocument::replaceLine(const QString& s,int line) 386void KateDocument::replaceLine(const QString& s,int line)
386{ 387{
387 remove_Line(line,false); 388 remove_Line(line,false);
388 insert_Line(s,line,true); 389 insert_Line(s,line,true);
389} 390}
390 391
391void KateDocument::insertLine( const QString &str, int l ) { 392void KateDocument::insertLine( const QString &str, int l ) {
392 insert_Line(str,l,true); 393 insert_Line(str,l,true);
393} 394}
394 395
395void KateDocument::insert_Line(const QString& s,int line, bool update) 396void KateDocument::insert_Line(const QString& s,int line, bool update)
396{ 397{
397 kdDebug(13020)<<"KateDocument::insertLine "<<s<<QString(" %1").arg(line)<<endl; 398 kdDebug(13020)<<"KateDocument::insertLine "<<s<<QString(" %1").arg(line)<<endl;
398 TextLine::Ptr TL=new TextLine(); 399 TextLine::Ptr TL=new TextLine();
399 TL->append(s.unicode(),s.length()); 400 TL->append(s.unicode(),s.length());
400 buffer->insertLine(line,TL); 401 buffer->insertLine(line,TL);
401 if (update) 402 if (update)
402 { 403 {
403 newDocGeometry=true; 404 newDocGeometry=true;
404 updateLines(line); 405 updateLines(line);
405 updateViews(); 406 updateViews();
406 } 407 }
407} 408}
408 409
409void KateDocument::insertAt( const QString &s, int line, int col, bool ) 410void KateDocument::insertAt( const QString &s, int line, int col, bool )
410{ 411{
@@ -471,309 +472,307 @@ QString KateDocument::selection() const
471 end = textLine->findSelected(start); 472 end = textLine->findSelected(start);
472 for (i = start; i < end; i++) { 473 for (i = start; i < end; i++) {
473 s[len] = textLine->getChar(i); 474 s[len] = textLine->getChar(i);
474 len++; 475 len++;
475 } 476 }
476 } while (start < end); 477 } while (start < end);
477 if (textLine->isSelected()) { 478 if (textLine->isSelected()) {
478 s[len] = '\n'; 479 s[len] = '\n';
479 len++; 480 len++;
480 } 481 }
481 } 482 }
482// s[len] = '\0'; 483// s[len] = '\0';
483 return s; 484 return s;
484 } else { 485 } else {
485 for (z = selectStart; z <= selectEnd; z++) { 486 for (z = selectStart; z <= selectEnd; z++) {
486 textLine = getTextLine(z); 487 textLine = getTextLine(z);
487 len += textLine->numSelected() + 1; 488 len += textLine->numSelected() + 1;
488 } 489 }
489 QString s; 490 QString s;
490 len = 0; 491 len = 0;
491 for (z = selectStart; z <= selectEnd; z++) { 492 for (z = selectStart; z <= selectEnd; z++) {
492 textLine = getTextLine(z); 493 textLine = getTextLine(z);
493 end = 0; 494 end = 0;
494 do { 495 do {
495 start = textLine->findUnselected(end); 496 start = textLine->findUnselected(end);
496 end = textLine->findSelected(start); 497 end = textLine->findSelected(start);
497 for (i = start; i < end; i++) { 498 for (i = start; i < end; i++) {
498 s[len] = textLine->getChar(i); 499 s[len] = textLine->getChar(i);
499 len++; 500 len++;
500 } 501 }
501 } while (start < end); 502 } while (start < end);
502 s[len] = '\n'; 503 s[len] = '\n';
503 len++; 504 len++;
504 } 505 }
505// s[len] = '\0'; // the final \0 is not counted in length() 506// s[len] = '\0'; // the final \0 is not counted in length()
506 return s; 507 return s;
507 } 508 }
508} 509}
509 510
510int KateDocument::numLines() const 511int KateDocument::numLines() const
511{ 512{
512 return buffer->count(); 513 return buffer->count();
513} 514}
514 515
515 516
516TextLine::Ptr KateDocument::getTextLine(int line) const 517TextLine::Ptr KateDocument::getTextLine(int line) const
517{ 518{
518 // This is a hack to get this stuff working. 519 // This is a hack to get this stuff working.
519 return buffer->line(line); 520 return buffer->line(line);
520} 521}
521 522
522int KateDocument::textLength(int line) { 523int KateDocument::textLength(int line) {
523 TextLine::Ptr textLine = getTextLine(line); 524 TextLine::Ptr textLine = getTextLine(line);
524 if (!textLine) return 0; 525 if (!textLine) return 0;
525 return textLine->length(); 526 return textLine->length();
526} 527}
527 528
528void KateDocument::setTabWidth(int chars) { 529void KateDocument::setTabWidth(int chars) {
529 if (tabChars == chars) return; 530 if (tabChars == chars) return;
530 if (chars < 1) chars = 1; 531 if (chars < 1) chars = 1;
531 if (chars > 16) chars = 16; 532 if (chars > 16) chars = 16;
532 tabChars = chars; 533 tabChars = chars;
533 updateFontData(); 534 updateFontData();
534 535
535 maxLength = -1; 536 maxLength = -1;
536 for (int i=0; i < buffer->count(); i++) 537 for (int i=0; i < buffer->count(); i++)
537 { 538 {
538 TextLine::Ptr textLine = buffer->line(i); 539 TextLine::Ptr textLine = buffer->line(i);
539 int len = textWidth(textLine,textLine->length()); 540 int len = textWidth(textLine,textLine->length());
540 if (len > maxLength) { 541 if (len > maxLength) {
541 maxLength = len; 542 maxLength = len;
542 longestLine = textLine; 543 longestLine = textLine;
543 } 544 }
544 } 545 }
545} 546}
546 547
547void KateDocument::setReadOnly(bool m) { 548void KateDocument::setReadOnly(bool m) {
548 KTextEditor::View *view; 549 KTextEditor::View *view;
549 550
550 if (m != readOnly) { 551 if (m != readOnly) {
551 readOnly = m; 552 readOnly = m;
552// if (readOnly) recordReset(); 553// if (readOnly) recordReset();
553 for (view = m_views.first(); view != 0L; view = m_views.next() ) { 554 for (view = m_views.first(); view != 0L; view = m_views.next() ) {
554 emit static_cast<KateView *>( view )->newStatus(); 555 emit static_cast<KateView *>( view )->newStatus();
555 } 556 }
556 } 557 }
557} 558}
558 559
559bool KateDocument::isReadOnly() const { 560bool KateDocument::isReadOnly() const {
560 return readOnly; 561 return readOnly;
561} 562}
562 563
563void KateDocument::setNewDoc( bool m ) 564void KateDocument::setNewDoc( bool m )
564{ 565{
565// KTextEditor::View *view; 566// KTextEditor::View *view;
566 567
567 if ( m != newDoc ) 568 if ( m != newDoc )
568 { 569 {
569 newDoc = m; 570 newDoc = m;
570//// if (readOnly) recordReset(); 571//// if (readOnly) recordReset();
571// for (view = m_views.first(); view != 0L; view = m_views.next() ) { 572// for (view = m_views.first(); view != 0L; view = m_views.next() ) {
572// emit static_cast<KateView *>( view )->newStatus(); 573// emit static_cast<KateView *>( view )->newStatus();
573// } 574// }
574 } 575 }
575} 576}
576 577
577bool KateDocument::isNewDoc() const { 578bool KateDocument::isNewDoc() const {
578 return newDoc; 579 return newDoc;
579} 580}
580 581
581void KateDocument::setModified(bool m) { 582void KateDocument::setModified(bool m) {
582 KTextEditor::View *view; 583 KTextEditor::View *view;
583 584
584 if (m != modified) { 585 if (m != modified) {
585 modified = m; 586 modified = m;
586 for (view = m_views.first(); view != 0L; view = m_views.next() ) { 587 for (view = m_views.first(); view != 0L; view = m_views.next() ) {
587 emit static_cast<KateView *>( view )->newStatus(); 588 emit static_cast<KateView *>( view )->newStatus();
588 } 589 }
589 emit modifiedChanged (); 590 emit modifiedChanged ();
590 } 591 }
591} 592}
592 593
593bool KateDocument::isModified() const { 594bool KateDocument::isModified() const {
594 return modified; 595 return modified;
595} 596}
596 597
597void KateDocument::readConfig() 598void KateDocument::readConfig()
598{ 599{
599 KConfig *config = KGlobal::config(); 600 KateConfig *config = KGlobal::config();
600 config->setGroup("Kate Document"); 601 config->setGroup("Kate Document");
601 602
602 myWordWrap = config->readBoolEntry("Word Wrap On", false); 603 myWordWrap = config->readBoolEntry("Word Wrap On", false);
603 myWordWrapAt = config->readNumEntry("Word Wrap At", 80); 604 myWordWrapAt = config->readNumEntry("Word Wrap At", 80);
604 if (myWordWrap) 605 if (myWordWrap)
605 wrapText (myWordWrapAt); 606 wrapText (myWordWrapAt);
606 607
607 setTabWidth(config->readNumEntry("TabWidth", 8)); 608 setTabWidth(config->readNumEntry("TabWidth", 8));
608 setUndoSteps(config->readNumEntry("UndoSteps", 50)); 609 setUndoSteps(config->readNumEntry("UndoSteps", 50));
609 m_singleSelection = config->readBoolEntry("SingleSelection", false); 610 m_singleSelection = config->readBoolEntry("SingleSelection", false);
610 myEncoding = config->readEntry("Encoding", QString::fromLatin1(QTextCodec::codecForLocale()->name())); 611 myEncoding = config->readEntry("Encoding", QString::fromLatin1(QTextCodec::codecForLocale()->name()));
611 setFont (config->readFontEntry("Font", &myFont)); 612 setFont (config->readFontEntry("Font", myFont));
612 613
613 colors[0] = config->readColorEntry("Color Background", &colors[0]); 614 colors[0] = config->readColorEntry("Color Background", colors[0]);
614 colors[1] = config->readColorEntry("Color Selected", &colors[1]); 615 colors[1] = config->readColorEntry("Color Selected", colors[1]);
615 616
616 config->sync(); 617// config->sync();
617} 618}
618 619
619void KateDocument::writeConfig() 620void KateDocument::writeConfig()
620{ 621{
621 KConfig *config = KGlobal::config(); 622 KateConfig *config = KGlobal::config();
622 config->setGroup("Kate Document"); 623 config->setGroup("Kate Document");
623#if 0 624 config->writeEntry("Word Wrap On", myWordWrap);
624 cofig->writeEntry("Word Wrap On", myWordWrap);
625 config->writeEntry("Word Wrap At", myWordWrapAt); 625 config->writeEntry("Word Wrap At", myWordWrapAt);
626 config->writeEntry("TabWidth", tabChars); 626 config->writeEntry("TabWidth", tabChars);
627 config->writeEntry("UndoSteps", undoSteps); 627 config->writeEntry("UndoSteps", undoSteps);
628 config->writeEntry("SingleSelection", m_singleSelection); 628 config->writeEntry("SingleSelection", m_singleSelection);
629 config->writeEntry("Encoding", myEncoding); 629 config->writeEntry("Encoding", myEncoding);
630 config->writeEntry("Font", myFont); 630 config->writeEntry("Font", myFont);
631 config->writeEntry("Color Background", colors[0]); 631 config->writeEntry("Color Background", colors[0]);
632 config->writeEntry("Color Selected", colors[1]); 632 config->writeEntry("Color Selected", colors[1]);
633#endif 633// config->sync();
634 config->sync();
635} 634}
636 635
637void KateDocument::readSessionConfig(KConfig *config) 636void KateDocument::readSessionConfig(KateConfig *config)
638{ 637{
639 m_url = config->readEntry("URL"); // ### doesn't this break the encoding? (Simon) 638 m_url = config->readEntry("URL"); // ### doesn't this break the encoding? (Simon)
640 setHighlight(hlManager->nameFind(config->readEntry("Highlight"))); 639 setHighlight(hlManager->nameFind(config->readEntry("Highlight")));
641 // anders: restore bookmarks if possible 640 // anders: restore bookmarks if possible
642 QValueList<int> l = config->readIntListEntry("Bookmarks"); 641 QValueList<int> l = config->readIntListEntry("Bookmarks");
643 if ( l.count() ) { 642 if ( l.count() ) {
644 for (uint i=0; i < l.count(); i++) { 643 for (uint i=0; i < l.count(); i++) {
645 if ( numLines() < l[i] ) break; 644 if ( numLines() < l[i] ) break;
646 getTextLine( l[i] )->addMark( Bookmark ); 645 getTextLine( l[i] )->addMark( Bookmark );
647 } 646 }
648 } 647 }
649} 648}
650 649
651void KateDocument::writeSessionConfig(KConfig *config) 650void KateDocument::writeSessionConfig(KateConfig *config)
652{ 651{
653#if 0 652#if 0
654 config->writeEntry("URL", m_url); // ### encoding?? (Simon) 653 config->writeEntry("URL", m_url); // ### encoding?? (Simon)
655 config->writeEntry("Highlight", m_highlight->name()); 654 config->writeEntry("Highlight", m_highlight->name());
656 // anders: save bookmarks 655 // anders: save bookmarks
657 QList<Kate::Mark> l = marks(); 656 QList<Kate::Mark> l = marks();
658 QValueList<int> ml; 657 QValueList<int> ml;
659 for (uint i=0; i < l.count(); i++) { 658 for (uint i=0; i < l.count(); i++) {
660 if ( l.at(i)->type == 1) // only save bookmarks 659 if ( l.at(i)->type == 1) // only save bookmarks
661 ml << l.at(i)->line; 660 ml << l.at(i)->line;
662 } 661 }
663 if ( ml.count() ) 662 if ( ml.count() )
664 config->writeEntry("Bookmarks", ml); 663 config->writeEntry("Bookmarks", ml);
665#endif 664#endif
666} 665}
667 666
668 667
669void KateDocument::setHighlight(int n) { 668void KateDocument::setHighlight(int n) {
670 Highlight *h; 669 Highlight *h;
671 670
672// hlNumber = n; 671// hlNumber = n;
673 672
674 h = hlManager->getHl(n); 673 h = hlManager->getHl(n);
675 if (h == m_highlight) { 674 if (h == m_highlight) {
676 updateLines(); 675 updateLines();
677 } else { 676 } else {
678 if (m_highlight != 0L) m_highlight->release(); 677 if (m_highlight != 0L) m_highlight->release();
679 h->use(); 678 h->use();
680 m_highlight = h; 679 m_highlight = h;
681 makeAttribs(); 680 makeAttribs();
682 } 681 }
683 PreHighlightedTill=0; 682 PreHighlightedTill=0;
684 RequestPreHighlightTill=0; 683 RequestPreHighlightTill=0;
685 emit(highlightChanged()); 684 emit(highlightChanged());
686} 685}
687 686
688void KateDocument::makeAttribs() { 687void KateDocument::makeAttribs() {
689 qDebug("KateDocument::makeAttribs()"); 688 qDebug("KateDocument::makeAttribs()");
690 m_numAttribs = hlManager->makeAttribs(m_highlight, m_attribs, maxAttribs); 689 m_numAttribs = hlManager->makeAttribs(m_highlight, m_attribs, maxAttribs);
691 updateFontData(); 690 updateFontData();
692 updateLines(); 691 updateLines();
693} 692}
694 693
695void KateDocument::updateFontData() { 694void KateDocument::updateFontData() {
696 int maxAscent, maxDescent; 695 int maxAscent, maxDescent;
697 int tabWidth; 696 int tabWidth;
698 KateView *view; 697 KateView *view;
699 698
700 maxAscent = myFontMetrics.ascent(); 699 maxAscent = myFontMetrics.ascent();
701 maxDescent = myFontMetrics.descent(); 700 maxDescent = myFontMetrics.descent();
702 tabWidth = myFontMetrics.width(' '); 701 tabWidth = myFontMetrics.width(' ');
703 702
704 fontHeight = maxAscent + maxDescent + 1; 703 fontHeight = maxAscent + maxDescent + 1;
705 fontAscent = maxAscent; 704 fontAscent = maxAscent;
706 m_tabWidth = tabChars*tabWidth; 705 m_tabWidth = tabChars*tabWidth;
707 706
708 for (view = views.first(); view != 0L; view = views.next() ) { 707 for (view = views.first(); view != 0L; view = views.next() ) {
709 view->myViewInternal->drawBuffer->resize(view->width(),fontHeight); 708 view->myViewInternal->drawBuffer->resize(view->width(),fontHeight);
710 view->tagAll(); 709 view->tagAll();
711 view->updateCursor(); 710 view->updateCursor();
712 } 711 }
713} 712}
714 713
715void KateDocument::hlChanged() { //slot 714void KateDocument::hlChanged() { //slot
716 makeAttribs(); 715 makeAttribs();
717 updateViews(); 716 updateViews();
718} 717}
719 718
720 719
721void KateDocument::addView(KTextEditor::View *view) { 720void KateDocument::addView(KTextEditor::View *view) {
722 views.append( static_cast<KateView *>( view ) ); 721 views.append( static_cast<KateView *>( view ) );
723 KTextEditor::Document::addView( view ); 722 KTextEditor::Document::addView( view );
724 connect( static_cast<KateView *>( view ), SIGNAL( destroyed() ), this, SLOT( slotViewDestroyed() ) ); 723 connect( static_cast<KateView *>( view ), SIGNAL( destroyed() ), this, SLOT( slotViewDestroyed() ) );
725} 724}
726 725
727void KateDocument::removeView(KTextEditor::View *view) { 726void KateDocument::removeView(KTextEditor::View *view) {
728// if (undoView == view) recordReset(); 727// if (undoView == view) recordReset();
729 disconnect( static_cast<KateView *>( view ), SIGNAL( destroyed() ), this, SLOT( slotViewDestroyed() ) ); 728 disconnect( static_cast<KateView *>( view ), SIGNAL( destroyed() ), this, SLOT( slotViewDestroyed() ) );
730 views.removeRef( static_cast<KateView *>( view ) ); 729 views.removeRef( static_cast<KateView *>( view ) );
731 KTextEditor::Document::removeView( view ); 730 KTextEditor::Document::removeView( view );
732} 731}
733 732
734void KateDocument::slotViewDestroyed() 733void KateDocument::slotViewDestroyed()
735{ 734{
736 views.removeRef( static_cast<const KateView *>( sender() ) ); 735 views.removeRef( static_cast<const KateView *>( sender() ) );
737} 736}
738 737
739bool KateDocument::ownedView(KateView *view) { 738bool KateDocument::ownedView(KateView *view) {
740 // do we own the given view? 739 // do we own the given view?
741 return (views.containsRef(view) > 0); 740 return (views.containsRef(view) > 0);
742} 741}
743 742
744bool KateDocument::isLastView(int numViews) { 743bool KateDocument::isLastView(int numViews) {
745 return ((int) views.count() == numViews); 744 return ((int) views.count() == numViews);
746} 745}
747 746
748int KateDocument::textWidth(const TextLine::Ptr &textLine, int cursorX) { 747int KateDocument::textWidth(const TextLine::Ptr &textLine, int cursorX) {
749 int x; 748 int x;
750 int z; 749 int z;
751 QChar ch; 750 QChar ch;
752 Attribute *a; 751 Attribute *a;
753 752
754 x = 0; 753 x = 0;
755 for (z = 0; z < cursorX; z++) { 754 for (z = 0; z < cursorX; z++) {
756 ch = textLine->getChar(z); 755 ch = textLine->getChar(z);
757 a = &m_attribs[textLine->getAttr(z)]; 756 a = &m_attribs[textLine->getAttr(z)];
758 757
759 if (ch == '\t') 758 if (ch == '\t')
760 x += m_tabWidth - (x % m_tabWidth); 759 x += m_tabWidth - (x % m_tabWidth);
761 else if (a->bold && a->italic) 760 else if (a->bold && a->italic)
762 x += myFontMetricsBI.width(ch); 761 x += myFontMetricsBI.width(ch);
763 else if (a->bold) 762 else if (a->bold)
764 x += myFontMetricsBold.width(ch); 763 x += myFontMetricsBold.width(ch);
765 else if (a->italic) 764 else if (a->italic)
766 x += myFontMetricsItalic.width(ch); 765 x += myFontMetricsItalic.width(ch);
767 else 766 else
768 x += myFontMetrics.width(ch); 767 x += myFontMetrics.width(ch);
769 } 768 }
770 return x; 769 return x;
771} 770}
772 771
773int KateDocument::textWidth(PointStruc &cursor) { 772int KateDocument::textWidth(PointStruc &cursor) {
774 if (cursor.x < 0) 773 if (cursor.x < 0)
775 cursor.x = 0; 774 cursor.x = 0;
776 if (cursor.y < 0) 775 if (cursor.y < 0)
777 cursor.y = 0; 776 cursor.y = 0;
778 if (cursor.y >= numLines()) 777 if (cursor.y >= numLines())
779 cursor.y = lastLine(); 778 cursor.y = lastLine();
diff --git a/noncore/apps/tinykate/libkate/document/katedocument.h b/noncore/apps/tinykate/libkate/document/katedocument.h
index 356541f..9d8ec6a 100644
--- a/noncore/apps/tinykate/libkate/document/katedocument.h
+++ b/noncore/apps/tinykate/libkate/document/katedocument.h
@@ -104,258 +104,258 @@ class KateAction {
104 KateAction(Action, PointStruc &cursor, int len = 0, 104 KateAction(Action, PointStruc &cursor, int len = 0,
105 const QString &text = QString::null); 105 const QString &text = QString::null);
106 106
107 Action action; 107 Action action;
108 PointStruc cursor; 108 PointStruc cursor;
109 int len; 109 int len;
110 QString text; 110 QString text;
111 KateAction *next; 111 KateAction *next;
112}; 112};
113 113
114class KateActionGroup { 114class KateActionGroup {
115 public: 115 public:
116 // the undo group types 116 // the undo group types
117 enum { ugNone, // 117 enum { ugNone, //
118 ugPaste, // paste 118 ugPaste, // paste
119 ugDelBlock, // delete/replace selected text 119 ugDelBlock, // delete/replace selected text
120 ugIndent, // indent 120 ugIndent, // indent
121 ugUnindent, // unindent 121 ugUnindent, // unindent
122 ugComment, // comment 122 ugComment, // comment
123 ugUncomment, // uncomment 123 ugUncomment, // uncomment
124 ugReplace, // text search/replace 124 ugReplace, // text search/replace
125 ugSpell, // spell check 125 ugSpell, // spell check
126 ugInsChar, // char type/deleting 126 ugInsChar, // char type/deleting
127 ugDelChar, // '' '' 127 ugDelChar, // '' ''
128 ugInsLine, // line insert/delete 128 ugInsLine, // line insert/delete
129 ugDelLine // '' '' 129 ugDelLine // '' ''
130 }; 130 };
131 131
132 KateActionGroup(PointStruc &aStart, int type = ugNone); 132 KateActionGroup(PointStruc &aStart, int type = ugNone);
133 ~KateActionGroup(); 133 ~KateActionGroup();
134 void insertAction(KateAction *); 134 void insertAction(KateAction *);
135 135
136 static const char * typeName(int type); 136 static const char * typeName(int type);
137 137
138 PointStruc start; 138 PointStruc start;
139 PointStruc end; 139 PointStruc end;
140 KateAction *action; 140 KateAction *action;
141 int undoType; 141 int undoType;
142}; 142};
143 143
144/** 144/**
145 The text document. It contains the textlines, controls the 145 The text document. It contains the textlines, controls the
146 document changing operations and does undo/redo. WARNING: do not change 146 document changing operations and does undo/redo. WARNING: do not change
147 the text contents directly in methods where this is not explicitly 147 the text contents directly in methods where this is not explicitly
148 permitted. All changes have to be made with some basic operations, 148 permitted. All changes have to be made with some basic operations,
149 which are recorded by the undo/redo system. 149 which are recorded by the undo/redo system.
150 @see TextLine 150 @see TextLine
151 @author Jochen Wilhelmy 151 @author Jochen Wilhelmy
152*/ 152*/
153class KateDocument: public Kate::Document 153class KateDocument: public Kate::Document
154{ 154{
155 Q_OBJECT 155 Q_OBJECT
156 friend class KateViewInternal; 156 friend class KateViewInternal;
157 friend class KateView; 157 friend class KateView;
158 friend class KateIconBorder; 158 friend class KateIconBorder;
159 159
160 public: 160 public:
161 KateDocument(bool bSingleViewMode=false, bool bBrowserView=false, QWidget *parentWidget = 0, const char *widgetName = 0, QObject * = 0, const char * = 0); 161 KateDocument(bool bSingleViewMode=false, bool bBrowserView=false, QWidget *parentWidget = 0, const char *widgetName = 0, QObject * = 0, const char * = 0);
162 ~KateDocument(); 162 ~KateDocument();
163 163
164 protected: 164 protected:
165 QFont myFont, myFontBold, myFontItalic, myFontBI; 165 QFont myFont, myFontBold, myFontItalic, myFontBI;
166 CachedFontMetrics myFontMetrics, myFontMetricsBold, myFontMetricsItalic, myFontMetricsBI; 166 CachedFontMetrics myFontMetrics, myFontMetricsBold, myFontMetricsItalic, myFontMetricsBI;
167 167
168 public: 168 public:
169 void setFont (QFont font); 169 void setFont (QFont font);
170 QFont getFont () { return myFont; }; 170 QFont getFont () { return myFont; };
171 CachedFontMetrics getFontMetrics () { return myFontMetrics; }; 171 CachedFontMetrics getFontMetrics () { return myFontMetrics; };
172 172
173 virtual bool saveFile(); 173 virtual bool saveFile();
174 174
175 virtual KTextEditor::View *createView( QWidget *parent, const char *name ); 175 virtual KTextEditor::View *createView( QWidget *parent, const char *name );
176 virtual QString textLine( int line ) const; 176 virtual QString textLine( int line ) const;
177 177
178 virtual void insertLine( const QString &s, int line = -1 ); 178 virtual void insertLine( const QString &s, int line = -1 );
179 179
180 void insert_Line(const QString& s,int line=-1, bool update=true); 180 void insert_Line(const QString& s,int line=-1, bool update=true);
181 void remove_Line(int line,bool update=true); 181 void remove_Line(int line,bool update=true);
182 void replaceLine(const QString& s,int line=-1); 182 void replaceLine(const QString& s,int line=-1);
183 virtual void insertAt( const QString &s, int line, int col, bool mark = FALSE ); 183 virtual void insertAt( const QString &s, int line, int col, bool mark = FALSE );
184 virtual void removeLine( int line ); 184 virtual void removeLine( int line );
185 virtual int length() const; 185 virtual int length() const;
186 186
187 virtual void setSelection( int row_from, int col_from, int row_to, int col_t ); 187 virtual void setSelection( int row_from, int col_from, int row_to, int col_t );
188 virtual bool hasSelection() const; 188 virtual bool hasSelection() const;
189 virtual QString selection() const; 189 virtual QString selection() const;
190 190
191 // only to make part work, don't change it ! 191 // only to make part work, don't change it !
192 bool m_bSingleViewMode; 192 bool m_bSingleViewMode;
193 193
194// public interface 194// public interface
195 /** 195 /**
196 * gets the number of lines 196 * gets the number of lines
197 */ 197 */
198 virtual int numLines() const; 198 virtual int numLines() const;
199 199
200 /** 200 /**
201 * gets the last line number (numLines() -1) 201 * gets the last line number (numLines() -1)
202 */ 202 */
203 int lastLine() const {return numLines()-1;} 203 int lastLine() const {return numLines()-1;}
204 204
205 /** 205 /**
206 gets the given line 206 gets the given line
207 @return the TextLine object at the given line 207 @return the TextLine object at the given line
208 @see TextLine 208 @see TextLine
209 */ 209 */
210 TextLine::Ptr getTextLine(int line) const; 210 TextLine::Ptr getTextLine(int line) const;
211 211
212 /** 212 /**
213 get the length in pixels of the given line 213 get the length in pixels of the given line
214 */ 214 */
215 int textLength(int line); 215 int textLength(int line);
216 216
217 void setTabWidth(int); 217 void setTabWidth(int);
218 int tabWidth() {return tabChars;} 218 int tabWidth() {return tabChars;}
219 void setReadOnly(bool); 219 void setReadOnly(bool);
220 bool isReadOnly() const; 220 bool isReadOnly() const;
221 void setNewDoc( bool ); 221 void setNewDoc( bool );
222 bool isNewDoc() const; 222 bool isNewDoc() const;
223 virtual void setReadWrite( bool ){}; 223 virtual void setReadWrite( bool ){};
224 virtual bool isReadWrite() const {return true;} 224 virtual bool isReadWrite() const {return true;}
225 virtual void setModified(bool); 225 virtual void setModified(bool);
226 virtual bool isModified() const; 226 virtual bool isModified() const;
227 void setSingleSelection(bool ss) {m_singleSelection = ss;} 227 void setSingleSelection(bool ss) {m_singleSelection = ss;}
228 bool singleSelection() {return m_singleSelection;} 228 bool singleSelection() {return m_singleSelection;}
229 229
230 void readConfig(); 230 void readConfig();
231 void writeConfig(); 231 void writeConfig();
232 void readSessionConfig(KConfig *); 232 void readSessionConfig(KateConfig *);
233 void writeSessionConfig(KConfig *); 233 void writeSessionConfig(KateConfig *);
234 234
235 bool hasBrowserExtension() const { return m_bBrowserView; } 235 bool hasBrowserExtension() const { return m_bBrowserView; }
236 236
237 protected: 237 protected:
238 bool m_bBrowserView; 238 bool m_bBrowserView;
239 239
240 signals: 240 signals:
241 void selectionChanged(); 241 void selectionChanged();
242 void highlightChanged(); 242 void highlightChanged();
243 void modifiedChanged (); 243 void modifiedChanged ();
244 void preHighlightChanged(long); 244 void preHighlightChanged(long);
245 245
246 // search stuff 246 // search stuff
247 protected: 247 protected:
248 static QStringList searchForList; 248 static QStringList searchForList;
249 static QStringList replaceWithList; 249 static QStringList replaceWithList;
250 static uint uniqueID; 250 static uint uniqueID;
251 251
252 // highlight stuff 252 // highlight stuff
253 public: 253 public:
254 Highlight *highlight() {return m_highlight;} 254 Highlight *highlight() {return m_highlight;}
255 int highlightNum() {return hlManager->findHl(m_highlight);} 255 int highlightNum() {return hlManager->findHl(m_highlight);}
256 int numAttribs() {return m_numAttribs;} 256 int numAttribs() {return m_numAttribs;}
257 Attribute *attribs() {return m_attribs;} 257 Attribute *attribs() {return m_attribs;}
258 void setDontChangeHlOnSave(); 258 void setDontChangeHlOnSave();
259 259
260 protected: 260 protected:
261 void setHighlight(int n); 261 void setHighlight(int n);
262 void makeAttribs(); 262 void makeAttribs();
263 void updateFontData(); 263 void updateFontData();
264 264
265 protected slots: 265 protected slots:
266 void hlChanged(); 266 void hlChanged();
267 267
268// view interaction 268// view interaction
269 public: 269 public:
270 virtual void addView(KTextEditor::View *); 270 virtual void addView(KTextEditor::View *);
271 virtual void removeView(KTextEditor::View *); 271 virtual void removeView(KTextEditor::View *);
272 bool ownedView(KateView *); 272 bool ownedView(KateView *);
273 bool isLastView(int numViews); 273 bool isLastView(int numViews);
274 274
275 int getTextLineCount() {return numLines();} 275 int getTextLineCount() {return numLines();}
276 276
277 int textWidth(const TextLine::Ptr &, int cursorX); 277 int textWidth(const TextLine::Ptr &, int cursorX);
278 int textWidth(PointStruc &cursor); 278 int textWidth(PointStruc &cursor);
279 int textWidth(bool wrapCursor, PointStruc &cursor, int xPos); 279 int textWidth(bool wrapCursor, PointStruc &cursor, int xPos);
280 int textPos(const TextLine::Ptr &, int xPos); 280 int textPos(const TextLine::Ptr &, int xPos);
281// int textPos(TextLine::Ptr &, int xPos, int &newXPos); 281// int textPos(TextLine::Ptr &, int xPos, int &newXPos);
282 int textWidth(); 282 int textWidth();
283 int textHeight(); 283 int textHeight();
284 284
285 void insert(VConfig &, const QString &); 285 void insert(VConfig &, const QString &);
286 void insertFile(VConfig &, QIODevice &); 286 void insertFile(VConfig &, QIODevice &);
287 287
288 int currentColumn(PointStruc &cursor); 288 int currentColumn(PointStruc &cursor);
289 bool insertChars(VConfig &, const QString &chars); 289 bool insertChars(VConfig &, const QString &chars);
290 void newLine(VConfig &); 290 void newLine(VConfig &);
291 void killLine(VConfig &); 291 void killLine(VConfig &);
292 void backspace(VConfig &); 292 void backspace(VConfig &);
293 void del(VConfig &); 293 void del(VConfig &);
294 void clear(); 294 void clear();
295 void cut(VConfig &); 295 void cut(VConfig &);
296 void copy(int flags); 296 void copy(int flags);
297 void paste(VConfig &); 297 void paste(VConfig &);
298 298
299 void toggleRect(int, int, int, int); 299 void toggleRect(int, int, int, int);
300 void selectTo(VConfig &c, PointStruc &cursor, int cXPos); 300 void selectTo(VConfig &c, PointStruc &cursor, int cXPos);
301 void selectAll(); 301 void selectAll();
302 void deselectAll(); 302 void deselectAll();
303 void invertSelection(); 303 void invertSelection();
304 void selectWord(PointStruc &cursor, int flags); 304 void selectWord(PointStruc &cursor, int flags);
305 void selectLength(PointStruc &cursor, int length, int flags); 305 void selectLength(PointStruc &cursor, int length, int flags);
306 306
307 void indent(VConfig &c) {doIndent(c, 1);} 307 void indent(VConfig &c) {doIndent(c, 1);}
308 void unIndent(VConfig &c) {doIndent(c, -1);} 308 void unIndent(VConfig &c) {doIndent(c, -1);}
309 void cleanIndent(VConfig &c) {doIndent(c, 0);} 309 void cleanIndent(VConfig &c) {doIndent(c, 0);}
310 // called by indent/unIndent/cleanIndent 310 // called by indent/unIndent/cleanIndent
311 // just does some setup and then calls optimizeLeadingSpace() 311 // just does some setup and then calls optimizeLeadingSpace()
312 void doIndent(VConfig &, int change); 312 void doIndent(VConfig &, int change);
313 // optimize leading whitespace on a single line - see kwdoc.cpp for full description 313 // optimize leading whitespace on a single line - see kwdoc.cpp for full description
314 void optimizeLeadingSpace(int line, int flags, int change); 314 void optimizeLeadingSpace(int line, int flags, int change);
315 315
316 void comment(VConfig &c) {doComment(c, 1);} 316 void comment(VConfig &c) {doComment(c, 1);}
317 void unComment(VConfig &c) {doComment(c, -1);} 317 void unComment(VConfig &c) {doComment(c, -1);}
318 void doComment(VConfig &, int change); 318 void doComment(VConfig &, int change);
319 319
320 virtual QString text() const; 320 virtual QString text() const;
321 QString getWord(PointStruc &cursor); 321 QString getWord(PointStruc &cursor);
322 322
323 public slots: 323 public slots:
324 virtual void setText(const QString &); 324 virtual void setText(const QString &);
325 325
326 public: 326 public:
327 long needPreHighlight(long till); 327 long needPreHighlight(long till);
328 bool hasMarkedText() {return (selectEnd >= selectStart);} 328 bool hasMarkedText() {return (selectEnd >= selectStart);}
329 QString markedText(int flags); 329 QString markedText(int flags);
330 void delMarkedText(VConfig &/*, bool undo = true*/); 330 void delMarkedText(VConfig &/*, bool undo = true*/);
331 331
332 void tagLineRange(int line, int x1, int x2); 332 void tagLineRange(int line, int x1, int x2);
333 void tagLines(int start, int end); 333 void tagLines(int start, int end);
334 void tagAll(); 334 void tagAll();
335 void updateLines(int startLine = 0, int endLine = 0xffffff, int flags = 0, int cursorY = -1); 335 void updateLines(int startLine = 0, int endLine = 0xffffff, int flags = 0, int cursorY = -1);
336 void updateMaxLength(TextLine::Ptr &); 336 void updateMaxLength(TextLine::Ptr &);
337 void updateViews(KateView *exclude = 0L); 337 void updateViews(KateView *exclude = 0L);
338 338
339 QColor &cursorCol(int x, int y); 339 QColor &cursorCol(int x, int y);
340 void paintTextLine(QPainter &, int line, int xStart, int xEnd, bool showTabs); 340 void paintTextLine(QPainter &, int line, int xStart, int xEnd, bool showTabs);
341 void paintTextLine(QPainter &, int line, int y, int xStart, int xEnd, bool showTabs); 341 void paintTextLine(QPainter &, int line, int y, int xStart, int xEnd, bool showTabs);
342 342
343 bool doSearch(SConfig &s, const QString &searchFor); 343 bool doSearch(SConfig &s, const QString &searchFor);
344 344
345// internal 345// internal
346 void tagLine(int line); 346 void tagLine(int line);
347 void insLine(int line); 347 void insLine(int line);
348 void delLine(int line); 348 void delLine(int line);
349 void optimizeSelection(); 349 void optimizeSelection();
350 350
351 void doAction(KateAction *); 351 void doAction(KateAction *);
352 void doReplace(KateAction *); 352 void doReplace(KateAction *);
353 void doWordWrap(KateAction *); 353 void doWordWrap(KateAction *);
354 void doWordUnWrap(KateAction *); 354 void doWordUnWrap(KateAction *);
355 void doNewLine(KateAction *); 355 void doNewLine(KateAction *);
356 void doDelLine(KateAction *); 356 void doDelLine(KateAction *);
357 void doInsLine(KateAction *); 357 void doInsLine(KateAction *);
358 void doKillLine(KateAction *); 358 void doKillLine(KateAction *);
359 void newUndo(); 359 void newUndo();
360 360
361 void recordStart(VConfig &, int newUndoType); 361 void recordStart(VConfig &, int newUndoType);
diff --git a/noncore/apps/tinykate/libkate/document/katehighlight.cpp b/noncore/apps/tinykate/libkate/document/katehighlight.cpp
index 797968b..0d2c283 100644
--- a/noncore/apps/tinykate/libkate/document/katehighlight.cpp
+++ b/noncore/apps/tinykate/libkate/document/katehighlight.cpp
@@ -524,356 +524,356 @@ ItemStyle::ItemStyle(const QColor &col, const QColor &selCol,
524} 524}
525 525
526ItemData::ItemData(const QString name, int defStyleNum) 526ItemData::ItemData(const QString name, int defStyleNum)
527 : name(name), defStyleNum(defStyleNum), defStyle(true) { 527 : name(name), defStyleNum(defStyleNum), defStyle(true) {
528} 528}
529 529
530ItemData::ItemData(const QString name, int defStyleNum, 530ItemData::ItemData(const QString name, int defStyleNum,
531 const QColor &col, const QColor &selCol, bool bold, bool italic) 531 const QColor &col, const QColor &selCol, bool bold, bool italic)
532 : ItemStyle(col,selCol,bold,italic), name(name), defStyleNum(defStyleNum), 532 : ItemStyle(col,selCol,bold,italic), name(name), defStyleNum(defStyleNum),
533 defStyle(false) { 533 defStyle(false) {
534} 534}
535 535
536HlData::HlData(const QString &wildcards, const QString &mimetypes, const QString &identifier) 536HlData::HlData(const QString &wildcards, const QString &mimetypes, const QString &identifier)
537 : wildcards(wildcards), mimetypes(mimetypes), identifier(identifier) { 537 : wildcards(wildcards), mimetypes(mimetypes), identifier(identifier) {
538 538
539//JW itemDataList.setAutoDelete(true); 539//JW itemDataList.setAutoDelete(true);
540} 540}
541 541
542HlContext::HlContext(int attribute, int lineEndContext, int _lineBeginContext) 542HlContext::HlContext(int attribute, int lineEndContext, int _lineBeginContext)
543 : attr(attribute), ctx(lineEndContext),lineBeginContext(_lineBeginContext) { 543 : attr(attribute), ctx(lineEndContext),lineBeginContext(_lineBeginContext) {
544 items.setAutoDelete(true); 544 items.setAutoDelete(true);
545} 545}
546 546
547Hl2CharDetect::Hl2CharDetect(int attribute, int context, const QChar *s) 547Hl2CharDetect::Hl2CharDetect(int attribute, int context, const QChar *s)
548 : HlItem(attribute,context) { 548 : HlItem(attribute,context) {
549 sChar1 = s[0]; 549 sChar1 = s[0];
550 sChar2 = s[1]; 550 sChar2 = s[1];
551} 551}
552 552
553Highlight::Highlight(syntaxModeListItem *def) : refCount(0) 553Highlight::Highlight(syntaxModeListItem *def) : refCount(0)
554{ 554{
555 noHl = false; 555 noHl = false;
556 556
557 if (def == 0) 557 if (def == 0)
558 { 558 {
559 noHl = true; 559 noHl = true;
560 iName = I18N_NOOP("Normal"); 560 iName = I18N_NOOP("Normal");
561 iSection = ""; 561 iSection = "";
562 } 562 }
563 else 563 else
564 { 564 {
565 iName = def->name; 565 iName = def->name;
566 iSection = def->section; 566 iSection = def->section;
567 iWildcards = def->extension; 567 iWildcards = def->extension;
568 iMimetypes = def->mimetype; 568 iMimetypes = def->mimetype;
569 identifier = def->identifier; 569 identifier = def->identifier;
570 } 570 }
571 deliminator = stdDeliminator; 571 deliminator = stdDeliminator;
572 deliminatorChars = deliminator.unicode(); 572 deliminatorChars = deliminator.unicode();
573 deliminatorLen = deliminator.length(); 573 deliminatorLen = deliminator.length();
574} 574}
575 575
576Highlight::~Highlight() 576Highlight::~Highlight()
577{ 577{
578} 578}
579 579
580int Highlight::doHighlight(int ctxNum, TextLine *textLine) 580int Highlight::doHighlight(int ctxNum, TextLine *textLine)
581{ 581{
582 if (noHl) 582 if (noHl)
583 { 583 {
584 textLine->setAttribs(0,0,textLine->length()); 584 textLine->setAttribs(0,0,textLine->length());
585 textLine->setAttr(0); 585 textLine->setAttr(0);
586 return 0; 586 return 0;
587 } 587 }
588 588
589 HlContext *context; 589 HlContext *context;
590 const QChar *s2; 590 const QChar *s2;
591 HlItem *item; 591 HlItem *item;
592 592
593 context = contextList[ctxNum]; 593 context = contextList[ctxNum];
594 if (context->lineBeginContext!=-1) 594 if (context->lineBeginContext!=-1)
595 { 595 {
596 ctxNum=context->lineBeginContext; 596 ctxNum=context->lineBeginContext;
597 context=contextList[ctxNum]; 597 context=contextList[ctxNum];
598 } 598 }
599 599
600 QChar lastChar = ' '; 600 QChar lastChar = ' ';
601 601
602 // first char 602 // first char
603 const QChar *str = textLine->getText(); 603 const QChar *str = textLine->getText();
604 604
605 // non space char - index of that char 605 // non space char - index of that char
606 const QChar *s1 = textLine->firstNonSpace(); 606 const QChar *s1 = textLine->firstNonSpace();
607 uint z = textLine->firstChar(); 607 uint z = textLine->firstChar();
608 608
609 // length of textline 609 // length of textline
610 uint len = textLine->length(); 610 uint len = textLine->length();
611 611
612 bool found = false; 612 bool found = false;
613 while (z < len) 613 while (z < len)
614 { 614 {
615 found = false; 615 found = false;
616 616
617 for (item = context->items.first(); item != 0L; item = context->items.next()) 617 for (item = context->items.first(); item != 0L; item = context->items.next())
618 { 618 {
619 if (item->startEnable(lastChar)) 619 if (item->startEnable(lastChar))
620 { 620 {
621 s2 = item->checkHgl(s1, len-z, z==0); 621 s2 = item->checkHgl(s1, len-z, z==0);
622 if (s2 > s1) 622 if (s2 > s1)
623 { 623 {
624 qDebug("An item has been detected"); 624 qDebug("An item has been detected");
625 textLine->setAttribs(item->attr,s1 - str,s2 - str); 625 textLine->setAttribs(item->attr,s1 - str,s2 - str);
626 ctxNum = item->ctx; 626 ctxNum = item->ctx;
627 context = contextList[ctxNum]; 627 context = contextList[ctxNum];
628 z = z + s2 - s1 - 1; 628 z = z + s2 - s1 - 1;
629 s1 = s2 - 1; 629 s1 = s2 - 1;
630 found = true; 630 found = true;
631 break; 631 break;
632 } 632 }
633 } 633 }
634 } 634 }
635 635
636 // nothing found: set attribute of one char 636 // nothing found: set attribute of one char
637 if (!found) 637 if (!found)
638 textLine->setAttribs(context->attr,s1 - str,s1 - str + 1); 638 textLine->setAttribs(context->attr,s1 - str,s1 - str + 1);
639 639
640 lastChar = *s1; 640 lastChar = *s1;
641 s1++; 641 s1++;
642 z++; 642 z++;
643 } 643 }
644 644
645 //set "end of line"-properties 645 //set "end of line"-properties
646 textLine->setAttr(context->attr); 646 textLine->setAttr(context->attr);
647 647
648 //return new context 648 //return new context
649 return context->ctx; 649 return context->ctx;
650} 650}
651 651
652KConfig *Highlight::getKConfig() { 652KateConfig *Highlight::getKateConfig() {
653 KConfig *config; 653 KateConfig *config;
654 config=KGlobal::config(); 654 config=KGlobal::config();
655 config->setGroup(iName + QString(" Highlight")); 655 config->setGroup(iName + QString(" Highlight"));
656 return config; 656 return config;
657} 657}
658 658
659QString Highlight::getWildcards() { 659QString Highlight::getWildcards() {
660 KConfig *config; 660 KateConfig *config;
661 661
662 config = getKConfig(); 662 config = getKateConfig();
663 663
664 //if wildcards not yet in config, then use iWildCards as default 664 //if wildcards not yet in config, then use iWildCards as default
665 return config->readEntry("Wildcards", iWildcards); 665 return config->readEntry("Wildcards", iWildcards);
666} 666}
667 667
668 668
669QString Highlight::getMimetypes() { 669QString Highlight::getMimetypes() {
670 KConfig *config; 670 KateConfig *config;
671 671
672 config = getKConfig(); 672 config = getKateConfig();
673 673
674 return config->readEntry("Mimetypes", iMimetypes); 674 return config->readEntry("Mimetypes", iMimetypes);
675} 675}
676 676
677 677
678HlData *Highlight::getData() { 678HlData *Highlight::getData() {
679 KConfig *config; 679 KateConfig *config;
680 HlData *hlData; 680 HlData *hlData;
681 681
682 config = getKConfig(); 682 config = getKateConfig();
683 683
684// iWildcards = config->readEntry("Wildcards"); 684// iWildcards = config->readEntry("Wildcards");
685// iMimetypes = config->readEntry("Mimetypes"); 685// iMimetypes = config->readEntry("Mimetypes");
686// hlData = new HlData(iWildcards,iMimetypes); 686// hlData = new HlData(iWildcards,iMimetypes);
687 hlData = new HlData( 687 hlData = new HlData(
688 config->readEntry("Wildcards", iWildcards), 688 config->readEntry("Wildcards", iWildcards),
689 config->readEntry("Mimetypes", iMimetypes), 689 config->readEntry("Mimetypes", iMimetypes),
690 config->readEntry("Identifier", identifier)); 690 config->readEntry("Identifier", identifier));
691 getItemDataList(hlData->itemDataList, config); 691 getItemDataList(hlData->itemDataList, config);
692 return hlData; 692 return hlData;
693} 693}
694 694
695void Highlight::setData(HlData *hlData) { 695void Highlight::setData(HlData *hlData) {
696 KConfig *config; 696 KateConfig *config;
697 697
698 config = getKConfig(); 698 config = getKateConfig();
699 699
700// iWildcards = hlData->wildcards; 700// iWildcards = hlData->wildcards;
701// iMimetypes = hlData->mimetypes; 701// iMimetypes = hlData->mimetypes;
702 702
703 config->writeEntry("Wildcards",hlData->wildcards); 703 config->writeEntry("Wildcards",hlData->wildcards);
704 config->writeEntry("Mimetypes",hlData->mimetypes); 704 config->writeEntry("Mimetypes",hlData->mimetypes);
705 705
706 setItemDataList(hlData->itemDataList,config); 706 setItemDataList(hlData->itemDataList,config);
707} 707}
708 708
709void Highlight::getItemDataList(ItemDataList &list) { 709void Highlight::getItemDataList(ItemDataList &list) {
710 KConfig *config; 710 KateConfig *config;
711 711
712 config = getKConfig(); 712 config = getKateConfig();
713 getItemDataList(list, config); 713 getItemDataList(list, config);
714} 714}
715 715
716void Highlight::getItemDataList(ItemDataList &list, KConfig *config) { 716void Highlight::getItemDataList(ItemDataList &list, KateConfig *config) {
717 ItemData *p; 717 ItemData *p;
718 QString s; 718 QString s;
719 QRgb col, selCol; 719 QRgb col, selCol;
720 720
721 list.clear(); 721 list.clear();
722//JW list.setAutoDelete(true); 722//JW list.setAutoDelete(true);
723 createItemData(list); 723 createItemData(list);
724 724
725 for (p = list.first(); p != 0L; p = list.next()) { 725 for (p = list.first(); p != 0L; p = list.next()) {
726 s = config->readEntry(p->name); 726 s = config->readEntry(p->name);
727 if (!s.isEmpty()) { 727 if (!s.isEmpty()) {
728 sscanf(s.latin1(),"%d,%X,%X,%d,%d", &p->defStyle,&col,&selCol,&p->bold,&p->italic); 728 sscanf(s.latin1(),"%d,%X,%X,%d,%d", &p->defStyle,&col,&selCol,&p->bold,&p->italic);
729 p->col.setRgb(col); 729 p->col.setRgb(col);
730 p->selCol.setRgb(selCol); 730 p->selCol.setRgb(selCol);
731 } 731 }
732 } 732 }
733} 733}
734 734
735/******************************************************************************************* 735/*******************************************************************************************
736 Highlight - setItemDataList 736 Highlight - setItemDataList
737 saves the ItemData / attribute / style definitions to the apps configfile. 737 saves the ItemData / attribute / style definitions to the apps configfile.
738 Especially needed for user overridden values. 738 Especially needed for user overridden values.
739 739
740 * input: ItemDataList &list :reference to the list, whose 740 * input: ItemDataList &list :reference to the list, whose
741 * items should be saved 741 * items should be saved
742 * KConfig *config :Pointer KDE configuration 742 * KateConfig *config :Pointer KDE configuration
743 * class, which should be used 743 * class, which should be used
744 * as storage 744 * as storage
745 ************* 745 *************
746 * output: none 746 * output: none
747 ************* 747 *************
748 * return value: none 748 * return value: none
749*******************************************************************************************/ 749*******************************************************************************************/
750 750
751void Highlight::setItemDataList(ItemDataList &list, KConfig *config) { 751void Highlight::setItemDataList(ItemDataList &list, KateConfig *config) {
752 ItemData *p; 752 ItemData *p;
753 QString s; 753 QString s;
754 754
755 for (p = list.first(); p != 0L; p = list.next()) { 755 for (p = list.first(); p != 0L; p = list.next()) {
756 s.sprintf("%d,%X,%X,%d,%d", 756 s.sprintf("%d,%X,%X,%d,%d",
757 p->defStyle,p->col.rgb(),p->selCol.rgb(),p->bold,p->italic); 757 p->defStyle,p->col.rgb(),p->selCol.rgb(),p->bold,p->italic);
758 config->writeEntry(p->name,s); 758 config->writeEntry(p->name,s);
759 } 759 }
760} 760}
761 761
762 762
763/******************************************************************************************* 763/*******************************************************************************************
764 Highlight - use 764 Highlight - use
765 Increase the usage count and trigger initialization if needed 765 Increase the usage count and trigger initialization if needed
766 766
767 * input: none 767 * input: none
768 ************* 768 *************
769 * output: none 769 * output: none
770 ************* 770 *************
771 * return value: none 771 * return value: none
772*******************************************************************************************/ 772*******************************************************************************************/
773 773
774void Highlight::use() 774void Highlight::use()
775{ 775{
776 if (refCount == 0) init(); 776 if (refCount == 0) init();
777 refCount++; 777 refCount++;
778} 778}
779 779
780 780
781/******************************************************************************************* 781/*******************************************************************************************
782 Highlight - release 782 Highlight - release
783 Decrease the usage count and trigger a cleanup if needed 783 Decrease the usage count and trigger a cleanup if needed
784 784
785 * input: none 785 * input: none
786 ************* 786 *************
787 * output: none 787 * output: none
788 ************* 788 *************
789 * return value: none 789 * return value: none
790*******************************************************************************************/ 790*******************************************************************************************/
791 791
792void Highlight::release() 792void Highlight::release()
793{ 793{
794 refCount--; 794 refCount--;
795 if (refCount == 0) done(); 795 if (refCount == 0) done();
796} 796}
797 797
798/******************************************************************************************* 798/*******************************************************************************************
799 Highlight - init 799 Highlight - init
800 If it's the first time a particular highlighting is used create the needed contextlist 800 If it's the first time a particular highlighting is used create the needed contextlist
801 801
802 * input: none 802 * input: none
803 ************* 803 *************
804 * output: none 804 * output: none
805 ************* 805 *************
806 * return value: none 806 * return value: none
807*******************************************************************************************/ 807*******************************************************************************************/
808 808
809void Highlight::init() 809void Highlight::init()
810{ 810{
811 if (noHl) 811 if (noHl)
812 return; 812 return;
813 813
814 for (int z = 0; z < nContexts; z++) contextList[z] = 0L; 814 for (int z = 0; z < nContexts; z++) contextList[z] = 0L;
815 makeContextList(); 815 makeContextList();
816} 816}
817 817
818 818
819/******************************************************************************************* 819/*******************************************************************************************
820 Highlight - done 820 Highlight - done
821 If the there is no document using the highlighting style free the complete context 821 If the there is no document using the highlighting style free the complete context
822 structure. 822 structure.
823 823
824 * input: none 824 * input: none
825 ************* 825 *************
826 * output: none 826 * output: none
827 ************* 827 *************
828 * return value: none 828 * return value: none
829*******************************************************************************************/ 829*******************************************************************************************/
830 830
831void Highlight::done() 831void Highlight::done()
832{ 832{
833 if (noHl) 833 if (noHl)
834 return; 834 return;
835 835
836 for (int z = 0; z < nContexts; z++) delete contextList[z]; 836 for (int z = 0; z < nContexts; z++) delete contextList[z];
837} 837}
838 838
839 839
840/******************************************************************************************* 840/*******************************************************************************************
841 Highlight - createItemData 841 Highlight - createItemData
842 This function reads the itemData entries from the config file, which specifies the 842 This function reads the itemData entries from the config file, which specifies the
843 default attribute styles for matched items/contexts. 843 default attribute styles for matched items/contexts.
844 844
845 * input: none 845 * input: none
846 ************* 846 *************
847 * output: ItemDataList &list :A reference to the internal 847 * output: ItemDataList &list :A reference to the internal
848 list containing the parsed 848 list containing the parsed
849 default config 849 default config
850 ************* 850 *************
851 * return value: none 851 * return value: none
852*******************************************************************************************/ 852*******************************************************************************************/
853 853
854void Highlight::createItemData(ItemDataList &list) 854void Highlight::createItemData(ItemDataList &list)
855{ 855{
856 qDebug("Highlight::createItemData"); 856 qDebug("Highlight::createItemData");
857 857
858 // If no highlighting is selected we need only one default. 858 // If no highlighting is selected we need only one default.
859 if (noHl) 859 if (noHl)
860 { 860 {
861 list.append(new ItemData(I18N_NOOP("Normal Text"), dsNormal)); 861 list.append(new ItemData(I18N_NOOP("Normal Text"), dsNormal));
862 return; 862 return;
863 } 863 }
864 864
865 QString color; 865 QString color;
866 QString selColor; 866 QString selColor;
867 QString bold; 867 QString bold;
868 QString italic; 868 QString italic;
869 869
870 // If the internal list isn't already available read the config file 870 // If the internal list isn't already available read the config file
871 if (internalIDList.count()==0) 871 if (internalIDList.count()==0)
872 { 872 {
873 //if all references to the list are destried the contents will also be deleted 873 //if all references to the list are destried the contents will also be deleted
874 internalIDList.setAutoDelete(true); 874 internalIDList.setAutoDelete(true);
875 syntaxContextData *data; 875 syntaxContextData *data;
876 876
877 qDebug("Trying to read itemData section"); 877 qDebug("Trying to read itemData section");
878 878
879 //Tell the syntax document class which file we want to parse and which data group 879 //Tell the syntax document class which file we want to parse and which data group
@@ -1141,319 +1141,319 @@ void Highlight::readGlobalKeywordConfig()
1141 casesensitive=true; 1141 casesensitive=true;
1142 weakDeliminator=QString(""); 1142 weakDeliminator=QString("");
1143 } 1143 }
1144 1144
1145} 1145}
1146 1146
1147/******************************************************************************************* 1147/*******************************************************************************************
1148 Highlight - makeContextList 1148 Highlight - makeContextList
1149 That's the most important initialization function for each highlighting. It's called 1149 That's the most important initialization function for each highlighting. It's called
1150 each time a document gets a highlighting style assigned. parses the xml file and 1150 each time a document gets a highlighting style assigned. parses the xml file and
1151 creates a corresponding internal structure 1151 creates a corresponding internal structure
1152 1152
1153 * input: none 1153 * input: none
1154 ************* 1154 *************
1155 * output: none 1155 * output: none
1156 ************* 1156 *************
1157 * return value: none 1157 * return value: none
1158*******************************************************************************************/ 1158*******************************************************************************************/
1159 1159
1160 1160
1161void Highlight::makeContextList() 1161void Highlight::makeContextList()
1162{ 1162{
1163 if (noHl) 1163 if (noHl)
1164 return; 1164 return;
1165 1165
1166 HlKeyword *keyword=0, *dataType=0; 1166 HlKeyword *keyword=0, *dataType=0;
1167 syntaxContextData *data, *datasub; 1167 syntaxContextData *data, *datasub;
1168 HlItem *c; 1168 HlItem *c;
1169 1169
1170 readCommentConfig(); 1170 readCommentConfig();
1171 readGlobalKeywordConfig(); 1171 readGlobalKeywordConfig();
1172 1172
1173 // Let the syntax document class know, which file we'd like to parse 1173 // Let the syntax document class know, which file we'd like to parse
1174 HlManager::self()->syntax->setIdentifier(identifier); 1174 HlManager::self()->syntax->setIdentifier(identifier);
1175 1175
1176 // This list is needed for the translation of the attribute parameter, if the itemData name is given instead of the index 1176 // This list is needed for the translation of the attribute parameter, if the itemData name is given instead of the index
1177 ItemDataList iDl; 1177 ItemDataList iDl;
1178 createItemData(iDl); 1178 createItemData(iDl);
1179 1179
1180 //start the real work 1180 //start the real work
1181 data=HlManager::self()->syntax->getGroupInfo("highlighting","context"); 1181 data=HlManager::self()->syntax->getGroupInfo("highlighting","context");
1182 int i=0; 1182 int i=0;
1183 if (data) 1183 if (data)
1184 { 1184 {
1185 while (HlManager::self()->syntax->nextGroup(data)) 1185 while (HlManager::self()->syntax->nextGroup(data))
1186 { 1186 {
1187 1187
1188 // BEGIN - Translation of the attribute parameter 1188 // BEGIN - Translation of the attribute parameter
1189 QString tmpAttr=HlManager::self()->syntax->groupData(data,QString("attribute")).simplifyWhiteSpace(); 1189 QString tmpAttr=HlManager::self()->syntax->groupData(data,QString("attribute")).simplifyWhiteSpace();
1190 int attr; 1190 int attr;
1191 if (QString("%1").arg(tmpAttr.toInt())==tmpAttr) 1191 if (QString("%1").arg(tmpAttr.toInt())==tmpAttr)
1192 attr=tmpAttr.toInt(); 1192 attr=tmpAttr.toInt();
1193 else 1193 else
1194 attr=lookupAttrName(tmpAttr,iDl); 1194 attr=lookupAttrName(tmpAttr,iDl);
1195 // END - Translation of the attribute parameter 1195 // END - Translation of the attribute parameter
1196 1196
1197 contextList[i]=new HlContext( 1197 contextList[i]=new HlContext(
1198 attr, 1198 attr,
1199 (HlManager::self()->syntax->groupData(data,QString("lineEndContext"))).toInt(), 1199 (HlManager::self()->syntax->groupData(data,QString("lineEndContext"))).toInt(),
1200 (HlManager::self()->syntax->groupData(data,QString("lineBeginContext"))).isEmpty()?-1: 1200 (HlManager::self()->syntax->groupData(data,QString("lineBeginContext"))).isEmpty()?-1:
1201 (HlManager::self()->syntax->groupData(data,QString("lineBeginContext"))).toInt()); 1201 (HlManager::self()->syntax->groupData(data,QString("lineBeginContext"))).toInt());
1202 1202
1203 1203
1204 //Let's create all items for the context 1204 //Let's create all items for the context
1205 while (HlManager::self()->syntax->nextItem(data)) 1205 while (HlManager::self()->syntax->nextItem(data))
1206 { 1206 {
1207 // kdDebug(13010)<< "In make Contextlist: Item:"<<endl; 1207 // kdDebug(13010)<< "In make Contextlist: Item:"<<endl;
1208 c=createHlItem(data,iDl); 1208 c=createHlItem(data,iDl);
1209 if (c) 1209 if (c)
1210 { 1210 {
1211 contextList[i]->items.append(c); 1211 contextList[i]->items.append(c);
1212 1212
1213 // Not supported completely atm and only one level. Subitems.(all have to be matched to at once) 1213 // Not supported completely atm and only one level. Subitems.(all have to be matched to at once)
1214 datasub=HlManager::self()->syntax->getSubItems(data); 1214 datasub=HlManager::self()->syntax->getSubItems(data);
1215 bool tmpbool; 1215 bool tmpbool;
1216 if (tmpbool=HlManager::self()->syntax->nextItem(datasub)) 1216 if (tmpbool=HlManager::self()->syntax->nextItem(datasub))
1217 { 1217 {
1218 c->subItems=new QList<HlItem>; 1218 c->subItems=new QList<HlItem>;
1219 for (;tmpbool;tmpbool=HlManager::self()->syntax->nextItem(datasub)) 1219 for (;tmpbool;tmpbool=HlManager::self()->syntax->nextItem(datasub))
1220 c->subItems->append(createHlItem(datasub,iDl)); 1220 c->subItems->append(createHlItem(datasub,iDl));
1221 } 1221 }
1222 HlManager::self()->syntax->freeGroupInfo(datasub); 1222 HlManager::self()->syntax->freeGroupInfo(datasub);
1223 // end of sublevel 1223 // end of sublevel
1224 } 1224 }
1225 // kdDebug(13010)<<"Last line in loop"<<endl; 1225 // kdDebug(13010)<<"Last line in loop"<<endl;
1226 } 1226 }
1227 i++; 1227 i++;
1228 } 1228 }
1229 } 1229 }
1230 1230
1231 HlManager::self()->syntax->freeGroupInfo(data); 1231 HlManager::self()->syntax->freeGroupInfo(data);
1232 1232
1233 1233
1234} 1234}
1235 1235
1236HlManager::HlManager() : QObject(0L) 1236HlManager::HlManager() : QObject(0L)
1237{ 1237{
1238 syntax = new SyntaxDocument(); 1238 syntax = new SyntaxDocument();
1239 SyntaxModeList modeList = syntax->modeList(); 1239 SyntaxModeList modeList = syntax->modeList();
1240 1240
1241 hlList.setAutoDelete(true); 1241 hlList.setAutoDelete(true);
1242 hlList.append(new Highlight(0)); 1242 hlList.append(new Highlight(0));
1243 1243
1244 uint i=0; 1244 uint i=0;
1245 while (i < modeList.count()) 1245 while (i < modeList.count())
1246 { 1246 {
1247 hlList.append(new Highlight(modeList.at(i))); 1247 hlList.append(new Highlight(modeList.at(i)));
1248 i++; 1248 i++;
1249 } 1249 }
1250} 1250}
1251 1251
1252HlManager::~HlManager() { 1252HlManager::~HlManager() {
1253 if(syntax) delete syntax; 1253 if(syntax) delete syntax;
1254} 1254}
1255 1255
1256HlManager *HlManager::self() 1256HlManager *HlManager::self()
1257{ 1257{
1258 if ( !s_pSelf ) 1258 if ( !s_pSelf )
1259 s_pSelf = new HlManager; 1259 s_pSelf = new HlManager;
1260 return s_pSelf; 1260 return s_pSelf;
1261} 1261}
1262 1262
1263Highlight *HlManager::getHl(int n) { 1263Highlight *HlManager::getHl(int n) {
1264 if (n < 0 || n >= (int) hlList.count()) n = 0; 1264 if (n < 0 || n >= (int) hlList.count()) n = 0;
1265 return hlList.at(n); 1265 return hlList.at(n);
1266} 1266}
1267 1267
1268int HlManager::defaultHl() { 1268int HlManager::defaultHl() {
1269 KConfig *config; 1269 KateConfig *config;
1270 config = KGlobal::config(); 1270 config = KGlobal::config();
1271 config->setGroup("General Options"); 1271 config->setGroup("General Options");
1272 1272
1273#warning fixme return nameFind(config->readEntry("Highlight")); 1273#warning fixme return nameFind(config->readEntry("Highlight"));
1274 1274
1275} 1275}
1276 1276
1277 1277
1278int HlManager::nameFind(const QString &name) { 1278int HlManager::nameFind(const QString &name) {
1279 int z; 1279 int z;
1280 1280
1281 for (z = hlList.count() - 1; z > 0; z--) { 1281 for (z = hlList.count() - 1; z > 0; z--) {
1282 if (hlList.at(z)->iName == name) break; 1282 if (hlList.at(z)->iName == name) break;
1283 } 1283 }
1284 return z; 1284 return z;
1285} 1285}
1286 1286
1287int HlManager::wildcardFind(const QString &fileName) { 1287int HlManager::wildcardFind(const QString &fileName) {
1288 Highlight *highlight; 1288 Highlight *highlight;
1289 int p1, p2; 1289 int p1, p2;
1290 QString w; 1290 QString w;
1291 for (highlight = hlList.first(); highlight != 0L; highlight = hlList.next()) { 1291 for (highlight = hlList.first(); highlight != 0L; highlight = hlList.next()) {
1292 p1 = 0; 1292 p1 = 0;
1293 w = highlight->getWildcards(); 1293 w = highlight->getWildcards();
1294 while (p1 < (int) w.length()) { 1294 while (p1 < (int) w.length()) {
1295 p2 = w.find(';',p1); 1295 p2 = w.find(';',p1);
1296 if (p2 == -1) p2 = w.length(); 1296 if (p2 == -1) p2 = w.length();
1297 if (p1 < p2) { 1297 if (p1 < p2) {
1298 QRegExp regExp(w.mid(p1,p2 - p1),true,true); 1298 QRegExp regExp(w.mid(p1,p2 - p1),true,true);
1299 if (regExp.match(fileName) == 0) return hlList.at(); 1299 if (regExp.match(fileName) == 0) return hlList.at();
1300 } 1300 }
1301 p1 = p2 + 1; 1301 p1 = p2 + 1;
1302 } 1302 }
1303 } 1303 }
1304 return -1; 1304 return -1;
1305} 1305}
1306 1306
1307 1307
1308int HlManager::makeAttribs(Highlight *highlight, Attribute *a, int maxAttribs) { 1308int HlManager::makeAttribs(Highlight *highlight, Attribute *a, int maxAttribs) {
1309 ItemStyleList defaultStyleList; 1309 ItemStyleList defaultStyleList;
1310 ItemStyle *defaultStyle; 1310 ItemStyle *defaultStyle;
1311 ItemDataList itemDataList; 1311 ItemDataList itemDataList;
1312 ItemData *itemData; 1312 ItemData *itemData;
1313 int nAttribs, z; 1313 int nAttribs, z;
1314 1314
1315 qDebug("HlManager::makeAttribs"); 1315 qDebug("HlManager::makeAttribs");
1316 1316
1317 defaultStyleList.setAutoDelete(true); 1317 defaultStyleList.setAutoDelete(true);
1318 getDefaults(defaultStyleList); 1318 getDefaults(defaultStyleList);
1319 1319
1320// itemDataList.setAutoDelete(true); 1320// itemDataList.setAutoDelete(true);
1321 highlight->getItemDataList(itemDataList); 1321 highlight->getItemDataList(itemDataList);
1322 nAttribs = itemDataList.count(); 1322 nAttribs = itemDataList.count();
1323 for (z = 0; z < nAttribs; z++) { 1323 for (z = 0; z < nAttribs; z++) {
1324 qDebug("HlManager::makeAttribs: createing one attribute definition"); 1324 qDebug("HlManager::makeAttribs: createing one attribute definition");
1325 itemData = itemDataList.at(z); 1325 itemData = itemDataList.at(z);
1326 if (itemData->defStyle) { 1326 if (itemData->defStyle) {
1327 // default style 1327 // default style
1328 defaultStyle = defaultStyleList.at(itemData->defStyleNum); 1328 defaultStyle = defaultStyleList.at(itemData->defStyleNum);
1329 a[z].col = defaultStyle->col; 1329 a[z].col = defaultStyle->col;
1330 a[z].selCol = defaultStyle->selCol; 1330 a[z].selCol = defaultStyle->selCol;
1331 a[z].bold = defaultStyle->bold; 1331 a[z].bold = defaultStyle->bold;
1332 a[z].italic = defaultStyle->italic; 1332 a[z].italic = defaultStyle->italic;
1333 } else { 1333 } else {
1334 // custom style 1334 // custom style
1335 a[z].col = itemData->col; 1335 a[z].col = itemData->col;
1336 a[z].selCol = itemData->selCol; 1336 a[z].selCol = itemData->selCol;
1337 a[z].bold = itemData->bold; 1337 a[z].bold = itemData->bold;
1338 a[z].italic = itemData->italic; 1338 a[z].italic = itemData->italic;
1339 } 1339 }
1340 } 1340 }
1341 1341
1342 for (; z < maxAttribs; z++) { 1342 for (; z < maxAttribs; z++) {
1343 a[z].col = black; 1343 a[z].col = black;
1344 a[z].selCol = black; 1344 a[z].selCol = black;
1345 a[z].bold = defaultStyle->bold; 1345 a[z].bold = defaultStyle->bold;
1346 a[z].italic = defaultStyle->italic; 1346 a[z].italic = defaultStyle->italic;
1347 } 1347 }
1348 return nAttribs; 1348 return nAttribs;
1349} 1349}
1350 1350
1351int HlManager::defaultStyles() { 1351int HlManager::defaultStyles() {
1352 return 10; 1352 return 10;
1353} 1353}
1354 1354
1355QString HlManager::defaultStyleName(int n) 1355QString HlManager::defaultStyleName(int n)
1356{ 1356{
1357 static QStringList names; 1357 static QStringList names;
1358 1358
1359 if (names.isEmpty()) 1359 if (names.isEmpty())
1360 { 1360 {
1361 names << i18n("Normal"); 1361 names << i18n("Normal");
1362 names << i18n("Keyword"); 1362 names << i18n("Keyword");
1363 names << i18n("Data Type"); 1363 names << i18n("Data Type");
1364 names << i18n("Decimal/Value"); 1364 names << i18n("Decimal/Value");
1365 names << i18n("Base-N Integer"); 1365 names << i18n("Base-N Integer");
1366 names << i18n("Floating Point"); 1366 names << i18n("Floating Point");
1367 names << i18n("Character"); 1367 names << i18n("Character");
1368 names << i18n("String"); 1368 names << i18n("String");
1369 names << i18n("Comment"); 1369 names << i18n("Comment");
1370 names << i18n("Others"); 1370 names << i18n("Others");
1371 } 1371 }
1372 1372
1373 return names[n]; 1373 return names[n];
1374} 1374}
1375 1375
1376void HlManager::getDefaults(ItemStyleList &list) { 1376void HlManager::getDefaults(ItemStyleList &list) {
1377 KConfig *config; 1377 KateConfig *config;
1378 int z; 1378 int z;
1379 ItemStyle *i; 1379 ItemStyle *i;
1380 QString s; 1380 QString s;
1381 QRgb col, selCol; 1381 QRgb col, selCol;
1382 1382
1383 list.setAutoDelete(true); 1383 list.setAutoDelete(true);
1384 //ItemStyle(color, selected color, bold, italic) 1384 //ItemStyle(color, selected color, bold, italic)
1385 list.append(new ItemStyle(black,white,false,false)); //normal 1385 list.append(new ItemStyle(black,white,false,false)); //normal
1386 list.append(new ItemStyle(black,white,true,false)); //keyword 1386 list.append(new ItemStyle(black,white,true,false)); //keyword
1387 list.append(new ItemStyle(darkRed,white,false,false)); //datatype 1387 list.append(new ItemStyle(darkRed,white,false,false)); //datatype
1388 list.append(new ItemStyle(blue,cyan,false,false)); //decimal/value 1388 list.append(new ItemStyle(blue,cyan,false,false)); //decimal/value
1389 list.append(new ItemStyle(darkCyan,cyan,false,false)); //base n 1389 list.append(new ItemStyle(darkCyan,cyan,false,false)); //base n
1390 list.append(new ItemStyle(darkMagenta,cyan,false,false));//float 1390 list.append(new ItemStyle(darkMagenta,cyan,false,false));//float
1391 list.append(new ItemStyle(magenta,magenta,false,false)); //char 1391 list.append(new ItemStyle(magenta,magenta,false,false)); //char
1392 list.append(new ItemStyle(red,red,false,false)); //string 1392 list.append(new ItemStyle(red,red,false,false)); //string
1393 list.append(new ItemStyle(darkGray,gray,false,true)); //comment 1393 list.append(new ItemStyle(darkGray,gray,false,true)); //comment
1394 list.append(new ItemStyle(darkGreen,green,false,false)); //others 1394 list.append(new ItemStyle(darkGreen,green,false,false)); //others
1395 1395
1396#warning fixme 1396#warning fixme
1397/* 1397/*
1398 config = KateFactory::instance()->config(); 1398 config = KateFactory::instance()->config();
1399 config->setGroup("Default Item Styles"); 1399 config->setGroup("Default Item Styles");
1400 for (z = 0; z < defaultStyles(); z++) { 1400 for (z = 0; z < defaultStyles(); z++) {
1401 i = list.at(z); 1401 i = list.at(z);
1402 s = config->readEntry(defaultStyleName(z)); 1402 s = config->readEntry(defaultStyleName(z));
1403 if (!s.isEmpty()) { 1403 if (!s.isEmpty()) {
1404 sscanf(s.latin1(),"%X,%X,%d,%d",&col,&selCol,&i->bold,&i->italic); 1404 sscanf(s.latin1(),"%X,%X,%d,%d",&col,&selCol,&i->bold,&i->italic);
1405 i->col.setRgb(col); 1405 i->col.setRgb(col);
1406 i->selCol.setRgb(selCol); 1406 i->selCol.setRgb(selCol);
1407 } 1407 }
1408 } 1408 }
1409*/ 1409*/
1410} 1410}
1411 1411
1412void HlManager::setDefaults(ItemStyleList &list) { 1412void HlManager::setDefaults(ItemStyleList &list) {
1413 KConfig *config; 1413 KateConfig *config;
1414 int z; 1414 int z;
1415 ItemStyle *i; 1415 ItemStyle *i;
1416 char s[64]; 1416 char s[64];
1417#warning fixme 1417#warning fixme
1418/* 1418/*
1419 config = KateFactory::instance()->config(); 1419 config = KateFactory::instance()->config();
1420 config->setGroup("Default Item Styles"); 1420 config->setGroup("Default Item Styles");
1421 for (z = 0; z < defaultStyles(); z++) { 1421 for (z = 0; z < defaultStyles(); z++) {
1422 i = list.at(z); 1422 i = list.at(z);
1423 sprintf(s,"%X,%X,%d,%d",i->col.rgb(),i->selCol.rgb(),i->bold, i->italic); 1423 sprintf(s,"%X,%X,%d,%d",i->col.rgb(),i->selCol.rgb(),i->bold, i->italic);
1424 config->writeEntry(defaultStyleName(z),s); 1424 config->writeEntry(defaultStyleName(z),s);
1425 } 1425 }
1426*/ 1426*/
1427 emit changed(); 1427 emit changed();
1428} 1428}
1429 1429
1430 1430
1431int HlManager::highlights() { 1431int HlManager::highlights() {
1432 return (int) hlList.count(); 1432 return (int) hlList.count();
1433} 1433}
1434 1434
1435QString HlManager::hlName(int n) { 1435QString HlManager::hlName(int n) {
1436 return hlList.at(n)->iName; 1436 return hlList.at(n)->iName;
1437} 1437}
1438 1438
1439QString HlManager::hlSection(int n) { 1439QString HlManager::hlSection(int n) {
1440 return hlList.at(n)->iSection; 1440 return hlList.at(n)->iSection;
1441} 1441}
1442 1442
1443void HlManager::getHlDataList(HlDataList &list) { 1443void HlManager::getHlDataList(HlDataList &list) {
1444 int z; 1444 int z;
1445 1445
1446 for (z = 0; z < (int) hlList.count(); z++) { 1446 for (z = 0; z < (int) hlList.count(); z++) {
1447 list.append(hlList.at(z)->getData()); 1447 list.append(hlList.at(z)->getData());
1448 } 1448 }
1449} 1449}
1450 1450
1451void HlManager::setHlDataList(HlDataList &list) { 1451void HlManager::setHlDataList(HlDataList &list) {
1452 int z; 1452 int z;
1453 1453
1454 for (z = 0; z < (int) hlList.count(); z++) { 1454 for (z = 0; z < (int) hlList.count(); z++) {
1455 hlList.at(z)->setData(list.at(z)); 1455 hlList.at(z)->setData(list.at(z));
1456 } 1456 }
1457 //notify documents about changes in highlight configuration 1457 //notify documents about changes in highlight configuration
1458 emit changed(); 1458 emit changed();
1459} 1459}
diff --git a/noncore/apps/tinykate/libkate/document/katehighlight.h b/noncore/apps/tinykate/libkate/document/katehighlight.h
index 1baddcc..fddf585 100644
--- a/noncore/apps/tinykate/libkate/document/katehighlight.h
+++ b/noncore/apps/tinykate/libkate/document/katehighlight.h
@@ -111,239 +111,239 @@ class HlKeyword : public HlItem
111 bool _caseSensitive; 111 bool _caseSensitive;
112 const QChar *deliminatorChars; 112 const QChar *deliminatorChars;
113 uint deliminatorLen; 113 uint deliminatorLen;
114}; 114};
115 115
116class HlPHex : public HlItem { 116class HlPHex : public HlItem {
117 public: 117 public:
118 HlPHex(int attribute,int context); 118 HlPHex(int attribute,int context);
119 virtual const QChar *checkHgl(const QChar *, int len, bool); 119 virtual const QChar *checkHgl(const QChar *, int len, bool);
120}; 120};
121class HlInt : public HlItem { 121class HlInt : public HlItem {
122 public: 122 public:
123 HlInt(int attribute, int context); 123 HlInt(int attribute, int context);
124 virtual const QChar *checkHgl(const QChar *, int len, bool); 124 virtual const QChar *checkHgl(const QChar *, int len, bool);
125}; 125};
126 126
127class HlFloat : public HlItem { 127class HlFloat : public HlItem {
128 public: 128 public:
129 HlFloat(int attribute, int context); 129 HlFloat(int attribute, int context);
130 virtual const QChar *checkHgl(const QChar *, int len, bool); 130 virtual const QChar *checkHgl(const QChar *, int len, bool);
131}; 131};
132 132
133class HlCInt : public HlInt { 133class HlCInt : public HlInt {
134 public: 134 public:
135 HlCInt(int attribute, int context); 135 HlCInt(int attribute, int context);
136 virtual const QChar *checkHgl(const QChar *, int len, bool); 136 virtual const QChar *checkHgl(const QChar *, int len, bool);
137}; 137};
138 138
139class HlCOct : public HlItem { 139class HlCOct : public HlItem {
140 public: 140 public:
141 HlCOct(int attribute, int context); 141 HlCOct(int attribute, int context);
142 virtual const QChar *checkHgl(const QChar *, int len, bool); 142 virtual const QChar *checkHgl(const QChar *, int len, bool);
143}; 143};
144 144
145class HlCHex : public HlItem { 145class HlCHex : public HlItem {
146 public: 146 public:
147 HlCHex(int attribute, int context); 147 HlCHex(int attribute, int context);
148 virtual const QChar *checkHgl(const QChar *, int len, bool); 148 virtual const QChar *checkHgl(const QChar *, int len, bool);
149}; 149};
150 150
151class HlCFloat : public HlFloat { 151class HlCFloat : public HlFloat {
152 public: 152 public:
153 HlCFloat(int attribute, int context); 153 HlCFloat(int attribute, int context);
154 virtual const QChar *checkHgl(const QChar *, int len, bool); 154 virtual const QChar *checkHgl(const QChar *, int len, bool);
155}; 155};
156 156
157class HlLineContinue : public HlItem { 157class HlLineContinue : public HlItem {
158 public: 158 public:
159 HlLineContinue(int attribute, int context); 159 HlLineContinue(int attribute, int context);
160 virtual bool endEnable(QChar c) {return c == '\0';} 160 virtual bool endEnable(QChar c) {return c == '\0';}
161 virtual const QChar *checkHgl(const QChar *, int len, bool); 161 virtual const QChar *checkHgl(const QChar *, int len, bool);
162}; 162};
163 163
164class HlCStringChar : public HlItem { 164class HlCStringChar : public HlItem {
165 public: 165 public:
166 HlCStringChar(int attribute, int context); 166 HlCStringChar(int attribute, int context);
167 virtual const QChar *checkHgl(const QChar *, int len, bool); 167 virtual const QChar *checkHgl(const QChar *, int len, bool);
168}; 168};
169 169
170class HlCChar : public HlItem { 170class HlCChar : public HlItem {
171 public: 171 public:
172 HlCChar(int attribute, int context); 172 HlCChar(int attribute, int context);
173 virtual const QChar *checkHgl(const QChar *, int len, bool); 173 virtual const QChar *checkHgl(const QChar *, int len, bool);
174}; 174};
175 175
176class HlAnyChar : public HlItem { 176class HlAnyChar : public HlItem {
177 public: 177 public:
178 HlAnyChar(int attribute, int context, const QChar* charList, uint len); 178 HlAnyChar(int attribute, int context, const QChar* charList, uint len);
179 virtual const QChar *checkHgl(const QChar *, int len, bool); 179 virtual const QChar *checkHgl(const QChar *, int len, bool);
180 const QChar* _charList; 180 const QChar* _charList;
181 uint _charListLen; 181 uint _charListLen;
182}; 182};
183 183
184class HlRegExpr : public HlItem { 184class HlRegExpr : public HlItem {
185 public: 185 public:
186 HlRegExpr(int attribute, int context,QString expr); 186 HlRegExpr(int attribute, int context,QString expr);
187 ~HlRegExpr(){delete Expr;}; 187 ~HlRegExpr(){delete Expr;};
188 virtual const QChar *checkHgl(const QChar *, int len, bool); 188 virtual const QChar *checkHgl(const QChar *, int len, bool);
189 QRegExp3 *Expr; 189 QRegExp3 *Expr;
190 bool handlesLinestart; 190 bool handlesLinestart;
191}; 191};
192 192
193//-------- 193//--------
194 194
195 195
196//Item Style: color, selected color, bold, italic 196//Item Style: color, selected color, bold, italic
197class ItemStyle { 197class ItemStyle {
198 public: 198 public:
199 ItemStyle(); 199 ItemStyle();
200// ItemStyle(const ItemStyle &); 200// ItemStyle(const ItemStyle &);
201 ItemStyle(const QColor &, const QColor &, bool bold, bool italic); 201 ItemStyle(const QColor &, const QColor &, bool bold, bool italic);
202 ItemStyle(ItemStyle *its){col=its->col;selCol=its->selCol; bold=its->bold; italic=its->italic;} 202 ItemStyle(ItemStyle *its){col=its->col;selCol=its->selCol; bold=its->bold; italic=its->italic;}
203// void setData(const ItemStyle &); 203// void setData(const ItemStyle &);
204 QColor col; 204 QColor col;
205 QColor selCol; 205 QColor selCol;
206 int bold; //boolean value 206 int bold; //boolean value
207 int italic; //boolean value 207 int italic; //boolean value
208}; 208};
209 209
210typedef QList<ItemStyle> ItemStyleList; 210typedef QList<ItemStyle> ItemStyleList;
211 211
212//Item Properties: name, Item Style, Item Font 212//Item Properties: name, Item Style, Item Font
213class ItemData : public ItemStyle { 213class ItemData : public ItemStyle {
214 public: 214 public:
215 ItemData(const QString name, int defStyleNum); 215 ItemData(const QString name, int defStyleNum);
216 ItemData(const QString name, int defStyleNum, 216 ItemData(const QString name, int defStyleNum,
217 const QColor&, const QColor&, bool bold, bool italic); 217 const QColor&, const QColor&, bool bold, bool italic);
218 ItemData(ItemData 218 ItemData(ItemData
219*itd):ItemStyle((ItemStyle*)itd),name(itd->name),defStyleNum(itd->defStyleNum),defStyle(itd->defStyle){;} 219*itd):ItemStyle((ItemStyle*)itd),name(itd->name),defStyleNum(itd->defStyleNum),defStyle(itd->defStyle){;}
220 const QString name; 220 const QString name;
221 int defStyleNum; 221 int defStyleNum;
222 int defStyle; //boolean value 222 int defStyle; //boolean value
223}; 223};
224 224
225typedef QList<ItemData> ItemDataList; 225typedef QList<ItemData> ItemDataList;
226 226
227class HlData { 227class HlData {
228 public: 228 public:
229 HlData(const QString &wildcards, const QString &mimetypes,const QString &identifier); 229 HlData(const QString &wildcards, const QString &mimetypes,const QString &identifier);
230 ItemDataList itemDataList; 230 ItemDataList itemDataList;
231 QString wildcards; 231 QString wildcards;
232 QString mimetypes; 232 QString mimetypes;
233 QString identifier; 233 QString identifier;
234}; 234};
235 235
236typedef QList<HlData> HlDataList; 236typedef QList<HlData> HlDataList;
237 237
238class HlManager; 238class HlManager;
239class KConfig; 239class KateConfig;
240 240
241//context 241//context
242class HlContext { 242class HlContext {
243 public: 243 public:
244 HlContext(int attribute, int lineEndContext,int _lineBeginContext); 244 HlContext(int attribute, int lineEndContext,int _lineBeginContext);
245 QList<HlItem> items; 245 QList<HlItem> items;
246 int attr; 246 int attr;
247 int ctx; 247 int ctx;
248 int lineBeginContext; 248 int lineBeginContext;
249}; 249};
250 250
251class Highlight 251class Highlight
252{ 252{
253 friend class HlManager; 253 friend class HlManager;
254 254
255 public: 255 public:
256 Highlight(syntaxModeListItem *def); 256 Highlight(syntaxModeListItem *def);
257 ~Highlight(); 257 ~Highlight();
258 258
259 int doHighlight(int ctxNum, TextLine *); 259 int doHighlight(int ctxNum, TextLine *);
260 260
261 KConfig *getKConfig(); 261 KateConfig *getKateConfig();
262 QString getWildcards(); 262 QString getWildcards();
263 QString getMimetypes(); 263 QString getMimetypes();
264 HlData *getData(); 264 HlData *getData();
265 void setData(HlData *); 265 void setData(HlData *);
266 void getItemDataList(ItemDataList &); 266 void getItemDataList(ItemDataList &);
267 void getItemDataList(ItemDataList &, KConfig *); 267 void getItemDataList(ItemDataList &, KateConfig *);
268 void setItemDataList(ItemDataList &, KConfig *); 268 void setItemDataList(ItemDataList &, KateConfig *);
269 QString name() {return iName;} 269 QString name() {return iName;}
270 QString section() {return iSection;} 270 QString section() {return iSection;}
271 void use(); 271 void use();
272 void release(); 272 void release();
273 bool isInWord(QChar c); 273 bool isInWord(QChar c);
274 274
275 QString getCommentStart() {return cmlStart;}; 275 QString getCommentStart() {return cmlStart;};
276 QString getCommentEnd() {return cmlEnd;}; 276 QString getCommentEnd() {return cmlEnd;};
277 QString getCommentSingleLineStart() { return cslStart;}; 277 QString getCommentSingleLineStart() { return cslStart;};
278 278
279 protected: 279 protected:
280 void init(); 280 void init();
281 void done(); 281 void done();
282 void makeContextList (); 282 void makeContextList ();
283 void createItemData (ItemDataList &list); 283 void createItemData (ItemDataList &list);
284 void readGlobalKeywordConfig(); 284 void readGlobalKeywordConfig();
285 void readCommentConfig(); 285 void readCommentConfig();
286 HlItem *createHlItem(struct syntaxContextData *data, ItemDataList &iDl); 286 HlItem *createHlItem(struct syntaxContextData *data, ItemDataList &iDl);
287 int lookupAttrName(const QString& name, ItemDataList &iDl); 287 int lookupAttrName(const QString& name, ItemDataList &iDl);
288 ItemDataList internalIDList; 288 ItemDataList internalIDList;
289 static const int nContexts = 32; 289 static const int nContexts = 32;
290 HlContext *contextList[nContexts]; 290 HlContext *contextList[nContexts];
291 291
292 bool noHl; 292 bool noHl;
293 bool casesensitive; 293 bool casesensitive;
294 QString weakDeliminator; 294 QString weakDeliminator;
295 QString deliminator; 295 QString deliminator;
296 const QChar *deliminatorChars; 296 const QChar *deliminatorChars;
297 uint deliminatorLen; 297 uint deliminatorLen;
298 QString cmlStart; 298 QString cmlStart;
299 QString cmlEnd; 299 QString cmlEnd;
300 QString cslStart; 300 QString cslStart;
301 QString iName; 301 QString iName;
302 QString iSection; 302 QString iSection;
303 QString iWildcards; 303 QString iWildcards;
304 QString iMimetypes; 304 QString iMimetypes;
305 QString identifier; 305 QString identifier;
306 int refCount; 306 int refCount;
307}; 307};
308 308
309class HlManager : public QObject { 309class HlManager : public QObject {
310 Q_OBJECT 310 Q_OBJECT
311 public: 311 public:
312 HlManager(); 312 HlManager();
313 ~HlManager(); 313 ~HlManager();
314 314
315 static HlManager *self(); 315 static HlManager *self();
316 316
317 Highlight *getHl(int n); 317 Highlight *getHl(int n);
318 int defaultHl(); 318 int defaultHl();
319 int nameFind(const QString &name); 319 int nameFind(const QString &name);
320 320
321 int wildcardFind(const QString &fileName); 321 int wildcardFind(const QString &fileName);
322 int findHl(Highlight *h) {return hlList.find(h);} 322 int findHl(Highlight *h) {return hlList.find(h);}
323 323
324 int makeAttribs(Highlight *, Attribute *, int maxAttribs); 324 int makeAttribs(Highlight *, Attribute *, int maxAttribs);
325 325
326 int defaultStyles(); 326 int defaultStyles();
327 QString defaultStyleName(int n); 327 QString defaultStyleName(int n);
328 void getDefaults(ItemStyleList &); 328 void getDefaults(ItemStyleList &);
329 void setDefaults(ItemStyleList &); 329 void setDefaults(ItemStyleList &);
330 330
331 int highlights(); 331 int highlights();
332 QString hlName(int n); 332 QString hlName(int n);
333 QString hlSection(int n); 333 QString hlSection(int n);
334 void getHlDataList(HlDataList &); 334 void getHlDataList(HlDataList &);
335 void setHlDataList(HlDataList &); 335 void setHlDataList(HlDataList &);
336 336
337 SyntaxDocument *syntax; 337 SyntaxDocument *syntax;
338 338
339 signals: 339 signals:
340 void changed(); 340 void changed();
341 protected: 341 protected:
342 QList<Highlight> hlList; 342 QList<Highlight> hlList;
343 static HlManager *s_pSelf; 343 static HlManager *s_pSelf;
344}; 344};
345 345
346 346
347 347
348 348
349#endif //_HIGHLIGHT_H_ 349#endif //_HIGHLIGHT_H_
diff --git a/noncore/apps/tinykate/libkate/document/katesyntaxdocument.cpp b/noncore/apps/tinykate/libkate/document/katesyntaxdocument.cpp
index e45daa4..844f27d 100644
--- a/noncore/apps/tinykate/libkate/document/katesyntaxdocument.cpp
+++ b/noncore/apps/tinykate/libkate/document/katesyntaxdocument.cpp
@@ -1,241 +1,235 @@
1/*************************************************************************** 1/***************************************************************************
2 katesyntaxdocument.cpp - description 2 katesyntaxdocument.cpp - description
3 ------------------- 3 -------------------
4 begin : Sat 31 March 2001 4 begin : Sat 31 March 2001
5 copyright : (C) 2001,2002 by Joseph Wenninger 5 copyright : (C) 2001,2002 by Joseph Wenninger
6 email : jowenn@kde.org 6 email : jowenn@kde.org
7 ***************************************************************************/ 7 ***************************************************************************/
8 8
9/*************************************************************************** 9/***************************************************************************
10 * * 10 * *
11 * This program is free software; you can redistribute it and/or modify * 11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by * 12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or * 13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. * 14 * (at your option) any later version. *
15 * * 15 * *
16 ***************************************************************************/ 16 ***************************************************************************/
17 17
18#include "katesyntaxdocument.h" 18#include "katesyntaxdocument.h"
19#include <kateconfig.h>
19#include <qfile.h> 20#include <qfile.h>
20#include <kdebug.h> 21#include <kdebug.h>
21#include <kstddirs.h> 22#include <kstddirs.h>
22#include <klocale.h> 23#include <klocale.h>
23#include <kmessagebox.h> 24#include <kmessagebox.h>
24#include <qstringlist.h> 25#include <qstringlist.h>
25#include <kconfig.h>
26#include <kglobal.h> 26#include <kglobal.h>
27#include <qpe/qpeapplication.h> 27#include <qpe/qpeapplication.h>
28#include <qdir.h> 28#include <qdir.h>
29 29
30SyntaxDocument::SyntaxDocument() 30SyntaxDocument::SyntaxDocument()
31{ 31{
32 m_root=0; 32 m_root=0;
33 currentFile=""; 33 currentFile="";
34 setupModeList(); 34 setupModeList();
35} 35}
36 36
37void SyntaxDocument::setIdentifier(const QString& identifier) 37void SyntaxDocument::setIdentifier(const QString& identifier)
38{ 38{
39#warning FIXME delete m_root; 39#warning FIXME delete m_root;
40 m_root=Opie::XMLElement::load(identifier); 40 m_root=Opie::XMLElement::load(identifier);
41 if (!m_root) KMessageBox::error( 0L, i18n("Can't open %1").arg(identifier) ); 41 if (!m_root) KMessageBox::error( 0L, i18n("Can't open %1").arg(identifier) );
42 42
43} 43}
44 44
45SyntaxDocument::~SyntaxDocument() 45SyntaxDocument::~SyntaxDocument()
46{ 46{
47} 47}
48 48
49void SyntaxDocument::setupModeList(bool force) 49void SyntaxDocument::setupModeList(bool force)
50{ 50{
51 51
52 if (myModeList.count() > 0) return; 52 if (myModeList.count() > 0) return;
53 53
54 KConfig *config=KGlobal::config(); 54 KateConfig *config=KGlobal::config();
55 KStandardDirs *dirs = KGlobal::dirs(); 55 KStandardDirs *dirs = KGlobal::dirs();
56 56
57// QStringList list=dirs->findAllResources("data","kate/syntax/*.xml",false,true); 57// QStringList list=dirs->findAllResources("data","kate/syntax/*.xml",false,true);
58 QString path=QPEApplication::qpeDir() +"share/tinykate/syntax/"; 58 QString path=QPEApplication::qpeDir() +"share/tinykate/syntax/";
59 59
60 QDir dir(path); 60 QDir dir(path);
61 QStringList list=dir.entryList("*.xml"); 61 QStringList list=dir.entryList("*.xml");
62 62
63 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) 63 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it )
64 { 64 {
65 QString Group="Highlighting_Cache"+path+*it; 65 QString Group="Highlighting_Cache"+path+*it;
66
67 if ((config->hasGroup(Group)) && (!force)) 66 if ((config->hasGroup(Group)) && (!force))
68 { 67 {
69 config->setGroup(Group); 68 config->setGroup(Group);
70 syntaxModeListItem *mli=new syntaxModeListItem; 69 syntaxModeListItem *mli=new syntaxModeListItem;
71 mli->name = config->readEntry("name",""); 70 mli->name = config->readEntry("name","");
72 mli->section = config->readEntry("section",""); 71 mli->section = config->readEntry("section","");
73 mli->mimetype = config->readEntry("mimetype",""); 72 mli->mimetype = config->readEntry("mimetype","");
74 mli->extension = config->readEntry("extension",""); 73 mli->extension = config->readEntry("extension","");
75 mli->identifier = *it; 74 mli->identifier = *it;
76 myModeList.append(mli); 75 myModeList.append(mli);
77 } 76 }
78 else 77 else
79 { 78 {
80 qDebug("Found a description file:"+path+(*it)); 79 qDebug("Found a description file:"+path+(*it));
81 setIdentifier(path+(*it)); 80 setIdentifier(path+(*it));
82 Opie::XMLElement *e=m_root; 81 Opie::XMLElement *e=m_root;
83 if (e) 82 if (e)
84 { 83 {
85 e=e->firstChild(); 84 e=e->firstChild();
86 qDebug(e->tagName()); 85 qDebug(e->tagName());
87 if (e->tagName()=="language") 86 if (e->tagName()=="language")
88 { 87 {
89 syntaxModeListItem *mli=new syntaxModeListItem; 88 syntaxModeListItem *mli=new syntaxModeListItem;
90 mli->name = e->attribute("name"); 89 mli->name = e->attribute("name");
91 mli->section = e->attribute("section"); 90 mli->section = e->attribute("section");
92 mli->mimetype = e->attribute("mimetype"); 91 mli->mimetype = e->attribute("mimetype");
93 mli->extension = e->attribute("extensions"); 92 mli->extension = e->attribute("extensions");
94 qDebug(QString("valid description for: %1/%2").arg(mli->section).arg(mli->name)); 93 qDebug(QString("valid description for: %1/%2").arg(mli->section).arg(mli->name));
95 if (mli->section.isEmpty()) 94 if (mli->section.isEmpty())
96 mli->section=i18n("Other"); 95 mli->section=i18n("Other");
97 96
98 mli->identifier = path+(*it); 97 mli->identifier = path+(*it);
99#warning fixme
100/*
101 config->setGroup(Group); 98 config->setGroup(Group);
102 config->writeEntry("name",mli->name); 99 config->writeEntry("name",mli->name);
103 config->writeEntry("section",mli->section); 100 config->writeEntry("section",mli->section);
104 config->writeEntry("mimetype",mli->mimetype); 101 config->writeEntry("mimetype",mli->mimetype);
105 config->writeEntry("extension",mli->extension); 102 config->writeEntry("extension",mli->extension);
106*/
107 myModeList.append(mli); 103 myModeList.append(mli);
108 } 104 }
109 } 105 }
110 }
111 } 106 }
112// } 107 }
113
114// config->sync(); 108// config->sync();
115} 109}
116 110
117SyntaxModeList SyntaxDocument::modeList() 111SyntaxModeList SyntaxDocument::modeList()
118{ 112{
119 return myModeList; 113 return myModeList;
120} 114}
121 115
122bool SyntaxDocument::nextGroup( syntaxContextData* data) 116bool SyntaxDocument::nextGroup( syntaxContextData* data)
123{ 117{
124 if(!data) return false; 118 if(!data) return false;
125 119
126 if (!data->currentGroup) 120 if (!data->currentGroup)
127 data->currentGroup=data->parent->firstChild(); 121 data->currentGroup=data->parent->firstChild();
128 else 122 else
129 data->currentGroup=data->currentGroup->nextChild(); 123 data->currentGroup=data->currentGroup->nextChild();
130 124
131 data->item=0; 125 data->item=0;
132 126
133 if (!data->currentGroup) 127 if (!data->currentGroup)
134 return false; 128 return false;
135 else 129 else
136 return true; 130 return true;
137} 131}
138 132
139bool SyntaxDocument::nextItem( syntaxContextData* data) 133bool SyntaxDocument::nextItem( syntaxContextData* data)
140{ 134{
141 if(!data) return false; 135 if(!data) return false;
142 136
143 if (!data->item) 137 if (!data->item)
144 data->item=data->currentGroup->firstChild(); 138 data->item=data->currentGroup->firstChild();
145 else 139 else
146 data->item=data->item->nextChild(); 140 data->item=data->item->nextChild();
147 141
148 if (!data->item) 142 if (!data->item)
149 return false; 143 return false;
150 else 144 else
151 return true; 145 return true;
152} 146}
153 147
154QString SyntaxDocument::groupItemData( syntaxContextData* data,QString name) 148QString SyntaxDocument::groupItemData( syntaxContextData* data,QString name)
155{ 149{
156 if(!data) 150 if(!data)
157 return QString::null; 151 return QString::null;
158 152
159 if ( (data->item) && (name.isEmpty())) 153 if ( (data->item) && (name.isEmpty()))
160 return data->item->tagName(); 154 return data->item->tagName();
161 155
162 if (data->item) 156 if (data->item)
163 return data->item->attribute(name); 157 return data->item->attribute(name);
164 else 158 else
165 return QString(); 159 return QString();
166} 160}
167 161
168QString SyntaxDocument::groupData( syntaxContextData* data,QString name) 162QString SyntaxDocument::groupData( syntaxContextData* data,QString name)
169{ 163{
170 if(!data) 164 if(!data)
171 return QString::null; 165 return QString::null;
172 166
173 if (data->currentGroup) 167 if (data->currentGroup)
174 return data->currentGroup->attribute(name); 168 return data->currentGroup->attribute(name);
175 else 169 else
176 return QString(); 170 return QString();
177} 171}
178 172
179void SyntaxDocument::freeGroupInfo( syntaxContextData* data) 173void SyntaxDocument::freeGroupInfo( syntaxContextData* data)
180{ 174{
181 if (data) 175 if (data)
182 delete data; 176 delete data;
183} 177}
184 178
185syntaxContextData* SyntaxDocument::getSubItems(syntaxContextData* data) 179syntaxContextData* SyntaxDocument::getSubItems(syntaxContextData* data)
186{ 180{
187 syntaxContextData *retval=new syntaxContextData; 181 syntaxContextData *retval=new syntaxContextData;
188 retval->parent=0; 182 retval->parent=0;
189 retval->currentGroup=0; 183 retval->currentGroup=0;
190 retval->item=0; 184 retval->item=0;
191 if (data != 0) 185 if (data != 0)
192 { 186 {
193 retval->parent=data->currentGroup; 187 retval->parent=data->currentGroup;
194 retval->currentGroup=data->item; 188 retval->currentGroup=data->item;
195 retval->item=0; 189 retval->item=0;
196 } 190 }
197 191
198 return retval; 192 return retval;
199} 193}
200 194
201syntaxContextData* SyntaxDocument::getConfig(const QString& mainGroupName, const QString &Config) 195syntaxContextData* SyntaxDocument::getConfig(const QString& mainGroupName, const QString &Config)
202{ 196{
203 Opie::XMLElement *e = m_root->firstChild()->firstChild(); 197 Opie::XMLElement *e = m_root->firstChild()->firstChild();
204 198
205 while (e) 199 while (e)
206 { 200 {
207 kdDebug(13010)<<"in SyntaxDocument::getGroupInfo (outer loop) " <<endl; 201 kdDebug(13010)<<"in SyntaxDocument::getGroupInfo (outer loop) " <<endl;
208 202
209 if (e->tagName().compare(mainGroupName)==0 ) 203 if (e->tagName().compare(mainGroupName)==0 )
210 { 204 {
211 Opie::XMLElement *e1=e->firstChild(); 205 Opie::XMLElement *e1=e->firstChild();
212 206
213 while (e1) 207 while (e1)
214 { 208 {
215 kdDebug(13010)<<"in SyntaxDocument::getGroupInfo (inner loop) " <<endl; 209 kdDebug(13010)<<"in SyntaxDocument::getGroupInfo (inner loop) " <<endl;
216 210
217 if (e1->tagName()==Config) 211 if (e1->tagName()==Config)
218 { 212 {
219 syntaxContextData *data=new ( syntaxContextData); 213 syntaxContextData *data=new ( syntaxContextData);
220 data->currentGroup=0; 214 data->currentGroup=0;
221 data->parent=0; 215 data->parent=0;
222 data->item=e1; 216 data->item=e1;
223 return data; 217 return data;
224 } 218 }
225 219
226 e1=e1->nextChild(); 220 e1=e1->nextChild();
227 } 221 }
228 222
229 kdDebug(13010) << "WARNING :returning null 3"<< endl; 223 kdDebug(13010) << "WARNING :returning null 3"<< endl;
230 return 0; 224 return 0;
231 } 225 }
232 226
233 e=e->nextChild(); 227 e=e->nextChild();
234 } 228 }
235 229
236 kdDebug(13010) << "WARNING :returning null 4" << endl; 230 kdDebug(13010) << "WARNING :returning null 4" << endl;
237 return 0; 231 return 0;
238} 232}
239 233
240 234
241 235
diff --git a/noncore/apps/tinykate/libkate/interfaces/document.h b/noncore/apps/tinykate/libkate/interfaces/document.h
index cbfd1b3..af885f1 100644
--- a/noncore/apps/tinykate/libkate/interfaces/document.h
+++ b/noncore/apps/tinykate/libkate/interfaces/document.h
@@ -1,103 +1,103 @@
1/*************************************************************************** 1/***************************************************************************
2 document.h - description 2 document.h - description
3 ------------------- 3 -------------------
4 begin : Mon Jan 15 2001 4 begin : Mon Jan 15 2001
5 copyright : (C) 2001 by Christoph "Crossfire" Cullmann 5 copyright : (C) 2001 by Christoph "Crossfire" Cullmann
6 (C) 2002 by Joseph Wenninger 6 (C) 2002 by Joseph Wenninger
7 email : crossfire@babylon2k.de 7 email : crossfire@babylon2k.de
8 jowenn@kde.org 8 jowenn@kde.org
9 ***************************************************************************/ 9 ***************************************************************************/
10 10
11/*************************************************************************** 11/***************************************************************************
12 This library is free software; you can redistribute it and/or 12 This library is free software; you can redistribute it and/or
13 modify it under the terms of the GNU Library General Public 13 modify it under the terms of the GNU Library General Public
14 License as published by the Free Software Foundation; either 14 License as published by the Free Software Foundation; either
15 version 2 of the License, or (at your option) any later version. 15 version 2 of the License, or (at your option) any later version.
16 16
17 This library is distributed in the hope that it will be useful, 17 This library is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of 18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 Library General Public License for more details. 20 Library General Public License for more details.
21 21
22 You should have received a copy of the GNU Library General Public License 22 You should have received a copy of the GNU Library General Public License
23 along with this library; see the file COPYING.LIB. If not, write to 23 along with this library; see the file COPYING.LIB. If not, write to
24 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 24 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 ***************************************************************************/ 26 ***************************************************************************/
27 27
28#ifndef _KATE_DOCUMENT_INCLUDE_ 28#ifndef _KATE_DOCUMENT_INCLUDE_
29#define _KATE_DOCUMENT_INCLUDE_ 29#define _KATE_DOCUMENT_INCLUDE_
30 30
31#include <ktexteditor.h> 31#include <ktexteditor.h>
32 32
33class KConfig; 33class KateConfig;
34 34
35namespace Kate 35namespace Kate
36{ 36{
37 37
38/** internal class for document bookmarks. */ 38/** internal class for document bookmarks. */
39class Mark 39class Mark
40{ 40{
41 public: 41 public:
42 uint line; 42 uint line;
43 uint type; 43 uint type;
44}; 44};
45 45
46/** This interface provedes access to the Kate Document class. 46/** This interface provedes access to the Kate Document class.
47*/ 47*/
48class Document : public KTextEditor::Document 48class Document : public KTextEditor::Document
49{ 49{
50 Q_OBJECT 50 Q_OBJECT
51 51
52 public: 52 public:
53 Document (); 53 Document ();
54 virtual ~Document (); 54 virtual ~Document ();
55 55
56 public: 56 public:
57 /** Read document config. 57 /** Read document config.
58 */ 58 */
59 virtual void readConfig () { ; }; 59 virtual void readConfig () { ; };
60 /** Save document config. 60 /** Save document config.
61 */ 61 */
62 virtual void writeConfig () { ; }; 62 virtual void writeConfig () { ; };
63 63
64 /** Read document session config. 64 /** Read document session config.
65 */ 65 */
66 virtual void readSessionConfig (KConfig *) { ; }; 66 virtual void readSessionConfig (KateConfig *) { ; };
67 /** Save document session config. 67 /** Save document session config.
68 */ 68 */
69 virtual void writeSessionConfig (KConfig *) { ; }; 69 virtual void writeSessionConfig (KateConfig *) { ; };
70 70
71 /** Returns the document ID. 71 /** Returns the document ID.
72 */ 72 */
73 virtual uint docID () { return 0L; }; 73 virtual uint docID () { return 0L; };
74 74
75 /** Defines possible mark types. A line can have marks of different types. 75 /** Defines possible mark types. A line can have marks of different types.
76 */ 76 */
77 enum marks 77 enum marks
78 { 78 {
79 Bookmark = 1, 79 Bookmark = 1,
80 Breakpoint = 2, 80 Breakpoint = 2,
81 markType0 = 4, 81 markType0 = 4,
82 markType1 = 8, 82 markType1 = 8,
83 markType2 = 16, 83 markType2 = 16,
84 markType3 = 32, 84 markType3 = 32,
85 markType4 = 64, 85 markType4 = 64,
86 markType5 = 128, 86 markType5 = 128,
87 markType6 = 256, 87 markType6 = 256,
88 markType7 = 512, 88 markType7 = 512,
89 markType8 = 1024 89 markType8 = 1024
90 }; 90 };
91 91
92 /** A list of all marks in a document. Use binary comparing to find marks of a specific type. 92 /** A list of all marks in a document. Use binary comparing to find marks of a specific type.
93 */ 93 */
94 virtual QList<Mark> marks () { QList<Mark> l; return l; }; 94 virtual QList<Mark> marks () { QList<Mark> l; return l; };
95 95
96 public slots: 96 public slots:
97 // clear buffer/filename - update the views 97 // clear buffer/filename - update the views
98 virtual void flush () { ; }; 98 virtual void flush () { ; };
99}; 99};
100 100
101}; 101};
102 102
103#endif 103#endif
diff --git a/noncore/apps/tinykate/libkate/interfaces/view.h b/noncore/apps/tinykate/libkate/interfaces/view.h
index 5b24bb5..5846395 100644
--- a/noncore/apps/tinykate/libkate/interfaces/view.h
+++ b/noncore/apps/tinykate/libkate/interfaces/view.h
@@ -1,160 +1,160 @@
1/*************************************************************************** 1/***************************************************************************
2 view.h - description 2 view.h - description
3 ------------------- 3 -------------------
4 begin : Mon Jan 15 2001 4 begin : Mon Jan 15 2001
5 copyright : (C) 2001 by Christoph "Crossfire" Cullmann 5 copyright : (C) 2001 by Christoph "Crossfire" Cullmann
6 (C) 2002 by Joseph Wenninger 6 (C) 2002 by Joseph Wenninger
7 email : crossfire@babylon2k.de 7 email : crossfire@babylon2k.de
8 jowenn@kde.org 8 jowenn@kde.org
9***************************************************************************/ 9***************************************************************************/
10 10
11/*************************************************************************** 11/***************************************************************************
12 This library is free software; you can redistribute it and/or 12 This library is free software; you can redistribute it and/or
13 modify it under the terms of the GNU Library General Public 13 modify it under the terms of the GNU Library General Public
14 License as published by the Free Software Foundation; either 14 License as published by the Free Software Foundation; either
15 version 2 of the License, or (at your option) any later version. 15 version 2 of the License, or (at your option) any later version.
16 16
17 This library is distributed in the hope that it will be useful, 17 This library is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of 18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 Library General Public License for more details. 20 Library General Public License for more details.
21 21
22 You should have received a copy of the GNU Library General Public License 22 You should have received a copy of the GNU Library General Public License
23 along with this library; see the file COPYING.LIB. If not, write to 23 along with this library; see the file COPYING.LIB. If not, write to
24 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 24 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 ***************************************************************************/ 26 ***************************************************************************/
27 27
28#ifndef _KATE_VIEW_INCLUDE_ 28#ifndef _KATE_VIEW_INCLUDE_
29#define _KATE_VIEW_INCLUDE_ 29#define _KATE_VIEW_INCLUDE_
30 30
31#include <ktexteditor.h> 31#include <ktexteditor.h>
32 32
33class KConfig; 33class KateConfig;
34 34
35namespace Kate 35namespace Kate
36{ 36{
37 37
38class Document; 38class Document;
39class Mark; 39class Mark;
40 40
41/** This interface provides access to the view. 41/** This interface provides access to the view.
42*/ 42*/
43class View : public KTextEditor::View 43class View : public KTextEditor::View
44{ 44{
45 Q_OBJECT 45 Q_OBJECT
46 46
47 public: 47 public:
48 View ( KTextEditor::Document *doc, QWidget *parent, const char *name = 0 ); 48 View ( KTextEditor::Document *doc, QWidget *parent, const char *name = 0 );
49 virtual ~View (); 49 virtual ~View ();
50 50
51 /** Returns a pointer to the document of the view. 51 /** Returns a pointer to the document of the view.
52 */ 52 */
53 virtual Document *getDoc () { return 0L; }; 53 virtual Document *getDoc () { return 0L; };
54 54
55 /** Returns the marked text in the view. 55 /** Returns the marked text in the view.
56 */ 56 */
57 virtual QString markedText () { return 0L; }; 57 virtual QString markedText () { return 0L; };
58 58
59 public slots: 59 public slots:
60 /** popup a config dialog for the editor part. 60 /** popup a config dialog for the editor part.
61 */ 61 */
62 virtual void configDialog () { ; }; 62 virtual void configDialog () { ; };
63 63
64 // Highlighting slots 64 // Highlighting slots
65 virtual void setHl (int) { ; }; 65 virtual void setHl (int) { ; };
66 virtual int getHl () { return 0; }; 66 virtual int getHl () { return 0; };
67 virtual int getHlCount () { return 0; }; 67 virtual int getHlCount () { return 0; };
68 virtual QString getHlName (int) { return 0L; }; 68 virtual QString getHlName (int) { return 0L; };
69 virtual QString getHlSection (int) { return 0L; }; 69 virtual QString getHlSection (int) { return 0L; };
70 70
71 // undo/redo stuff 71 // undo/redo stuff
72 virtual void undo () { ; }; 72 virtual void undo () { ; };
73 virtual void redo () { ; }; 73 virtual void redo () { ; };
74 virtual void undoHistory() { ; }; 74 virtual void undoHistory() { ; };
75 75
76 public: 76 public:
77 // read/save config of the view 77 // read/save config of the view
78 virtual void readConfig () { ; }; 78 virtual void readConfig () { ; };
79 virtual void writeConfig () { ; }; 79 virtual void writeConfig () { ; };
80 80
81 // read/save sessionconfig of the view 81 // read/save sessionconfig of the view
82 virtual void readSessionConfig (KConfig *) { ; }; 82 virtual void readSessionConfig (KateConfig *) { ; };
83 virtual void writeSessionConfig (KConfig *) { ; }; 83 virtual void writeSessionConfig (KateConfig *) { ; };
84 84
85 public slots: 85 public slots:
86 // some simply key commands 86 // some simply key commands
87 virtual void keyReturn () { ; }; 87 virtual void keyReturn () { ; };
88 virtual void keyDelete () { ; }; 88 virtual void keyDelete () { ; };
89 virtual void backspace () { ; }; 89 virtual void backspace () { ; };
90 virtual void killLine () { ; }; 90 virtual void killLine () { ; };
91 91
92 // move cursor in the view 92 // move cursor in the view
93 virtual void cursorLeft () { ; }; 93 virtual void cursorLeft () { ; };
94 virtual void shiftCursorLeft () { ; }; 94 virtual void shiftCursorLeft () { ; };
95 virtual void cursorRight () { ; }; 95 virtual void cursorRight () { ; };
96 virtual void shiftCursorRight () { ; }; 96 virtual void shiftCursorRight () { ; };
97 virtual void wordLeft () { ; }; 97 virtual void wordLeft () { ; };
98 virtual void shiftWordLeft () { ; }; 98 virtual void shiftWordLeft () { ; };
99 virtual void wordRight () { ; }; 99 virtual void wordRight () { ; };
100 virtual void shiftWordRight () { ; }; 100 virtual void shiftWordRight () { ; };
101 virtual void home () { ; }; 101 virtual void home () { ; };
102 virtual void shiftHome () { ; }; 102 virtual void shiftHome () { ; };
103 virtual void end () { ; }; 103 virtual void end () { ; };
104 virtual void shiftEnd () { ; }; 104 virtual void shiftEnd () { ; };
105 virtual void up () { ; }; 105 virtual void up () { ; };
106 virtual void shiftUp () { ; }; 106 virtual void shiftUp () { ; };
107 virtual void down () { ; }; 107 virtual void down () { ; };
108 virtual void shiftDown () { ; }; 108 virtual void shiftDown () { ; };
109 virtual void scrollUp () { ; }; 109 virtual void scrollUp () { ; };
110 virtual void scrollDown () { ; }; 110 virtual void scrollDown () { ; };
111 virtual void topOfView () { ; }; 111 virtual void topOfView () { ; };
112 virtual void bottomOfView () { ; }; 112 virtual void bottomOfView () { ; };
113 virtual void pageUp () { ; }; 113 virtual void pageUp () { ; };
114 virtual void shiftPageUp () { ; }; 114 virtual void shiftPageUp () { ; };
115 virtual void pageDown () { ; }; 115 virtual void pageDown () { ; };
116 virtual void shiftPageDown () { ; }; 116 virtual void shiftPageDown () { ; };
117 virtual void top () { ; }; 117 virtual void top () { ; };
118 virtual void shiftTop () { ; }; 118 virtual void shiftTop () { ; };
119 virtual void bottom () { ; }; 119 virtual void bottom () { ; };
120 virtual void shiftBottom () { ; }; 120 virtual void shiftBottom () { ; };
121 121
122 public slots: 122 public slots:
123 // edit command popup window 123 // edit command popup window
124 virtual void slotEditCommand () { ; }; 124 virtual void slotEditCommand () { ; };
125 125
126 // icon border enable/disable 126 // icon border enable/disable
127 virtual void setIconBorder (bool) { ; }; 127 virtual void setIconBorder (bool) { ; };
128 virtual void toggleIconBorder () { ; }; 128 virtual void toggleIconBorder () { ; };
129 129
130 // goto mark 130 // goto mark
131 virtual void gotoMark (Mark *) { ; }; 131 virtual void gotoMark (Mark *) { ; };
132 132
133 // toggle current line bookmark or clear all bookmarks 133 // toggle current line bookmark or clear all bookmarks
134 virtual void toggleBookmark () { ; }; 134 virtual void toggleBookmark () { ; };
135 virtual void clearBookmarks () { ; }; 135 virtual void clearBookmarks () { ; };
136 136
137 public: 137 public:
138 // is iconborder visible ? 138 // is iconborder visible ?
139 virtual bool iconBorder() { return false; }; 139 virtual bool iconBorder() { return false; };
140 140
141 public slots: 141 public slots:
142 /** 142 /**
143 Flushes the document of the text widget. The user is given 143 Flushes the document of the text widget. The user is given
144 a chance to save the current document if the current document has 144 a chance to save the current document if the current document has
145 been modified. 145 been modified.
146 */ 146 */
147 virtual void flush () { ; }; 147 virtual void flush () { ; };
148 148
149 public: 149 public:
150 /** 150 /**
151 Returns true if the current document can be 151 Returns true if the current document can be
152 discarded. If the document is modified, the user is asked if he wants 152 discarded. If the document is modified, the user is asked if he wants
153 to save it. On "cancel" the function returns false. 153 to save it. On "cancel" the function returns false.
154 */ 154 */
155 virtual bool canDiscard() { return false; }; 155 virtual bool canDiscard() { return false; };
156}; 156};
157 157
158}; 158};
159 159
160#endif 160#endif
diff --git a/noncore/apps/tinykate/libkate/kateconfig.cpp b/noncore/apps/tinykate/libkate/kateconfig.cpp
new file mode 100644
index 0000000..06ac49f
--- a/dev/null
+++ b/noncore/apps/tinykate/libkate/kateconfig.cpp
@@ -0,0 +1,634 @@
1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3**
4** This file is part of Qtopia Environment.
5**
6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20
21#include <qdir.h>
22#include <qfile.h>
23#include <qfileinfo.h>
24#include <qmessagebox.h>
25#if QT_VERSION <= 230 && defined(QT_NO_CODECS)
26#include <qtextcodec.h>
27#endif
28#include <qtextstream.h>
29
30#include <sys/stat.h>
31#include <sys/types.h>
32#include <fcntl.h>
33#include <stdlib.h>
34#include <unistd.h>
35
36#define QTOPIA_INTERNAL_LANGLIST
37#include "kateconfig.h"
38#include <qpe/global.h>
39
40
41/*!
42 \internal
43*/
44QString KateConfig::configFilename(const QString& name, Domain d)
45{
46 switch (d) {
47 case File:
48 return name;
49 case User: {
50 QDir dir = (QString(getenv("HOME")) + "/Settings");
51 if ( !dir.exists() )
52 mkdir(dir.path().local8Bit(),0700);
53 return dir.path() + "/" + name + ".conf";
54 }
55 }
56 return name;
57}
58
59/*!
60 \class KateConfig config.h
61 \brief The KateConfig class provides for saving application cofniguration state.
62
63 You should keep a KateConfig in existence only while you do not want others
64 to be able to change the state. There is no locking currently, but there
65 may be in the future.
66*/
67
68/*!
69 \enum KateConfig::KateConfigGroup
70 \internal
71*/
72
73/*!
74 \enum KateConfig::Domain
75
76 \value File
77 \value User
78
79 See KateConfig for details.
80*/
81
82/*!
83 Constructs a config that will load or create a configuration with the
84 given \a name in the given \a domain.
85
86 You must call setGroup() before doing much else with the KateConfig.
87
88 In the default Domain, \e User,
89 the configuration is user-specific. \a name should not contain "/" in
90 this case, and in general should be the name of the C++ class that is
91 primarily responsible for maintaining the configuration.
92
93 In the File Domain, \a name is an absolute filename.
94*/
95KateConfig::KateConfig( const QString &name, Domain domain )
96 : filename( configFilename(name,domain) )
97{
98 qWarning("KateConfig constructor\n");
99 git = groups.end();
100 read();
101 QStringList l = Global::languageList();
102 lang = l[0];
103 glang = l[1];
104}
105
106
107// Sharp ROM compatibility
108KateConfig::KateConfig ( const QString &name, bool what )
109 : filename( configFilename(name,what ? User : File) )
110{
111 git = groups.end();
112 read();
113 QStringList l = Global::languageList();
114 lang = l[0];
115 glang = l[1];
116}
117
118/*!
119 Writes any changes to disk and destroys the in-memory object.
120*/
121KateConfig::~KateConfig()
122{
123 qWarning("KateConfig destructor\n");
124 if ( changed )
125 write();
126}
127
128/*!
129 Returns whether the current group has an entry called \a key.
130*/
131bool KateConfig::hasKey( const QString &key ) const
132{
133 if ( groups.end() == git )
134 return FALSE;
135 KateConfigGroup::ConstIterator it = ( *git ).find( key );
136 return it != ( *git ).end();
137}
138
139/*!
140 Sets the current group for subsequent reading and writing of
141 entries to \a gname. Grouping allows the application to partition the namespace.
142
143 This function must be called prior to any reading or writing
144 of entries.
145
146 The \a gname must not be empty.
147*/
148void KateConfig::setGroup( const QString &gname )
149{
150 QMap< QString, KateConfigGroup>::Iterator it = groups.find( gname );
151 if ( it == groups.end() ) {
152 git = groups.insert( gname, KateConfigGroup() );
153 changed = TRUE;
154 return;
155 }
156 git = it;
157}
158
159/*!
160 Writes a (\a key, \a value) entry to the current group.
161
162 \sa readEntry()
163*/
164void KateConfig::writeEntry( const QString &key, const char* value )
165{
166 writeEntry(key,QString(value));
167}
168
169/*!
170 Writes a (\a key, \a value) entry to the current group.
171
172 \sa readEntry()
173*/
174void KateConfig::writeEntry( const QString &key, const QString &value )
175{
176 if ( git == groups.end() ) {
177 qWarning( "no group set" );
178 return;
179 }
180 if ( (*git)[key] != value ) {
181 ( *git ).insert( key, value );
182 changed = TRUE;
183 }
184}
185
186/*
187 Note that the degree of protection offered by the encryption here is
188 only sufficient to avoid the most casual observation of the configuration
189 files. People with access to the files can write down the contents and
190 decrypt it using this source code.
191
192 Conceivably, and at some burden to the user, this encryption could
193 be improved.
194*/
195static QString encipher(const QString& plain)
196{
197 // mainly, we make it long
198 QString cipher;
199 int mix=28730492;
200 for (int i=0; i<(int)plain.length(); i++) {
201 int u = plain[i].unicode();
202 int c = u ^ mix;
203 QString x = QString::number(c,36);
204 cipher.append(QChar('a'+x.length()));
205 cipher.append(x);
206 mix *= u;
207 }
208 return cipher;
209}
210
211static QString decipher(const QString& cipher)
212{
213 QString plain;
214 int mix=28730492;
215 for (int i=0; i<(int)cipher.length();) {
216 int l = cipher[i].unicode()-'a';
217 QString x = cipher.mid(i+1,l); i+=l+1;
218 int u = x.toInt(0,36) ^ mix;
219 plain.append(QChar(u));
220 mix *= u;
221 }
222 return plain;
223}
224
225/*!
226 Writes an encrypted (\a key, \a value) entry to the current group.
227
228 Note that the degree of protection offered by the encryption is
229 only sufficient to avoid the most casual observation of the configuration
230 files.
231
232 \sa readEntry()
233*/
234void KateConfig::writeEntryCrypt( const QString &key, const QString &value )
235{
236 if ( git == groups.end() ) {
237 qWarning( "no group set" );
238 return;
239 }
240 QString evalue = encipher(value);
241 if ( (*git)[key] != evalue ) {
242 ( *git ).insert( key, evalue );
243 changed = TRUE;
244 }
245}
246
247/*!
248 Writes a (\a key, \a num) entry to the current group.
249
250 \sa readNumEntry()
251*/
252void KateConfig::writeEntry( const QString &key, int num )
253{
254 QString s;
255 s.setNum( num );
256 writeEntry( key, s );
257}
258
259void KateConfig::writeEntry( const QString &key, unsigned int num )
260{
261 QString s;
262 s.setNum( num );
263 writeEntry( key, s );
264}
265
266#ifdef Q_HAS_BOOL_TYPE
267/*!
268 Writes a (\a key, \a b) entry to the current group. This is equivalent
269 to writing a 0 or 1 as an integer entry.
270
271 \sa readBoolEntry()
272*/
273void KateConfig::writeEntry( const QString &key, bool b )
274{
275 QString s;
276 s.setNum( ( int )b );
277 writeEntry( key, s );
278}
279#endif
280
281/*!
282 Writes a (\a key, \a lst) entry to the current group. The list
283 is separated by \a sep, so the strings must not contain that character.
284
285 \sa readListEntry()
286*/
287void KateConfig::writeEntry( const QString &key, const QStringList &lst, const QChar &sep )
288{
289 QString s;
290 QStringList::ConstIterator it = lst.begin();
291 for ( ; it != lst.end(); ++it )
292 s += *it + sep;
293 writeEntry( key, s );
294}
295
296void KateConfig::writeEntry( const QString &key, const QColor &val )
297{
298 QStringList l;
299 l.append( QString().setNum(val.red()) );
300 l.append( QString().setNum(val.green()) );
301 l.append( QString().setNum(val.blue()) );
302
303 writeEntry( key, l, QChar(',') );
304}
305
306void KateConfig::writeEntry( const QString &key, const QFont &val )
307{
308 QStringList l;
309 l.append( val.family() );
310 l.append( QString().setNum(val.pointSize()) );
311 l.append( QString().setNum(val.weight()) );
312 l.append( QString().setNum((int)val.italic()) );
313 l.append( QString().setNum((int)val.charSet()) );
314
315 writeEntry( key, l, QChar(',') );
316}
317
318/*!
319 Removes the \a key entry from the current group. Does nothing if
320 there is no such entry.
321*/
322
323void KateConfig::removeEntry( const QString &key )
324{
325 if ( git == groups.end() ) {
326 qWarning( "no group set" );
327 return;
328 }
329 ( *git ).remove( key );
330 changed = TRUE;
331}
332
333/*!
334 \fn bool KateConfig::operator == ( const KateConfig & other ) const
335
336 Tests for equality with \a other. KateConfig objects are equal if they refer to the same filename.
337*/
338
339/*!
340 \fn bool KateConfig::operator != ( const KateConfig & other ) const
341
342 Tests for inequality with \a other. KateConfig objects are equal if they refer to the same filename.
343*/
344
345/*!
346 \fn QString KateConfig::readEntry( const QString &key, const QString &deflt ) const
347
348 Reads a string entry stored with \a key, defaulting to \a deflt if there is no entry.
349*/
350
351/*!
352 \internal
353 For compatibility, non-const version.
354*/
355QString KateConfig::readEntry( const QString &key, const QString &deflt )
356{
357 QString res = readEntryDirect( key+"["+lang+"]" );
358 if ( !res.isNull() )
359 return res;
360 if ( !glang.isEmpty() ) {
361 res = readEntryDirect( key+"["+glang+"]" );
362 if ( !res.isNull() )
363 return res;
364 }
365 return readEntryDirect( key, deflt );
366}
367
368/*!
369 \fn QString KateConfig::readEntryCrypt( const QString &key, const QString &deflt ) const
370
371 Reads an encrypted string entry stored with \a key, defaulting to \a deflt if there is no entry.
372*/
373
374/*!
375 \internal
376 For compatibility, non-const version.
377*/
378QString KateConfig::readEntryCrypt( const QString &key, const QString &deflt )
379{
380 QString res = readEntryDirect( key+"["+lang+"]" );
381 if ( res.isNull() && glang.isEmpty() )
382 res = readEntryDirect( key+"["+glang+"]" );
383 if ( res.isNull() )
384 res = readEntryDirect( key, QString::null );
385 if ( res.isNull() )
386 return deflt;
387 return decipher(res);
388}
389
390/*!
391 \fn QString KateConfig::readEntryDirect( const QString &key, const QString &deflt ) const
392 \internal
393*/
394
395/*!
396 \internal
397 For compatibility, non-const version.
398*/
399QString KateConfig::readEntryDirect( const QString &key, const QString &deflt )
400{
401 if ( git == groups.end() ) {
402 //qWarning( "no group set" );
403 return deflt;
404 }
405 KateConfigGroup::ConstIterator it = ( *git ).find( key );
406 if ( it != ( *git ).end() )
407 return *it;
408 else
409 return deflt;
410}
411
412/*!
413 \fn int KateConfig::readNumEntry( const QString &key, int deflt ) const
414 Reads a numeric entry stored with \a key, defaulting to \a deflt if there is no entry.
415*/
416
417/*!
418 \internal
419 For compatibility, non-const version.
420*/
421int KateConfig::readNumEntry( const QString &key, int deflt )
422{
423 QString s = readEntry( key );
424 if ( s.isEmpty() )
425 return deflt;
426 else
427 return s.toInt();
428}
429
430/*!
431 \fn bool KateConfig::readBoolEntry( const QString &key, bool deflt ) const
432 Reads a bool entry stored with \a key, defaulting to \a deflt if there is no entry.
433*/
434
435/*!
436 \internal
437 For compatibility, non-const version.
438*/
439bool KateConfig::readBoolEntry( const QString &key, bool deflt )
440{
441 QString s = readEntry( key );
442 if ( s.isEmpty() )
443 return deflt;
444 else
445 return (bool)s.toInt();
446}
447
448/*!
449 \fn QStringList KateConfig::readListEntry( const QString &key, const QChar &sep ) const
450 Reads a string list entry stored with \a key, and with \a sep as the separator.
451*/
452
453/*!
454 \internal
455 For compatibility, non-const version.
456*/
457QStringList KateConfig::readListEntry( const QString &key, const QChar &sep )
458{
459 QString s = readEntry( key );
460 if ( s.isEmpty() )
461 return QStringList();
462 else
463 return QStringList::split( sep, s );
464}
465
466QColor KateConfig::readColorEntry( const QString &key, const QColor &def ) const
467{
468 QStringList list = readListEntry(key, QChar(','));
469 if( list.count() != 3 )
470 return def;
471
472 return QColor(list[0].toInt(), list[1].toInt(), list[2].toInt());
473}
474
475QFont KateConfig::readFontEntry( const QString &key, const QFont &def ) const
476{
477 QStringList list = readListEntry(key, QChar(','));
478 if( list.count() != 5 )
479 return def;
480
481 return QFont(list[0], list[1].toInt(), list[2].toInt(), (bool)list[3].toInt(), (QFont::CharSet)list[4].toInt());
482}
483
484QValueList<int> KateConfig::readIntListEntry( const QString &key ) const
485{
486 QString s = readEntry( key );
487 QValueList<int> il;
488 if ( s.isEmpty() )
489 return il;
490
491 QStringList l = QStringList::split( QChar(','), s );
492
493 QStringList::Iterator l_it;
494 for( l_it = l.begin(); l_it != l.end(); ++l_it )
495 il.append( (*l_it).toInt() );
496 return il;
497}
498
499/*!
500 Removes all entries from the current group.
501*/
502void KateConfig::clearGroup()
503{
504 if ( git == groups.end() ) {
505 qWarning( "no group set" );
506 return;
507 }
508 if ( !(*git).isEmpty() ) {
509 ( *git ).clear();
510 changed = TRUE;
511 }
512}
513
514/*!
515 \internal
516*/
517void KateConfig::write( const QString &fn )
518{
519 QString strNewFile;
520 if ( !fn.isEmpty() )
521 filename = fn;
522 strNewFile = filename + ".new";
523
524 QFile f( strNewFile );
525 if ( !f.open( IO_WriteOnly|IO_Raw ) ) {
526 qWarning( "could not open for writing `%s'", strNewFile.latin1() );
527 git = groups.end();
528 return;
529 }
530
531 QString str;
532 QCString cstr;
533 QMap< QString, KateConfigGroup >::Iterator g_it = groups.begin();
534
535 for ( ; g_it != groups.end(); ++g_it ) {
536 str += "[" + g_it.key() + "]\n";
537 KateConfigGroup::Iterator e_it = ( *g_it ).begin();
538 for ( ; e_it != ( *g_it ).end(); ++e_it )
539 str += e_it.key() + " = " + *e_it + "\n";
540 }
541 cstr = str.utf8();
542
543 int total_length;
544 total_length = f.writeBlock( cstr.data(), cstr.length() );
545 if ( total_length != int(cstr.length()) ) {
546 QMessageBox::critical( 0, QObject::tr("Out of Space"),
547 QObject::tr("There was a problem creating\nKateConfiguration Information \nfor this program.\n\nPlease free up some space and\ntry again.") );
548 f.close();
549 QFile::remove( strNewFile );
550 return;
551 }
552
553 f.close();
554 // now rename the file...
555 if ( rename( strNewFile, filename ) < 0 ) {
556 qWarning( "problem renaming the file %s to %s", strNewFile.latin1(),
557 filename.latin1() );
558 QFile::remove( strNewFile );
559 }
560}
561
562/*!
563 Returns whether the KateConfig is in a valid state.
564*/
565bool KateConfig::isValid() const
566{
567 return groups.end() != git;
568}
569
570/*!
571 \internal
572*/
573void KateConfig::read()
574{
575 changed = FALSE;
576
577 if ( !QFileInfo( filename ).exists() ) {
578 git = groups.end();
579 return;
580 }
581
582 QFile f( filename );
583 if ( !f.open( IO_ReadOnly ) ) {
584 git = groups.end();
585 return;
586 }
587
588 QTextStream s( &f );
589#if QT_VERSION <= 230 && defined(QT_NO_CODECS)
590 // The below should work, but doesn't in Qt 2.3.0
591 s.setCodec( QTextCodec::codecForMib( 106 ) );
592#else
593 s.setEncoding( QTextStream::UnicodeUTF8 );
594#endif
595
596 QStringList list = QStringList::split('\n', s.read() );
597 f.close();
598
599 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
600 if ( !parse( *it ) ) {
601 git = groups.end();
602 return;
603 }
604 }
605}
606
607/*!
608 \internal
609*/
610bool KateConfig::parse( const QString &l )
611{
612 QString line = l.stripWhiteSpace();
613
614 if ( line [0] == QChar ( '#' ))
615 return true; // ignore comments
616
617 if ( line[ 0 ] == QChar( '[' ) ) {
618 QString gname = line;
619 gname = gname.remove( 0, 1 );
620 if ( gname[ (int)gname.length() - 1 ] == QChar( ']' ) )
621 gname = gname.remove( gname.length() - 1, 1 );
622 git = groups.insert( gname, KateConfigGroup() );
623 } else if ( !line.isEmpty() ) {
624 if ( git == groups.end() )
625 return FALSE;
626 int eq = line.find( '=' );
627 if ( eq == -1 )
628 return FALSE;
629 QString key = line.left(eq).stripWhiteSpace();
630 QString value = line.mid(eq+1).stripWhiteSpace();
631 ( *git ).insert( key, value );
632 }
633 return TRUE;
634}
diff --git a/noncore/apps/tinykate/libkate/kateconfig.h b/noncore/apps/tinykate/libkate/kateconfig.h
new file mode 100644
index 0000000..80a4e67
--- a/dev/null
+++ b/noncore/apps/tinykate/libkate/kateconfig.h
@@ -0,0 +1,117 @@
1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3**
4** This file is part of Qtopia Environment.
5**
6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20
21#ifndef KATECONFIG_H
22#define KATECONFIG_H
23
24// ##### could use QSettings with Qt 3.0
25
26#include <qmap.h>
27#include <qstringlist.h>
28#include <qfont.h>
29#include <qcolor.h>
30
31class KateConfigPrivate;
32class KateConfig
33{
34public:
35 typedef QMap< QString, QString > KateConfigGroup;
36
37 enum Domain { File, User };
38 KateConfig( const QString &name, Domain domain=User );
39 ~KateConfig();
40
41 bool operator == ( const KateConfig & other ) const { return (filename == other.filename); }
42 bool operator != ( const KateConfig & other ) const { return (filename != other.filename); }
43
44 bool isValid() const;
45 bool hasKey( const QString &key ) const;
46
47 // inline for better SharpROM BC
48 inline bool hasGroup ( const QString &gname ) const { return ( groups. find ( gname ) != groups. end ( )); };
49 inline QStringList groupList ( ) const { QStringList sl; for ( QMap< QString, KateConfigGroup >::ConstIterator it = groups. begin ( ); it != groups. end ( ); ++it ) { sl << it.key(); } return sl; };
50
51 void setGroup( const QString &gname );
52 void writeEntry( const QString &key, const char* value );
53 void writeEntry( const QString &key, const QString &value );
54 void writeEntryCrypt( const QString &key, const QString &value );
55 void writeEntry( const QString &key, int num );
56 void writeEntry( const QString &key, unsigned int num );
57#ifdef Q_HAS_BOOL_TYPE
58 void writeEntry( const QString &key, bool b );
59#endif
60 void writeEntry( const QString &key, const QStringList &lst, const QChar &sep );
61 void writeEntry( const QString &key, const QColor & );
62 void writeEntry( const QString &key, const QFont & );
63 void removeEntry( const QString &key );
64
65 QString readEntry( const QString &key, const QString &deflt = QString::null ) const;
66 QString readEntryCrypt( const QString &key, const QString &deflt = QString::null ) const;
67 QString readEntryDirect( const QString &key, const QString &deflt = QString::null ) const;
68 int readNumEntry( const QString &key, int deflt = -1 ) const;
69 bool readBoolEntry( const QString &key, bool deflt = FALSE ) const;
70 QStringList readListEntry( const QString &key, const QChar &sep ) const;
71 QColor readColorEntry( const QString &, const QColor & ) const;
72 QFont readFontEntry( const QString &, const QFont & ) const;
73 QValueList<int> readIntListEntry( const QString &key ) const;
74
75 // For compatibility, non-const versions.
76 QString readEntry( const QString &key, const QString &deflt );
77 QString readEntryCrypt( const QString &key, const QString &deflt );
78 QString readEntryDirect( const QString &key, const QString &deflt );
79 int readNumEntry( const QString &key, int deflt );
80 bool readBoolEntry( const QString &key, bool deflt );
81 QStringList readListEntry( const QString &key, const QChar &sep );
82
83 void clearGroup();
84
85 void write( const QString &fn = QString::null );
86
87protected:
88 void read();
89 bool parse( const QString &line );
90
91 QMap< QString, KateConfigGroup > groups;
92 QMap< QString, KateConfigGroup >::Iterator git;
93 QString filename;
94 QString lang;
95 QString glang;
96 bool changed;
97 KateConfigPrivate *d;
98 static QString configFilename(const QString& name, Domain);
99
100private: // Sharp ROM compatibility
101 KateConfig( const QString &name, bool what );
102};
103
104inline QString KateConfig::readEntry( const QString &key, const QString &deflt ) const
105{ return ((KateConfig*)this)->readEntry(key,deflt); }
106inline QString KateConfig::readEntryCrypt( const QString &key, const QString &deflt ) const
107{ return ((KateConfig*)this)->readEntryCrypt(key,deflt); }
108inline QString KateConfig::readEntryDirect( const QString &key, const QString &deflt ) const
109{ return ((KateConfig*)this)->readEntryDirect(key,deflt); }
110inline int KateConfig::readNumEntry( const QString &key, int deflt ) const
111{ return ((KateConfig*)this)->readNumEntry(key,deflt); }
112inline bool KateConfig::readBoolEntry( const QString &key, bool deflt ) const
113{ return ((KateConfig*)this)->readBoolEntry(key,deflt); }
114inline QStringList KateConfig::readListEntry( const QString &key, const QChar &sep ) const
115{ return ((KateConfig*)this)->readListEntry(key,sep); }
116
117#endif
diff --git a/noncore/apps/tinykate/libkate/libkate.pro b/noncore/apps/tinykate/libkate/libkate.pro
index b0354e6..0082106 100644
--- a/noncore/apps/tinykate/libkate/libkate.pro
+++ b/noncore/apps/tinykate/libkate/libkate.pro
@@ -1,90 +1,91 @@
1 TEMPLATE= lib 1 TEMPLATE= lib
2 CONFIG = qt warn_on release 2 CONFIG = qt warn_on release
3 HEADERS = microkde/kapplication.h \ 3 HEADERS = microkde/kapplication.h \
4 microkde/kconfig.h \ 4 kateconfig.h \
5 microkde/kdebug.h \ 5 microkde/kdebug.h \
6 microkde/kdialog.h \ 6 microkde/kdialog.h \
7 microkde/kdialogbase.h \ 7 microkde/kdialogbase.h \
8 microkde/kfiledialog.h \ 8 microkde/kfiledialog.h \
9 microkde/kglobal.h \ 9 microkde/kglobal.h \
10 microkde/kiconloader.h \ 10 microkde/kiconloader.h \
11 microkde/klineedit.h \ 11 microkde/klineedit.h \
12 microkde/klocale.h \ 12 microkde/klocale.h \
13 microkde/kmessagebox.h \ 13 microkde/kmessagebox.h \
14 microkde/kprinter.h \ 14 microkde/kprinter.h \
15 microkde/krestrictedline.h \ 15 microkde/krestrictedline.h \
16 microkde/kseparator.h \ 16 microkde/kseparator.h \
17 microkde/ksimpleconfig.h \
18 microkde/kstandarddirs.h \ 17 microkde/kstandarddirs.h \
19 microkde/ktempfile.h \ 18 microkde/ktempfile.h \
20 microkde/kunload.h \ 19 microkde/kunload.h \
21 microkde/kurlrequester.h \ 20 microkde/kurlrequester.h \
22 microkde/kfontdialog.h \ 21 microkde/kfontdialog.h \
23 microkde/krun.h \ 22 microkde/krun.h \
24 microkde/knumvalidator.h \ 23 microkde/knumvalidator.h \
25 microkde/kstaticdeleter.h \ 24 microkde/kstaticdeleter.h \
26 microkde/klistview.h \ 25 microkde/klistview.h \
27 microkde/kglobalsettings.h \ 26 microkde/kglobalsettings.h \
28 microkde/kcolorbtn.h \ 27 microkde/kcolorbtn.h \
29 \ 28 \
30 \ 29 \
31 qt3back/qregexp3.h \ 30 qt3back/qregexp3.h \
32 kde/ksharedptr.h \ 31 kde/ksharedptr.h \
33 document/katebuffer.h document/katedialogs.h \ 32 document/katebuffer.h document/katedialogs.h \
34 document/katetextline.h \ 33 document/katetextline.h \
35 document/katecmd.h \ 34 document/katecmd.h \
36 document/katehighlight.h \ 35 document/katehighlight.h \
37 document/katecmds.h document/katedocument.h \ 36 document/katecmds.h document/katedocument.h \
38 document/katesyntaxdocument.h \ 37 document/katesyntaxdocument.h \
39 view/kateundohistory.h \ 38 view/kateundohistory.h \
40 view/kateview.h \ 39 view/kateview.h \
41 view/kateviewdialog.h \ 40 view/kateviewdialog.h \
42 interfaces/view.h \ 41 interfaces/view.h \
43 interfaces/document.h \ 42 interfaces/document.h \
44 ktexteditor/ktexteditor.h 43 ktexteditor/ktexteditor.h
45 44
46 SOURCES = microkde/kapplication.cpp \ 45 SOURCES = microkde/kapplication.cpp \
47 microkde/kdialogbase.cpp \ 46 microkde/kdialogbase.cpp \
48 microkde/kconfig.cpp \ 47 kateconfig.cpp \
49 microkde/klocale.cpp \ 48 microkde/klocale.cpp \
50 microkde/kmessagebox.cpp \ 49 microkde/kmessagebox.cpp \
51 microkde/kprocess.cpp \ 50 microkde/kprocess.cpp \
52 microkde/kstandarddirs.cpp \ 51 microkde/kstandarddirs.cpp \
53 microkde/ktempfile.cpp \ 52 microkde/ktempfile.cpp \
54 microkde/kurlrequester.cpp \ 53 microkde/kurlrequester.cpp \
55 microkde/kcolordialog.cpp \ 54 microkde/kcolordialog.cpp \
56 microkde/kfontdialog.cpp \ 55 microkde/kfontdialog.cpp \
57 microkde/krun.cpp \ 56 microkde/krun.cpp \
58 microkde/knumvalidator.cpp \ 57 microkde/knumvalidator.cpp \
59 microkde/kglobal.cpp \ 58 microkde/kglobal.cpp \
60 microkde/kglobalsettings.cpp \ 59 microkde/kglobalsettings.cpp \
61 microkde/kcolorbtn.cpp \ 60 microkde/kcolorbtn.cpp \
62 \ 61 \
63 \ 62 \
64 qt3back/qregexp3.cpp \ 63 qt3back/qregexp3.cpp \
65 ktexteditor/ktexteditor.cpp \ 64 ktexteditor/ktexteditor.cpp \
66 document/katebuffer.cpp document/katedialogs.cpp \ 65 document/katebuffer.cpp document/katedialogs.cpp \
67 document/katehighlight.cpp \ 66 document/katehighlight.cpp \
68 document/katecmd.cpp \ 67 document/katecmd.cpp \
69 document/katesyntaxdocument.cpp document/katecmds.cpp \ 68 document/katesyntaxdocument.cpp document/katecmds.cpp \
70 document/katedocument.cpp document/katetextline.cpp \ 69 document/katedocument.cpp document/katetextline.cpp \
71 view/kateundohistory.cpp \ 70 view/kateundohistory.cpp \
72 view/kateview.cpp \ 71 view/kateview.cpp \
73 view/kateviewdialog.cpp \ 72 view/kateviewdialog.cpp \
74 interfaces/interfaces.cpp 73 interfaces/interfaces.cpp
75 74
76 INTERFACES= 75 INTERFACES=
77 INCLUDEPATH+= $(OPIEDIR)/include $(OPIEDIR)/noncore/apps/tinykate/libkate/microkde \ 76 INCLUDEPATH+= $(OPIEDIR)/include \
77 $(OPIEDIR)/noncore/apps/tinykate/libkate \
78 $(OPIEDIR)/noncore/apps/tinykate/libkate/microkde \
78 $(OPIEDIR)/noncore/apps/tinykate/libkate/document \ 79 $(OPIEDIR)/noncore/apps/tinykate/libkate/document \
79 $(OPIEDIR)/noncore/apps/tinykate/libkate/view \ 80 $(OPIEDIR)/noncore/apps/tinykate/libkate/view \
80 $(OPIEDIR)/noncore/apps/tinykate/libkate/interfaces \ 81 $(OPIEDIR)/noncore/apps/tinykate/libkate/interfaces \
81 $(OPIEDIR)/noncore/apps/tinykate/libkate/ktexteditor \ 82 $(OPIEDIR)/noncore/apps/tinykate/libkate/ktexteditor \
82 $(OPIEDIR)/noncore/apps/tinykate/libkate/qt3back 83 $(OPIEDIR)/noncore/apps/tinykate/libkate/qt3back
83 DEPENDPATH+= $(OPIEDIR)/include 84 DEPENDPATH+= $(OPIEDIR)/include
84LIBS += -lqpe -lopie 85LIBS += -lqpe -lopie
85 TARGET = tinykate 86 TARGET = tinykate
86 87
87INCLUDEPATH += $(OPIEDIR)/include 88INCLUDEPATH += $(OPIEDIR)/include
88DESTDIR = $(OPIEDIR)/lib$(PROJMAK) 89DESTDIR = $(OPIEDIR)/lib$(PROJMAK)
89 90
90include ( $(OPIEDIR)/include.pro ) 91include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/apps/tinykate/libkate/microkde/kconfig.cpp b/noncore/apps/tinykate/libkate/microkde/kconfig.cpp
deleted file mode 100644
index d88bda0..0000000
--- a/noncore/apps/tinykate/libkate/microkde/kconfig.cpp
+++ b/dev/null
@@ -1,181 +0,0 @@
1#include <qfile.h>
2#include <qtextstream.h>
3
4#include "kdebug.h"
5
6#include "kconfig.h"
7
8QString KConfig::mGroup = "";
9//QString KConfig::mGroup = "General";
10
11KConfig::KConfig( const QString &fileName )
12 : mFileName( fileName ), mDirty( false )
13{
14 kdDebug() << "KConfig::KConfig(): '" << fileName << "'" << endl;
15
16 load();
17}
18
19
20KConfig::~KConfig()
21{
22 sync();
23}
24
25void KConfig::setGroup( const QString &group )
26{
27 return;
28
29// kdDebug() << "KConfig::setGroup(): '" << group << "'" << endl;
30
31 mGroup = group;
32
33 if ( mGroup.right( 1 ) != "/" ) mGroup += "/";
34}
35
36
37QValueList<int> KConfig::readIntListEntry( const QString & )
38{
39 QValueList<int> l;
40 return l;
41}
42
43int KConfig::readNumEntry( const QString &, int def )
44{
45 return def;
46}
47
48QString KConfig::readEntry( const QString &key, const QString &def )
49{
50 QMap<QString,QString>::ConstIterator it = mStringMap.find( mGroup + key );
51
52 if ( it == mStringMap.end() ) {
53 return def;
54 }
55
56 return *it;
57}
58
59QStringList KConfig::readListEntry( const QString & )
60{
61 return QStringList();
62}
63
64bool KConfig::readBoolEntry( const QString &key, bool def )
65{
66 QMap<QString,bool>::ConstIterator it = mBoolMap.find( mGroup + key );
67
68 if ( it == mBoolMap.end() ) {
69 return def;
70 }
71
72 return *it;
73}
74
75QColor KConfig::readColorEntry( const QString &, QColor *def )
76{
77 if ( def ) return *def;
78 return QColor();
79}
80
81QFont KConfig::readFontEntry( const QString &, QFont *def )
82{
83 if ( def ) return *def;
84 return QFont();
85}
86
87
88void KConfig::writeEntry( const QString &, QValueList<int> )
89{
90}
91
92void KConfig::writeEntry( const QString &, int )
93{
94}
95
96void KConfig::writeEntry( const QString &key, const QString &value )
97{
98 mStringMap.insert( mGroup + key, value );
99
100 mDirty = true;
101}
102
103void KConfig::writeEntry( const QString &, const QStringList & )
104{
105}
106
107void KConfig::writeEntry( const QString &key, bool value)
108{
109 mBoolMap.insert( mGroup + key, value );
110
111 mDirty = true;
112}
113
114void KConfig::writeEntry( const QString &, const QColor & )
115{
116}
117
118void KConfig::writeEntry( const QString &, const QFont & )
119{
120}
121
122void KConfig::load()
123{
124 mBoolMap.clear();
125 mStringMap.clear();
126
127 QFile f( mFileName );
128 if ( !f.open( IO_ReadOnly ) ) {
129 kdDebug() << "KConfig::load(): Can't open file '" << mFileName << "'"
130 << endl;
131 return;
132 }
133
134
135 QTextStream t( &f );
136
137 QString line = t.readLine();
138
139 while ( !line.isNull() ) {
140 QStringList tokens = QStringList::split( ",", line );
141 if ( tokens[0] == "bool" ) {
142 bool value = false;
143 if ( tokens[2] == "1" ) value = true;
144
145 mBoolMap.insert( tokens[1], value );
146 } else if ( tokens[0] == "QString" ) {
147 QString value = tokens[2];
148 mStringMap.insert( tokens[1], value );
149 }
150
151 line = t.readLine();
152 }
153}
154
155void KConfig::sync()
156{
157 if ( !mDirty ) return;
158
159 QFile f( mFileName );
160 if ( !f.open( IO_WriteOnly ) ) {
161 kdDebug() << "KConfig::sync(): Can't open file '" << mFileName << "'"
162 << endl;
163 return;
164 }
165
166 QTextStream t( &f );
167
168 QMap<QString,bool>::ConstIterator itBool;
169 for( itBool = mBoolMap.begin(); itBool != mBoolMap.end(); ++itBool ) {
170 t << "bool," << itBool.key() << "," << (*itBool ) << endl;
171 }
172
173 QMap<QString,QString>::ConstIterator itString;
174 for( itString = mStringMap.begin(); itString != mStringMap.end(); ++itString ) {
175 t << "QString," << itString.key() << "," << (*itString ) << endl;
176 }
177
178 f.close();
179
180 mDirty = false;
181}
diff --git a/noncore/apps/tinykate/libkate/microkde/kconfig.h b/noncore/apps/tinykate/libkate/microkde/kconfig.h
deleted file mode 100644
index 8bd768a..0000000
--- a/noncore/apps/tinykate/libkate/microkde/kconfig.h
+++ b/dev/null
@@ -1,51 +0,0 @@
1#ifndef MINIKDE_KCONFIG_H
2#define MINIKDE_KCONFIG_H
3
4#include <qstring.h>
5#include <qstringlist.h>
6#include <qvaluelist.h>
7#include <qcolor.h>
8#include <qfont.h>
9#include <qmap.h>
10
11class KConfig
12{
13 public:
14 KConfig( const QString & );
15 ~KConfig();
16
17 void setGroup( const QString & );
18
19 bool hasGroup( const QString &) {return false;}
20
21 QValueList<int> readIntListEntry( const QString & );
22 int readNumEntry( const QString &, int def=0 );
23 QString readEntry( const QString &, const QString &def=QString::null );
24 QStringList readListEntry( const QString & );
25 bool readBoolEntry( const QString &, bool def=false );
26 QColor readColorEntry( const QString &, QColor * );
27 QFont readFontEntry( const QString &, QFont * );
28
29 void writeEntry( const QString &, QValueList<int> );
30 void writeEntry( const QString &, int );
31 void writeEntry( const QString &, const QString & );
32 void writeEntry( const QString &, const QStringList & );
33 void writeEntry( const QString &, bool );
34 void writeEntry( const QString &, const QColor & );
35 void writeEntry( const QString &, const QFont & );
36
37 void load();
38 void sync();
39
40 private:
41 static QString mGroup;
42
43 QString mFileName;
44
45 QMap<QString,bool> mBoolMap;
46 QMap<QString,QString> mStringMap;
47
48 bool mDirty;
49};
50
51#endif
diff --git a/noncore/apps/tinykate/libkate/microkde/kglobal.cpp b/noncore/apps/tinykate/libkate/microkde/kglobal.cpp
index 572768d..9b5c4d3 100644
--- a/noncore/apps/tinykate/libkate/microkde/kglobal.cpp
+++ b/noncore/apps/tinykate/libkate/microkde/kglobal.cpp
@@ -1,49 +1,49 @@
1#include "kglobal.h" 1#include "kglobal.h"
2 2
3KLocale *KGlobal::mLocale = 0; 3KLocale *KGlobal::mLocale = 0;
4KConfig *KGlobal::mConfig = 0; 4KateConfig *KGlobal::mConfig = 0;
5KIconLoader *KGlobal::mIconLoader = 0; 5KIconLoader *KGlobal::mIconLoader = 0;
6KStandardDirs *KGlobal::mDirs = 0; 6KStandardDirs *KGlobal::mDirs = 0;
7 7
8QString KGlobal::mAppName = "godot"; 8QString KGlobal::mAppName = "godot";
9 9
10KLocale *KGlobal::locale() 10KLocale *KGlobal::locale()
11{ 11{
12 if ( !mLocale ) { 12 if ( !mLocale ) {
13 mLocale = new KLocale(); 13 mLocale = new KLocale();
14 } 14 }
15 15
16 return mLocale; 16 return mLocale;
17} 17}
18 18
19KConfig *KGlobal::config() 19KateConfig *KGlobal::config()
20{ 20{
21 if ( !mConfig ) { 21 if ( !mConfig ) {
22 mConfig = new KConfig( KStandardDirs::appDir() + mAppName + "rc" ); 22 mConfig = new KateConfig( mAppName );
23 } 23 }
24 24
25 return mConfig; 25 return mConfig;
26} 26}
27 27
28KIconLoader *KGlobal::iconLoader() 28KIconLoader *KGlobal::iconLoader()
29{ 29{
30 if ( !mIconLoader ) { 30 if ( !mIconLoader ) {
31 mIconLoader = new KIconLoader(); 31 mIconLoader = new KIconLoader();
32 } 32 }
33 33
34 return mIconLoader; 34 return mIconLoader;
35} 35}
36 36
37KStandardDirs *KGlobal::dirs() 37KStandardDirs *KGlobal::dirs()
38{ 38{
39 if ( !mDirs ) { 39 if ( !mDirs ) {
40 mDirs = new KStandardDirs(); 40 mDirs = new KStandardDirs();
41 } 41 }
42 42
43 return mDirs; 43 return mDirs;
44} 44}
45 45
46void KGlobal::setAppName( const QString &appName ) 46void KGlobal::setAppName( const QString &appName )
47{ 47{
48 mAppName = appName; 48 mAppName = appName;
49} 49}
diff --git a/noncore/apps/tinykate/libkate/microkde/kglobal.h b/noncore/apps/tinykate/libkate/microkde/kglobal.h
index 8985bd4..e4e2c79 100644
--- a/noncore/apps/tinykate/libkate/microkde/kglobal.h
+++ b/noncore/apps/tinykate/libkate/microkde/kglobal.h
@@ -1,27 +1,27 @@
1#ifndef MINIKDE_KGLOBAL_H 1#ifndef MINIKDE_KGLOBAL_H
2#define MINIKDE_KGLOBAL_H 2#define MINIKDE_KGLOBAL_H
3 3
4#include "klocale.h" 4#include "klocale.h"
5#include "kiconloader.h" 5#include "kiconloader.h"
6#include "kstandarddirs.h" 6#include "kstandarddirs.h"
7#include "kconfig.h" 7#include <kateconfig.h>
8 8
9class KGlobal { 9class KGlobal {
10 public: 10 public:
11 static KLocale *locale(); 11 static KLocale *locale();
12 static KConfig *config(); 12 static KateConfig *config();
13 static KIconLoader *iconLoader(); 13 static KIconLoader *iconLoader();
14 static KStandardDirs *dirs(); 14 static KStandardDirs *dirs();
15 15
16 static void setAppName( const QString & ); 16 static void setAppName( const QString & );
17 17
18 private: 18 private:
19 static KLocale *mLocale; 19 static KLocale *mLocale;
20 static KConfig *mConfig; 20 static KateConfig *mConfig;
21 static KIconLoader *mIconLoader; 21 static KIconLoader *mIconLoader;
22 static KStandardDirs *mDirs; 22 static KStandardDirs *mDirs;
23 23
24 static QString mAppName; 24 static QString mAppName;
25}; 25};
26 26
27#endif 27#endif
diff --git a/noncore/apps/tinykate/libkate/view/kateview.cpp b/noncore/apps/tinykate/libkate/view/kateview.cpp
index 63e941f..af3b30d 100644
--- a/noncore/apps/tinykate/libkate/view/kateview.cpp
+++ b/noncore/apps/tinykate/libkate/view/kateview.cpp
@@ -1,187 +1,187 @@
1/*************************************************************************** 1/***************************************************************************
2 kateview.cpp - description 2 kateview.cpp - description
3 ------------------- 3 -------------------
4 begin : Mon Jan 15 2001 4 begin : Mon Jan 15 2001
5 copyright : (C) 2001 by Christoph "Crossfire" Cullmann 5 copyright : (C) 2001 by Christoph "Crossfire" Cullmann
6 (C) 2002 by Joseph Wenninger 6 (C) 2002 by Joseph Wenninger
7 email : crossfire@babylon2k.de 7 email : crossfire@babylon2k.de
8 jowenn@kde.org 8 jowenn@kde.org
9 ***************************************************************************/ 9 ***************************************************************************/
10 10
11/*************************************************************************** 11/***************************************************************************
12 * * 12 * *
13 * This program is free software; you can redistribute it and/or modify * 13 * This program is free software; you can redistribute it and/or modify *
14 * it under the terms of the GNU General Public License as published by * 14 * it under the terms of the GNU General Public License as published by *
15 * the Free Software Foundation; either version 2 of the License, or * 15 * the Free Software Foundation; either version 2 of the License, or *
16 * (at your option) any later version. * 16 * (at your option) any later version. *
17 * * 17 * *
18 ***************************************************************************/ 18 ***************************************************************************/
19 19
20/* 20/*
21 Copyright (C) 1998, 1999 Jochen Wilhelmy 21 Copyright (C) 1998, 1999 Jochen Wilhelmy
22 digisnap@cs.tu-berlin.de 22 digisnap@cs.tu-berlin.de
23 23
24 This library is free software; you can redistribute it and/or 24 This library is free software; you can redistribute it and/or
25 modify it under the terms of the GNU Library General Public 25 modify it under the terms of the GNU Library General Public
26 License as published by the Free Software Foundation; either 26 License as published by the Free Software Foundation; either
27 version 2 of the License, or (at your option) any later version. 27 version 2 of the License, or (at your option) any later version.
28 28
29 This library is distributed in the hope that it will be useful, 29 This library is distributed in the hope that it will be useful,
30 but WITHOUT ANY WARRANTY; without even the implied warranty of 30 but WITHOUT ANY WARRANTY; without even the implied warranty of
31 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 31 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
32 Library General Public License for more details. 32 Library General Public License for more details.
33 33
34 You should have received a copy of the GNU Library General Public License 34 You should have received a copy of the GNU Library General Public License
35 along with this library; see the file COPYING.LIB. If not, write to 35 along with this library; see the file COPYING.LIB. If not, write to
36 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 36 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
37 Boston, MA 02111-1307, USA. 37 Boston, MA 02111-1307, USA.
38*/ 38*/
39 39
40 40
41 41
42#include "kateview.h" 42#include "kateview.h"
43 43
44#include "../document/katedocument.h" 44#include "../document/katedocument.h"
45#include "../document/katecmd.h" 45#include "../document/katecmd.h"
46#include "../document/katehighlight.h" 46#include "../document/katehighlight.h"
47#include "kateviewdialog.h" 47#include "kateviewdialog.h"
48#include "../document/katedialogs.h" 48#include "../document/katedialogs.h"
49#include <kateconfig.h>
49 50
50#include <qfocusdata.h> 51#include <qfocusdata.h>
51#include <kdebug.h> 52#include <kdebug.h>
52#include <kapplication.h> 53#include <kapplication.h>
53#include <qscrollbar.h> 54#include <qscrollbar.h>
54#include <qiodevice.h> 55#include <qiodevice.h>
55#include <qpopupmenu.h> 56#include <qpopupmenu.h>
56#include <kpopupmenu.h> 57#include <kpopupmenu.h>
57#include <qkeycode.h> 58#include <qkeycode.h>
58#include <qintdict.h> 59#include <qintdict.h>
59#include <kconfig.h>
60#include <qfont.h> 60#include <qfont.h>
61#include <qpainter.h> 61#include <qpainter.h>
62#include <qpixmap.h> 62#include <qpixmap.h>
63#include <qfileinfo.h> 63#include <qfileinfo.h>
64#include <qfile.h> 64#include <qfile.h>
65#include <qevent.h> 65#include <qevent.h>
66#include <qdir.h> 66#include <qdir.h>
67#include <qvbox.h> 67#include <qvbox.h>
68#include <qprintdialog.h> 68#include <qprintdialog.h>
69#include <qpaintdevicemetrics.h> 69#include <qpaintdevicemetrics.h>
70#include <qiodevice.h> 70#include <qiodevice.h>
71#include <qbuffer.h> 71#include <qbuffer.h>
72#include <qfocusdata.h> 72#include <qfocusdata.h>
73#include <klocale.h> 73#include <klocale.h>
74#include <kglobal.h> 74#include <kglobal.h>
75#include <kdebug.h> 75#include <kdebug.h>
76#include <kmessagebox.h> 76#include <kmessagebox.h>
77#include <qregexp.h> 77#include <qregexp.h>
78#include <kdialogbase.h> 78#include <kdialogbase.h>
79#include <klineeditdlg.h> 79#include <klineeditdlg.h>
80#include <qapplication.h> 80#include <qapplication.h>
81#include <kfiledialog.h> 81#include <kfiledialog.h>
82#include <kiconloader.h> 82#include <kiconloader.h>
83#include "../document/katetextline.h" 83#include "../document/katetextline.h"
84#include "kateviewdialog.h" 84#include "kateviewdialog.h"
85#include "kateundohistory.h" 85#include "kateundohistory.h"
86#include <qlayout.h> 86#include <qlayout.h>
87 87
88KateViewInternal::KateViewInternal(KateView *view, KateDocument *doc) : QWidget(view) 88KateViewInternal::KateViewInternal(KateView *view, KateDocument *doc) : QWidget(view)
89{ 89{
90 waitForPreHighlight=-1; 90 waitForPreHighlight=-1;
91 myView = view; 91 myView = view;
92 myDoc = doc; 92 myDoc = doc;
93 93
94 iconBorderWidth = 16; 94 iconBorderWidth = 16;
95 iconBorderHeight = 800; 95 iconBorderHeight = 800;
96 96
97 QWidget::setCursor(ibeamCursor); 97 QWidget::setCursor(ibeamCursor);
98 setBackgroundMode(NoBackground); 98 setBackgroundMode(NoBackground);
99 99
100 setFocusPolicy(StrongFocus); 100 setFocusPolicy(StrongFocus);
101 101
102 xScroll = new QScrollBar(QScrollBar::Horizontal,myView); 102 xScroll = new QScrollBar(QScrollBar::Horizontal,myView);
103 yScroll = new QScrollBar(QScrollBar::Vertical,myView); 103 yScroll = new QScrollBar(QScrollBar::Vertical,myView);
104 connect(xScroll,SIGNAL(valueChanged(int)),SLOT(changeXPos(int))); 104 connect(xScroll,SIGNAL(valueChanged(int)),SLOT(changeXPos(int)));
105 connect(yScroll,SIGNAL(valueChanged(int)),SLOT(changeYPos(int))); 105 connect(yScroll,SIGNAL(valueChanged(int)),SLOT(changeYPos(int)));
106 connect(yScroll,SIGNAL(valueChanged(int)),myView,SIGNAL(scrollValueChanged(int))); 106 connect(yScroll,SIGNAL(valueChanged(int)),myView,SIGNAL(scrollValueChanged(int)));
107 connect( doc, SIGNAL (preHighlightChanged(long)),this,SLOT(slotPreHighlightUpdate(long))); 107 connect( doc, SIGNAL (preHighlightChanged(long)),this,SLOT(slotPreHighlightUpdate(long)));
108 108
109 xPos = 0; 109 xPos = 0;
110 yPos = 0; 110 yPos = 0;
111 111
112 scrollTimer = 0; 112 scrollTimer = 0;
113 113
114 cursor.x = 0; 114 cursor.x = 0;
115 cursor.y = 0; 115 cursor.y = 0;
116 cursorOn = false; 116 cursorOn = false;
117 cursorTimer = 0; 117 cursorTimer = 0;
118 cXPos = 0; 118 cXPos = 0;
119 cOldXPos = 0; 119 cOldXPos = 0;
120 120
121 startLine = 0; 121 startLine = 0;
122 endLine = -1; 122 endLine = -1;
123 123
124 exposeCursor = false; 124 exposeCursor = false;
125 updateState = 0; 125 updateState = 0;
126 numLines = 0; 126 numLines = 0;
127 lineRanges = 0L; 127 lineRanges = 0L;
128 newXPos = -1; 128 newXPos = -1;
129 newYPos = -1; 129 newYPos = -1;
130 130
131 drawBuffer = new QPixmap (); 131 drawBuffer = new QPixmap ();
132 drawBuffer->setOptimization (QPixmap::BestOptim); 132 drawBuffer->setOptimization (QPixmap::BestOptim);
133 133
134 bm.sXPos = 0; 134 bm.sXPos = 0;
135 bm.eXPos = -1; 135 bm.eXPos = -1;
136 136
137} 137}
138 138
139 139
140KateViewInternal::~KateViewInternal() 140KateViewInternal::~KateViewInternal()
141{ 141{
142 delete [] lineRanges; 142 delete [] lineRanges;
143 delete drawBuffer; 143 delete drawBuffer;
144} 144}
145 145
146 146
147void KateViewInternal::slotPreHighlightUpdate(long line) 147void KateViewInternal::slotPreHighlightUpdate(long line)
148{ 148{
149 //kdDebug()<<QString("slotPreHighlightUpdate - Wait for: %1, line: %2").arg(waitForPreHighlight).arg(line)<<endl; 149 //kdDebug()<<QString("slotPreHighlightUpdate - Wait for: %1, line: %2").arg(waitForPreHighlight).arg(line)<<endl;
150 if (waitForPreHighlight!=-1) 150 if (waitForPreHighlight!=-1)
151 { 151 {
152 if (line>=waitForPreHighlight) 152 if (line>=waitForPreHighlight)
153 { 153 {
154 waitForPreHighlight=-1; 154 waitForPreHighlight=-1;
155 repaint(); 155 repaint();
156 } 156 }
157 } 157 }
158} 158}
159 159
160void KateViewInternal::doCursorCommand(VConfig &c, int cmdNum) { 160void KateViewInternal::doCursorCommand(VConfig &c, int cmdNum) {
161 161
162 switch (cmdNum) { 162 switch (cmdNum) {
163 case KateView::cmLeft: 163 case KateView::cmLeft:
164 cursorLeft(c); 164 cursorLeft(c);
165 break; 165 break;
166 case KateView::cmRight: 166 case KateView::cmRight:
167 cursorRight(c); 167 cursorRight(c);
168 break; 168 break;
169 case KateView::cmWordLeft: 169 case KateView::cmWordLeft:
170 wordLeft(c); 170 wordLeft(c);
171 break; 171 break;
172 case KateView::cmWordRight: 172 case KateView::cmWordRight:
173 wordRight(c); 173 wordRight(c);
174 break; 174 break;
175 case KateView::cmHome: 175 case KateView::cmHome:
176 home(c); 176 home(c);
177 break; 177 break;
178 case KateView::cmEnd: 178 case KateView::cmEnd:
179 end(c); 179 end(c);
180 break; 180 break;
181 case KateView::cmUp: 181 case KateView::cmUp:
182 cursorUp(c); 182 cursorUp(c);
183 break; 183 break;
184 case KateView::cmDown: 184 case KateView::cmDown:
185 cursorDown(c); 185 cursorDown(c);
186 break; 186 break;
187 case KateView::cmScrollUp: 187 case KateView::cmScrollUp:
@@ -1116,262 +1116,262 @@ void KateViewInternal::mouseMoveEvent(QMouseEvent *e) {
1116 myDoc->updateViews(/*ufNoScroll*/); 1116 myDoc->updateViews(/*ufNoScroll*/);
1117 } 1117 }
1118} 1118}
1119 1119
1120 1120
1121 1121
1122void KateViewInternal::wheelEvent( QWheelEvent *e ) 1122void KateViewInternal::wheelEvent( QWheelEvent *e )
1123{ 1123{
1124 if( yScroll->isVisible() == true ) 1124 if( yScroll->isVisible() == true )
1125 { 1125 {
1126 QApplication::sendEvent( yScroll, e ); 1126 QApplication::sendEvent( yScroll, e );
1127 } 1127 }
1128} 1128}
1129 1129
1130 1130
1131 1131
1132void KateViewInternal::paintEvent(QPaintEvent *e) { 1132void KateViewInternal::paintEvent(QPaintEvent *e) {
1133 int xStart, xEnd; 1133 int xStart, xEnd;
1134 int h; 1134 int h;
1135 int line, y, yEnd; 1135 int line, y, yEnd;
1136 1136
1137 QRect updateR = e->rect(); 1137 QRect updateR = e->rect();
1138 1138
1139 if (!drawBuffer) return; 1139 if (!drawBuffer) return;
1140 if (drawBuffer->isNull()) return; 1140 if (drawBuffer->isNull()) return;
1141 1141
1142 QPainter paint; 1142 QPainter paint;
1143 paint.begin(drawBuffer); 1143 paint.begin(drawBuffer);
1144 1144
1145 xStart = xPos-2 + updateR.x(); 1145 xStart = xPos-2 + updateR.x();
1146 xEnd = xStart + updateR.width(); 1146 xEnd = xStart + updateR.width();
1147 1147
1148 h = myDoc->fontHeight; 1148 h = myDoc->fontHeight;
1149 line = (yPos + updateR.y()) / h; 1149 line = (yPos + updateR.y()) / h;
1150 y = line*h - yPos; 1150 y = line*h - yPos;
1151 yEnd = updateR.y() + updateR.height(); 1151 yEnd = updateR.y() + updateR.height();
1152 waitForPreHighlight=myDoc->needPreHighlight(waitForPreHighlight=line+((long)(yEnd-y)/h)+5); 1152 waitForPreHighlight=myDoc->needPreHighlight(waitForPreHighlight=line+((long)(yEnd-y)/h)+5);
1153 1153
1154 while (y < yEnd) 1154 while (y < yEnd)
1155 { 1155 {
1156 TextLine *textLine; 1156 TextLine *textLine;
1157 int ctxNum = 0; 1157 int ctxNum = 0;
1158 myDoc->paintTextLine(paint, line, xStart, xEnd, myView->configFlags & KateView::cfShowTabs); 1158 myDoc->paintTextLine(paint, line, xStart, xEnd, myView->configFlags & KateView::cfShowTabs);
1159 bitBlt(this, updateR.x(), y, drawBuffer, 0, 0, updateR.width(), h); 1159 bitBlt(this, updateR.x(), y, drawBuffer, 0, 0, updateR.width(), h);
1160 leftBorder->paintLine(line); 1160 leftBorder->paintLine(line);
1161 line++; 1161 line++;
1162 y += h; 1162 y += h;
1163 } 1163 }
1164 paint.end(); 1164 paint.end();
1165 1165
1166 if (cursorOn) paintCursor(); 1166 if (cursorOn) paintCursor();
1167 if (bm.eXPos > bm.sXPos) paintBracketMark(); 1167 if (bm.eXPos > bm.sXPos) paintBracketMark();
1168} 1168}
1169 1169
1170void KateViewInternal::resizeEvent(QResizeEvent *) 1170void KateViewInternal::resizeEvent(QResizeEvent *)
1171{ 1171{
1172 drawBuffer->resize (width(), myDoc->fontHeight); 1172 drawBuffer->resize (width(), myDoc->fontHeight);
1173 leftBorder->resize(iconBorderWidth, height()); 1173 leftBorder->resize(iconBorderWidth, height());
1174} 1174}
1175 1175
1176void KateViewInternal::timerEvent(QTimerEvent *e) { 1176void KateViewInternal::timerEvent(QTimerEvent *e) {
1177 if (e->timerId() == cursorTimer) { 1177 if (e->timerId() == cursorTimer) {
1178 cursorOn = !cursorOn; 1178 cursorOn = !cursorOn;
1179 paintCursor(); 1179 paintCursor();
1180 } 1180 }
1181 if (e->timerId() == scrollTimer && (scrollX | scrollY)) { 1181 if (e->timerId() == scrollTimer && (scrollX | scrollY)) {
1182 xScroll->setValue(xPos + scrollX); 1182 xScroll->setValue(xPos + scrollX);
1183 yScroll->setValue(yPos + scrollY); 1183 yScroll->setValue(yPos + scrollY);
1184 1184
1185 placeCursor(mouseX, mouseY, KateView::cfMark); 1185 placeCursor(mouseX, mouseY, KateView::cfMark);
1186 myDoc->updateViews(/*ufNoScroll*/); 1186 myDoc->updateViews(/*ufNoScroll*/);
1187 } 1187 }
1188} 1188}
1189 1189
1190uint KateView::uniqueID = 0; 1190uint KateView::uniqueID = 0;
1191 1191
1192KateView::KateView(KateDocument *doc, QWidget *parent, const char * name) : Kate::View (doc, parent, name) 1192KateView::KateView(KateDocument *doc, QWidget *parent, const char * name) : Kate::View (doc, parent, name)
1193{ 1193{
1194 1194
1195 myViewID = uniqueID; 1195 myViewID = uniqueID;
1196 uniqueID++; 1196 uniqueID++;
1197 1197
1198 active = false; 1198 active = false;
1199 myIconBorder = false; 1199 myIconBorder = false;
1200 1200
1201 myDoc = doc; 1201 myDoc = doc;
1202 myViewInternal = new KateViewInternal (this,doc); 1202 myViewInternal = new KateViewInternal (this,doc);
1203 myViewInternal->move(2, 2); 1203 myViewInternal->move(2, 2);
1204 myViewInternal->leftBorder = new KateIconBorder(this, myViewInternal); 1204 myViewInternal->leftBorder = new KateIconBorder(this, myViewInternal);
1205 myViewInternal->leftBorder->setGeometry(2, 2, myViewInternal->iconBorderWidth, myViewInternal->iconBorderHeight); 1205 myViewInternal->leftBorder->setGeometry(2, 2, myViewInternal->iconBorderWidth, myViewInternal->iconBorderHeight);
1206 myViewInternal->leftBorder->hide(); 1206 myViewInternal->leftBorder->hide();
1207 1207
1208 doc->addView( this ); 1208 doc->addView( this );
1209 1209
1210 1210
1211 // some defaults 1211 // some defaults
1212 configFlags = KateView::cfAutoIndent | KateView::cfBackspaceIndents 1212 configFlags = KateView::cfAutoIndent | KateView::cfBackspaceIndents
1213 | KateView::cfTabIndents | KateView::cfKeepIndentProfile 1213 | KateView::cfTabIndents | KateView::cfKeepIndentProfile
1214 | KateView::cfRemoveSpaces 1214 | KateView::cfRemoveSpaces
1215 | KateView::cfDelOnInput | KateView::cfMouseAutoCopy | KateView::cfWrapCursor 1215 | KateView::cfDelOnInput | KateView::cfMouseAutoCopy | KateView::cfWrapCursor
1216 | KateView::cfGroupUndo | KateView::cfShowTabs | KateView::cfSmartHome; 1216 | KateView::cfGroupUndo | KateView::cfShowTabs | KateView::cfSmartHome;
1217 1217
1218 searchFlags = 0; 1218 searchFlags = 0;
1219 replacePrompt = 0L; 1219 replacePrompt = 0L;
1220 rmbMenu = 0L; 1220 rmbMenu = 0L;
1221 1221
1222 1222
1223 setFocusProxy( myViewInternal ); 1223 setFocusProxy( myViewInternal );
1224 myViewInternal->setFocus(); 1224 myViewInternal->setFocus();
1225 resize(parent->width() -4, parent->height() -4); 1225 resize(parent->width() -4, parent->height() -4);
1226 1226
1227 1227
1228 myViewInternal->installEventFilter( this ); 1228 myViewInternal->installEventFilter( this );
1229 1229
1230 //setupActions(); 1230 //setupActions();
1231 1231
1232 connect( this, SIGNAL( newStatus() ), this, SLOT( slotUpdate() ) ); 1232 connect( this, SIGNAL( newStatus() ), this, SLOT( slotUpdate() ) );
1233 connect( this, SIGNAL( newUndo() ), this, SLOT( slotNewUndo() ) ); 1233 connect( this, SIGNAL( newUndo() ), this, SLOT( slotNewUndo() ) );
1234 connect( doc, SIGNAL( fileNameChanged() ), this, SLOT( slotFileStatusChanged() ) ); 1234 connect( doc, SIGNAL( fileNameChanged() ), this, SLOT( slotFileStatusChanged() ) );
1235 connect( doc, SIGNAL( highlightChanged() ), this, SLOT( slotHighlightChanged() ) ); 1235 connect( doc, SIGNAL( highlightChanged() ), this, SLOT( slotHighlightChanged() ) );
1236 1236
1237 readConfig(); 1237 readConfig();
1238// setHighlight->setCurrentItem(getHl()); 1238// setHighlight->setCurrentItem(getHl());
1239 slotUpdate(); 1239 slotUpdate();
1240} 1240}
1241 1241
1242KateView::~KateView() 1242KateView::~KateView()
1243{ 1243{
1244 writeConfig();
1244 1245
1245 if (myDoc && !myDoc->m_bSingleViewMode) 1246 if (myDoc && !myDoc->m_bSingleViewMode)
1246 myDoc->removeView( this ); 1247 myDoc->removeView( this );
1247 1248
1248 delete myViewInternal; 1249 delete myViewInternal;
1249
1250} 1250}
1251 1251
1252#if 0 1252#if 0
1253void KateView::setupActions() 1253void KateView::setupActions()
1254{ 1254{
1255#if 0 1255#if 0
1256 KStdAction::close( this, SLOT(flush()), actionCollection(), "file_close" ); 1256 KStdAction::close( this, SLOT(flush()), actionCollection(), "file_close" );
1257 1257
1258 KStdAction::save(this, SLOT(save()), actionCollection()); 1258 KStdAction::save(this, SLOT(save()), actionCollection());
1259 1259
1260 // setup edit menu 1260 // setup edit menu
1261 editUndo = KStdAction::undo(this, SLOT(undo()), actionCollection()); 1261 editUndo = KStdAction::undo(this, SLOT(undo()), actionCollection());
1262 editRedo = KStdAction::redo(this, SLOT(redo()), actionCollection()); 1262 editRedo = KStdAction::redo(this, SLOT(redo()), actionCollection());
1263 editUndoHist = new KAction(i18n("Undo/Redo &History..."), 0, this, SLOT(undoHistory()), 1263 editUndoHist = new KAction(i18n("Undo/Redo &History..."), 0, this, SLOT(undoHistory()),
1264 actionCollection(), "edit_undoHistory"); 1264 actionCollection(), "edit_undoHistory");
1265 KStdAction::cut(this, SLOT(cut()), actionCollection()); 1265 KStdAction::cut(this, SLOT(cut()), actionCollection());
1266 KStdAction::copy(this, SLOT(copy()), actionCollection()); 1266 KStdAction::copy(this, SLOT(copy()), actionCollection());
1267 KStdAction::paste(this, SLOT(paste()), actionCollection()); 1267 KStdAction::paste(this, SLOT(paste()), actionCollection());
1268 1268
1269 if ( myDoc->hasBrowserExtension() ) 1269 if ( myDoc->hasBrowserExtension() )
1270 { 1270 {
1271 KStdAction::saveAs(this, SLOT(saveAs()), myDoc->actionCollection()); 1271 KStdAction::saveAs(this, SLOT(saveAs()), myDoc->actionCollection());
1272 KStdAction::find(this, SLOT(find()), myDoc->actionCollection(), "find"); 1272 KStdAction::find(this, SLOT(find()), myDoc->actionCollection(), "find");
1273 KStdAction::findNext(this, SLOT(findAgain()), myDoc->actionCollection(), "find_again"); 1273 KStdAction::findNext(this, SLOT(findAgain()), myDoc->actionCollection(), "find_again");
1274 KStdAction::findPrev(this, SLOT(findPrev()), myDoc->actionCollection(), "find_prev"); 1274 KStdAction::findPrev(this, SLOT(findPrev()), myDoc->actionCollection(), "find_prev");
1275 KStdAction::gotoLine(this, SLOT(gotoLine()), myDoc->actionCollection(), "goto_line" ); 1275 KStdAction::gotoLine(this, SLOT(gotoLine()), myDoc->actionCollection(), "goto_line" );
1276 new KAction(i18n("&Configure Editor..."), 0, this, SLOT(configDialog()),myDoc->actionCollection(), "set_confdlg"); 1276 new KAction(i18n("&Configure Editor..."), 0, this, SLOT(configDialog()),myDoc->actionCollection(), "set_confdlg");
1277 setHighlight = new KSelectAction(i18n("&Highlight Mode"), 0, myDoc->actionCollection(), "set_highlight"); 1277 setHighlight = new KSelectAction(i18n("&Highlight Mode"), 0, myDoc->actionCollection(), "set_highlight");
1278 KStdAction::selectAll(this, SLOT(selectAll()), myDoc->actionCollection(), "select_all"); 1278 KStdAction::selectAll(this, SLOT(selectAll()), myDoc->actionCollection(), "select_all");
1279 new KAction(i18n("&Deselect All"), 0, this, SLOT(deselectAll()), 1279 new KAction(i18n("&Deselect All"), 0, this, SLOT(deselectAll()),
1280 myDoc->actionCollection(), "unselect_all"); 1280 myDoc->actionCollection(), "unselect_all");
1281 new KAction(i18n("Invert &Selection"), 0, this, SLOT(invertSelection()), 1281 new KAction(i18n("Invert &Selection"), 0, this, SLOT(invertSelection()),
1282 myDoc->actionCollection(), "invert_select"); 1282 myDoc->actionCollection(), "invert_select");
1283 1283
1284 new KAction(i18n("Increase Font Sizes"), "viewmag+", 0, this, SLOT(slotIncFontSizes()), 1284 new KAction(i18n("Increase Font Sizes"), "viewmag+", 0, this, SLOT(slotIncFontSizes()),
1285 myDoc->actionCollection(), "incFontSizes"); 1285 myDoc->actionCollection(), "incFontSizes");
1286 new KAction(i18n("Decrease Font Sizes"), "viewmag-", 0, this, SLOT(slotDecFontSizes()), 1286 new KAction(i18n("Decrease Font Sizes"), "viewmag-", 0, this, SLOT(slotDecFontSizes()),
1287 myDoc->actionCollection(), "decFontSizes"); 1287 myDoc->actionCollection(), "decFontSizes");
1288 } 1288 }
1289 else 1289 else
1290 { 1290 {
1291 KStdAction::saveAs(this, SLOT(saveAs()), actionCollection()); 1291 KStdAction::saveAs(this, SLOT(saveAs()), actionCollection());
1292 KStdAction::find(this, SLOT(find()), actionCollection()); 1292 KStdAction::find(this, SLOT(find()), actionCollection());
1293 KStdAction::findNext(this, SLOT(findAgain()), actionCollection()); 1293 KStdAction::findNext(this, SLOT(findAgain()), actionCollection());
1294 KStdAction::findPrev(this, SLOT(findPrev()), actionCollection(), "edit_find_prev"); 1294 KStdAction::findPrev(this, SLOT(findPrev()), actionCollection(), "edit_find_prev");
1295 KStdAction::gotoLine(this, SLOT(gotoLine()), actionCollection()); 1295 KStdAction::gotoLine(this, SLOT(gotoLine()), actionCollection());
1296 new KAction(i18n("&Configure Editor..."), 0, this, SLOT(configDialog()),actionCollection(), "set_confdlg"); 1296 new KAction(i18n("&Configure Editor..."), 0, this, SLOT(configDialog()),actionCollection(), "set_confdlg");
1297 setHighlight = new KSelectAction(i18n("&Highlight Mode"), 0, actionCollection(), "set_highlight"); 1297 setHighlight = new KSelectAction(i18n("&Highlight Mode"), 0, actionCollection(), "set_highlight");
1298 KStdAction::selectAll(this, SLOT(selectAll()), actionCollection()); 1298 KStdAction::selectAll(this, SLOT(selectAll()), actionCollection());
1299 new KAction(i18n("&Deselect All"), 0, this, SLOT(deselectAll()), 1299 new KAction(i18n("&Deselect All"), 0, this, SLOT(deselectAll()),
1300 actionCollection(), "edit_deselectAll"); 1300 actionCollection(), "edit_deselectAll");
1301 new KAction(i18n("Invert &Selection"), 0, this, SLOT(invertSelection()), 1301 new KAction(i18n("Invert &Selection"), 0, this, SLOT(invertSelection()),
1302 actionCollection(), "edit_invertSelection"); 1302 actionCollection(), "edit_invertSelection");
1303 1303
1304 new KAction(i18n("Increase Font Sizes"), "viewmag+", 0, this, SLOT(slotIncFontSizes()), 1304 new KAction(i18n("Increase Font Sizes"), "viewmag+", 0, this, SLOT(slotIncFontSizes()),
1305 actionCollection(), "incFontSizes"); 1305 actionCollection(), "incFontSizes");
1306 new KAction(i18n("Decrease Font Sizes"), "viewmag-", 0, this, SLOT(slotDecFontSizes()), 1306 new KAction(i18n("Decrease Font Sizes"), "viewmag-", 0, this, SLOT(slotDecFontSizes()),
1307 actionCollection(), "decFontSizes"); 1307 actionCollection(), "decFontSizes");
1308 } 1308 }
1309 1309
1310 new KAction(i18n("Apply Word Wrap"), 0, myDoc, SLOT(applyWordWrap()), actionCollection(), "edit_apply_wordwrap"); 1310 new KAction(i18n("Apply Word Wrap"), 0, myDoc, SLOT(applyWordWrap()), actionCollection(), "edit_apply_wordwrap");
1311 1311
1312 KStdAction::replace(this, SLOT(replace()), actionCollection()); 1312 KStdAction::replace(this, SLOT(replace()), actionCollection());
1313 1313
1314 new KAction(i18n("Editing Co&mmand"), Qt::CTRL+Qt::Key_M, this, SLOT(slotEditCommand()), 1314 new KAction(i18n("Editing Co&mmand"), Qt::CTRL+Qt::Key_M, this, SLOT(slotEditCommand()),
1315 actionCollection(), "edit_cmd"); 1315 actionCollection(), "edit_cmd");
1316 1316
1317 // setup bookmark menu 1317 // setup bookmark menu
1318 bookmarkToggle = new KAction(i18n("Toggle &Bookmark"), Qt::CTRL+Qt::Key_B, this, SLOT(toggleBookmark()), actionCollection(), "edit_bookmarkToggle"); 1318 bookmarkToggle = new KAction(i18n("Toggle &Bookmark"), Qt::CTRL+Qt::Key_B, this, SLOT(toggleBookmark()), actionCollection(), "edit_bookmarkToggle");
1319 bookmarkClear = new KAction(i18n("Clear Bookmarks"), 0, this, SLOT(clearBookmarks()), actionCollection(), "edit_bookmarksClear"); 1319 bookmarkClear = new KAction(i18n("Clear Bookmarks"), 0, this, SLOT(clearBookmarks()), actionCollection(), "edit_bookmarksClear");
1320 1320
1321 // connect settings menu aboutToshow 1321 // connect settings menu aboutToshow
1322 bookmarkMenu = new KActionMenu(i18n("&Bookmarks"), actionCollection(), "bookmarks"); 1322 bookmarkMenu = new KActionMenu(i18n("&Bookmarks"), actionCollection(), "bookmarks");
1323 connect(bookmarkMenu->popupMenu(), SIGNAL(aboutToShow()), this, SLOT(bookmarkMenuAboutToShow())); 1323 connect(bookmarkMenu->popupMenu(), SIGNAL(aboutToShow()), this, SLOT(bookmarkMenuAboutToShow()));
1324 1324
1325 new KToggleAction(i18n("Show &IconBorder"), Key_F6, this, SLOT(toggleIconBorder()), actionCollection(), "view_border"); 1325 new KToggleAction(i18n("Show &IconBorder"), Key_F6, this, SLOT(toggleIconBorder()), actionCollection(), "view_border");
1326 1326
1327 // setup Tools menu 1327 // setup Tools menu
1328 KStdAction::spelling(this, SLOT(spellcheck()), actionCollection()); 1328 KStdAction::spelling(this, SLOT(spellcheck()), actionCollection());
1329 new KAction(i18n("&Indent"), "indent", Qt::CTRL+Qt::Key_I, this, SLOT(indent()), 1329 new KAction(i18n("&Indent"), "indent", Qt::CTRL+Qt::Key_I, this, SLOT(indent()),
1330 actionCollection(), "tools_indent"); 1330 actionCollection(), "tools_indent");
1331 new KAction(i18n("&Unindent"), "unindent", Qt::CTRL+Qt::Key_U, this, SLOT(unIndent()), 1331 new KAction(i18n("&Unindent"), "unindent", Qt::CTRL+Qt::Key_U, this, SLOT(unIndent()),
1332 actionCollection(), "tools_unindent"); 1332 actionCollection(), "tools_unindent");
1333 new KAction(i18n("&Clean Indentation"), 0, this, SLOT(cleanIndent()), 1333 new KAction(i18n("&Clean Indentation"), 0, this, SLOT(cleanIndent()),
1334 actionCollection(), "tools_cleanIndent"); 1334 actionCollection(), "tools_cleanIndent");
1335 new KAction(i18n("C&omment"), CTRL+Qt::Key_NumberSign, this, SLOT(comment()), 1335 new KAction(i18n("C&omment"), CTRL+Qt::Key_NumberSign, this, SLOT(comment()),
1336 actionCollection(), "tools_comment"); 1336 actionCollection(), "tools_comment");
1337 new KAction(i18n("Unco&mment"), CTRL+SHIFT+Qt::Key_NumberSign, this, SLOT(uncomment()), 1337 new KAction(i18n("Unco&mment"), CTRL+SHIFT+Qt::Key_NumberSign, this, SLOT(uncomment()),
1338 actionCollection(), "tools_uncomment"); 1338 actionCollection(), "tools_uncomment");
1339 1339
1340 setVerticalSelection = new KToggleAction(i18n("&Vertical Selection"), Key_F4, this, SLOT(toggleVertical()), 1340 setVerticalSelection = new KToggleAction(i18n("&Vertical Selection"), Key_F4, this, SLOT(toggleVertical()),
1341 actionCollection(), "set_verticalSelect"); 1341 actionCollection(), "set_verticalSelect");
1342 1342
1343 connect(setHighlight, SIGNAL(activated(int)), this, SLOT(setHl(int))); 1343 connect(setHighlight, SIGNAL(activated(int)), this, SLOT(setHl(int)));
1344 QStringList list; 1344 QStringList list;
1345 for (int z = 0; z < HlManager::self()->highlights(); z++) 1345 for (int z = 0; z < HlManager::self()->highlights(); z++)
1346 list.append(HlManager::self()->hlName(z)); 1346 list.append(HlManager::self()->hlName(z));
1347 setHighlight->setItems(list); 1347 setHighlight->setItems(list);
1348 1348
1349 setEndOfLine = new KSelectAction(i18n("&End Of Line"), 0, actionCollection(), "set_eol"); 1349 setEndOfLine = new KSelectAction(i18n("&End Of Line"), 0, actionCollection(), "set_eol");
1350 connect(setEndOfLine, SIGNAL(activated(int)), this, SLOT(setEol(int))); 1350 connect(setEndOfLine, SIGNAL(activated(int)), this, SLOT(setEol(int)));
1351 list.clear(); 1351 list.clear();
1352 list.append("&Unix"); 1352 list.append("&Unix");
1353 list.append("&Windows/Dos"); 1353 list.append("&Windows/Dos");
1354 list.append("&Macintosh"); 1354 list.append("&Macintosh");
1355 setEndOfLine->setItems(list); 1355 setEndOfLine->setItems(list);
1356#endif 1356#endif
1357} 1357}
1358#endif 1358#endif
1359 1359
1360void KateView::slotUpdate() 1360void KateView::slotUpdate()
1361{ 1361{
1362 int cfg = config(); 1362 int cfg = config();
1363 1363
1364#warning fixme setVerticalSelection->setChecked(cfg & KateView::cfVerticalSelect); 1364#warning fixme setVerticalSelection->setChecked(cfg & KateView::cfVerticalSelect);
1365 1365
1366 slotNewUndo(); 1366 slotNewUndo();
1367} 1367}
1368void KateView::slotFileStatusChanged() 1368void KateView::slotFileStatusChanged()
1369{ 1369{
1370 int eol = getEol(); 1370 int eol = getEol();
1371 eol = eol>=1 ? eol : 0; 1371 eol = eol>=1 ? eol : 0;
1372 1372
1373#warning fixme setEndOfLine->setCurrentItem(eol); 1373#warning fixme setEndOfLine->setCurrentItem(eol);
1374} 1374}
1375void KateView::slotNewUndo() 1375void KateView::slotNewUndo()
1376{ 1376{
1377#if 0 1377#if 0
@@ -2097,355 +2097,355 @@ void KateView::doReplaceAction(int result, bool found) {
2097 break; 2097 break;
2098 case KateView::srAll: //replace all 2098 case KateView::srAll: //replace all
2099 deleteReplacePrompt(); 2099 deleteReplacePrompt();
2100 do { 2100 do {
2101 started = false; 2101 started = false;
2102 while (found || myDoc->doSearch(s,searchFor)) { 2102 while (found || myDoc->doSearch(s,searchFor)) {
2103 if (!started) { 2103 if (!started) {
2104 found = false; 2104 found = false;
2105 myDoc->recordStart(this, s.cursor, configFlags, 2105 myDoc->recordStart(this, s.cursor, configFlags,
2106 KateActionGroup::ugReplace); 2106 KateActionGroup::ugReplace);
2107 started = true; 2107 started = true;
2108 } 2108 }
2109 myDoc->recordReplace(s.cursor, s.matchedLength, replaceWith); 2109 myDoc->recordReplace(s.cursor, s.matchedLength, replaceWith);
2110 replaces++; 2110 replaces++;
2111 if (s.cursor.y == s.startCursor.y && s.cursor.x < s.startCursor.x) 2111 if (s.cursor.y == s.startCursor.y && s.cursor.x < s.startCursor.x)
2112 s.startCursor.x += rlen - s.matchedLength; 2112 s.startCursor.x += rlen - s.matchedLength;
2113 if (!(s.flags & KateView::sfBackward)) s.cursor.x += rlen; 2113 if (!(s.flags & KateView::sfBackward)) s.cursor.x += rlen;
2114 } 2114 }
2115 if (started) myDoc->recordEnd(this, s.cursor, 2115 if (started) myDoc->recordEnd(this, s.cursor,
2116 configFlags | KateView::cfPersistent); 2116 configFlags | KateView::cfPersistent);
2117 } while (!askReplaceEnd()); 2117 } while (!askReplaceEnd());
2118 return; 2118 return;
2119 case KateView::srCancel: //cancel 2119 case KateView::srCancel: //cancel
2120 deleteReplacePrompt(); 2120 deleteReplacePrompt();
2121 return; 2121 return;
2122 default: 2122 default:
2123 replacePrompt = 0L; 2123 replacePrompt = 0L;
2124 } 2124 }
2125 2125
2126 do { 2126 do {
2127 if (myDoc->doSearch(s,searchFor)) { 2127 if (myDoc->doSearch(s,searchFor)) {
2128 //text found: highlight it, show replace prompt if needed and exit 2128 //text found: highlight it, show replace prompt if needed and exit
2129 cursor = s.cursor; 2129 cursor = s.cursor;
2130 if (!(s.flags & KateView::sfBackward)) cursor.x += s.matchedLength; 2130 if (!(s.flags & KateView::sfBackward)) cursor.x += s.matchedLength;
2131 myViewInternal->updateCursor(cursor); //does deselectAll() 2131 myViewInternal->updateCursor(cursor); //does deselectAll()
2132 exposeFound(s.cursor,s.matchedLength,(s.flags & KateView::sfAgain) ? 0 : KateView::ufUpdateOnScroll,true); 2132 exposeFound(s.cursor,s.matchedLength,(s.flags & KateView::sfAgain) ? 0 : KateView::ufUpdateOnScroll,true);
2133 if (replacePrompt == 0L) { 2133 if (replacePrompt == 0L) {
2134 replacePrompt = new ReplacePrompt(this); 2134 replacePrompt = new ReplacePrompt(this);
2135 myDoc->setPseudoModal(replacePrompt);//disable(); 2135 myDoc->setPseudoModal(replacePrompt);//disable();
2136 connect(replacePrompt,SIGNAL(clicked()),this,SLOT(replaceSlot())); 2136 connect(replacePrompt,SIGNAL(clicked()),this,SLOT(replaceSlot()));
2137 replacePrompt->show(); //this is not modal 2137 replacePrompt->show(); //this is not modal
2138 } 2138 }
2139 return; //exit if text found 2139 return; //exit if text found
2140 } 2140 }
2141 //nothing found: repeat until user cancels "repeat from beginning" dialog 2141 //nothing found: repeat until user cancels "repeat from beginning" dialog
2142 } while (!askReplaceEnd()); 2142 } while (!askReplaceEnd());
2143 deleteReplacePrompt(); 2143 deleteReplacePrompt();
2144} 2144}
2145 2145
2146void KateView::exposeFound(PointStruc &cursor, int slen, int flags, bool replace) { 2146void KateView::exposeFound(PointStruc &cursor, int slen, int flags, bool replace) {
2147 int x1, x2, y1, y2, xPos, yPos; 2147 int x1, x2, y1, y2, xPos, yPos;
2148 2148
2149 VConfig c; 2149 VConfig c;
2150 myViewInternal->getVConfig(c); 2150 myViewInternal->getVConfig(c);
2151 myDoc->selectLength(cursor,slen,c.flags); 2151 myDoc->selectLength(cursor,slen,c.flags);
2152 2152
2153 TextLine::Ptr textLine = myDoc->getTextLine(cursor.y); 2153 TextLine::Ptr textLine = myDoc->getTextLine(cursor.y);
2154 x1 = myDoc->textWidth(textLine,cursor.x) -10; 2154 x1 = myDoc->textWidth(textLine,cursor.x) -10;
2155 x2 = myDoc->textWidth(textLine,cursor.x + slen) +20; 2155 x2 = myDoc->textWidth(textLine,cursor.x + slen) +20;
2156 y1 = myDoc->fontHeight*cursor.y -10; 2156 y1 = myDoc->fontHeight*cursor.y -10;
2157 y2 = y1 + myDoc->fontHeight +30; 2157 y2 = y1 + myDoc->fontHeight +30;
2158 2158
2159 xPos = myViewInternal->xPos; 2159 xPos = myViewInternal->xPos;
2160 yPos = myViewInternal->yPos; 2160 yPos = myViewInternal->yPos;
2161 2161
2162 if (x1 < 0) x1 = 0; 2162 if (x1 < 0) x1 = 0;
2163 if (replace) y2 += 90; 2163 if (replace) y2 += 90;
2164 2164
2165 if (x1 < xPos || x2 > xPos + myViewInternal->width()) { 2165 if (x1 < xPos || x2 > xPos + myViewInternal->width()) {
2166 xPos = x2 - myViewInternal->width(); 2166 xPos = x2 - myViewInternal->width();
2167 } 2167 }
2168 if (y1 < yPos || y2 > yPos + myViewInternal->height()) { 2168 if (y1 < yPos || y2 > yPos + myViewInternal->height()) {
2169 xPos = x2 - myViewInternal->width(); 2169 xPos = x2 - myViewInternal->width();
2170 yPos = myDoc->fontHeight*cursor.y - height()/3; 2170 yPos = myDoc->fontHeight*cursor.y - height()/3;
2171 } 2171 }
2172 myViewInternal->setPos(xPos, yPos); 2172 myViewInternal->setPos(xPos, yPos);
2173 myViewInternal->updateView(flags);// | ufPos,xPos,yPos); 2173 myViewInternal->updateView(flags);// | ufPos,xPos,yPos);
2174 myDoc->updateViews(this); 2174 myDoc->updateViews(this);
2175} 2175}
2176 2176
2177void KateView::deleteReplacePrompt() { 2177void KateView::deleteReplacePrompt() {
2178 myDoc->setPseudoModal(0L); 2178 myDoc->setPseudoModal(0L);
2179} 2179}
2180 2180
2181bool KateView::askReplaceEnd() { 2181bool KateView::askReplaceEnd() {
2182 QString str; 2182 QString str;
2183 int query; 2183 int query;
2184 2184
2185 myDoc->updateViews(); 2185 myDoc->updateViews();
2186 if (s.flags & KateView::sfFinished) { 2186 if (s.flags & KateView::sfFinished) {
2187 // replace finished 2187 // replace finished
2188 str = i18n("%1 replacement(s) made").arg(replaces); 2188 str = i18n("%1 replacement(s) made").arg(replaces);
2189 KMessageBox::information(this, str, i18n("Replace")); 2189 KMessageBox::information(this, str, i18n("Replace"));
2190 return true; 2190 return true;
2191 } 2191 }
2192 2192
2193 // ask for continue 2193 // ask for continue
2194 if (!(s.flags & KateView::sfBackward)) { 2194 if (!(s.flags & KateView::sfBackward)) {
2195 // forward search 2195 // forward search
2196 str = i18n("%1 replacement(s) made.\n" 2196 str = i18n("%1 replacement(s) made.\n"
2197 "End of document reached.\n" 2197 "End of document reached.\n"
2198 "Continue from the beginning?").arg(replaces); 2198 "Continue from the beginning?").arg(replaces);
2199 query = KMessageBox::questionYesNo(this, str, i18n("Replace"), 2199 query = KMessageBox::questionYesNo(this, str, i18n("Replace"),
2200 i18n("Continue"), i18n("Stop")); 2200 i18n("Continue"), i18n("Stop"));
2201 } else { 2201 } else {
2202 // backward search 2202 // backward search
2203 str = i18n("%1 replacement(s) made.\n" 2203 str = i18n("%1 replacement(s) made.\n"
2204 "Beginning of document reached.\n" 2204 "Beginning of document reached.\n"
2205 "Continue from the end?").arg(replaces); 2205 "Continue from the end?").arg(replaces);
2206 query = KMessageBox::questionYesNo(this, str, i18n("Replace"), 2206 query = KMessageBox::questionYesNo(this, str, i18n("Replace"),
2207 i18n("Continue"), i18n("Stop")); 2207 i18n("Continue"), i18n("Stop"));
2208 } 2208 }
2209 replaces = 0; 2209 replaces = 0;
2210 continueSearch(s); 2210 continueSearch(s);
2211 return (query == KMessageBox::No); 2211 return (query == KMessageBox::No);
2212} 2212}
2213 2213
2214void KateView::replaceSlot() { 2214void KateView::replaceSlot() {
2215 doReplaceAction(replacePrompt->result(),true); 2215 doReplaceAction(replacePrompt->result(),true);
2216} 2216}
2217 2217
2218void KateView::installPopup(QPopupMenu *rmb_Menu) 2218void KateView::installPopup(QPopupMenu *rmb_Menu)
2219{ 2219{
2220 rmbMenu = rmb_Menu; 2220 rmbMenu = rmb_Menu;
2221} 2221}
2222 2222
2223void KateView::readConfig() 2223void KateView::readConfig()
2224{ 2224{
2225 KConfig *config = KGlobal::config(); 2225 KateConfig *config = KGlobal::config();
2226 config->setGroup("Kate View"); 2226 config->setGroup("Kate View");
2227 2227
2228 searchFlags = config->readNumEntry("SearchFlags", KateView::sfPrompt); 2228 searchFlags = config->readNumEntry("SearchFlags", KateView::sfPrompt);
2229 configFlags = config->readNumEntry("ConfigFlags", configFlags) & ~KateView::cfMark; 2229 configFlags = config->readNumEntry("ConfigFlags", configFlags) & ~KateView::cfMark;
2230 2230
2231 config->sync(); 2231// config->sync();
2232} 2232}
2233 2233
2234void KateView::writeConfig() 2234void KateView::writeConfig()
2235{ 2235{
2236 KConfig *config = KGlobal::config(); 2236 KateConfig *config = KGlobal::config();
2237 config->setGroup("Kate View"); 2237 config->setGroup("Kate View");
2238 2238
2239 config->writeEntry("SearchFlags",searchFlags); 2239 config->writeEntry("SearchFlags",searchFlags);
2240 config->writeEntry("ConfigFlags",configFlags); 2240 config->writeEntry("ConfigFlags",configFlags);
2241 2241
2242 config->sync(); 2242// config->sync();
2243} 2243}
2244 2244
2245void KateView::readSessionConfig(KConfig *config) 2245void KateView::readSessionConfig(KateConfig *config)
2246{ 2246{
2247 PointStruc cursor; 2247 PointStruc cursor;
2248 2248
2249 myViewInternal->xPos = config->readNumEntry("XPos"); 2249 myViewInternal->xPos = config->readNumEntry("XPos");
2250 myViewInternal->yPos = config->readNumEntry("YPos"); 2250 myViewInternal->yPos = config->readNumEntry("YPos");
2251 cursor.x = config->readNumEntry("CursorX"); 2251 cursor.x = config->readNumEntry("CursorX");
2252 cursor.y = config->readNumEntry("CursorY"); 2252 cursor.y = config->readNumEntry("CursorY");
2253 myViewInternal->updateCursor(cursor); 2253 myViewInternal->updateCursor(cursor);
2254 myIconBorder = config->readBoolEntry("IconBorder on"); 2254 myIconBorder = config->readBoolEntry("IconBorder on");
2255 setIconBorder(myIconBorder); 2255 setIconBorder(myIconBorder);
2256} 2256}
2257 2257
2258void KateView::writeSessionConfig(KConfig *config) 2258void KateView::writeSessionConfig(KateConfig *config)
2259{ 2259{
2260 config->writeEntry("XPos",myViewInternal->xPos); 2260 config->writeEntry("XPos",myViewInternal->xPos);
2261 config->writeEntry("YPos",myViewInternal->yPos); 2261 config->writeEntry("YPos",myViewInternal->yPos);
2262 config->writeEntry("CursorX",myViewInternal->cursor.x); 2262 config->writeEntry("CursorX",myViewInternal->cursor.x);
2263 config->writeEntry("CursorY",myViewInternal->cursor.y); 2263 config->writeEntry("CursorY",myViewInternal->cursor.y);
2264 config->writeEntry("IconBorder on", myIconBorder); 2264 config->writeEntry("IconBorder on", myIconBorder);
2265} 2265}
2266 2266
2267void KateView::configDialog() 2267void KateView::configDialog()
2268{ 2268{
2269 2269
2270#warning fixme 2270#warning fixme
2271 2271
2272#if 1 2272#if 1
2273 KDialogBase *kd = new KDialogBase(KDialogBase::IconList, 2273 KDialogBase *kd = new KDialogBase(KDialogBase::IconList,
2274 i18n("Configure Editor"), 2274 i18n("Configure Editor"),
2275 KDialogBase::Ok | KDialogBase::Cancel | 2275 KDialogBase::Ok | KDialogBase::Cancel |
2276 KDialogBase::Help , 2276 KDialogBase::Help ,
2277 KDialogBase::Ok, this, "tabdialog"); 2277 KDialogBase::Ok, this, "tabdialog");
2278 2278
2279 // color options 2279 // color options
2280 QFrame *page=kd->addPage(i18n("Colors")); 2280 QFrame *page=kd->addPage(i18n("Colors"));
2281 (new QVBoxLayout(page))->setAutoAdd(true); 2281 (new QVBoxLayout(page))->setAutoAdd(true);
2282 ColorConfig *colorConfig = new ColorConfig(page); 2282 ColorConfig *colorConfig = new ColorConfig(page);
2283 QColor* colors = getColors(); 2283 QColor* colors = getColors();
2284 colorConfig->setColors(colors); 2284 colorConfig->setColors(colors);
2285 2285
2286 page = kd->addPage(i18n("Fonts")); 2286 page = kd->addPage(i18n("Fonts"));
2287 (new QVBoxLayout(page))->setAutoAdd(true); 2287 (new QVBoxLayout(page))->setAutoAdd(true);
2288 2288
2289 FontConfig *fontConfig = new FontConfig(page); 2289 FontConfig *fontConfig = new FontConfig(page);
2290 fontConfig->setFont (myDoc->getFont()); 2290 fontConfig->setFont (myDoc->getFont());
2291 2291
2292 // indent options 2292 // indent options
2293 page=kd->addPage(i18n("Indent")); 2293 page=kd->addPage(i18n("Indent"));
2294 (new QVBoxLayout(page))->setAutoAdd(true); 2294 (new QVBoxLayout(page))->setAutoAdd(true);
2295 2295
2296 IndentConfigTab *indentConfig = new IndentConfigTab(page, this); 2296 IndentConfigTab *indentConfig = new IndentConfigTab(page, this);
2297 2297
2298 // select options 2298 // select options
2299 page=kd->addPage(i18n("Select")); 2299 page=kd->addPage(i18n("Select"));
2300 (new QVBoxLayout(page))->setAutoAdd(true); 2300 (new QVBoxLayout(page))->setAutoAdd(true);
2301 2301
2302 SelectConfigTab *selectConfig = new SelectConfigTab(page, this); 2302 SelectConfigTab *selectConfig = new SelectConfigTab(page, this);
2303 2303
2304 // edit options 2304 // edit options
2305 page=kd->addPage(i18n("Edit")); 2305 page=kd->addPage(i18n("Edit"));
2306 (new QVBoxLayout(page))->setAutoAdd(true); 2306 (new QVBoxLayout(page))->setAutoAdd(true);
2307 2307
2308 EditConfigTab *editConfig = new EditConfigTab(page, this); 2308 EditConfigTab *editConfig = new EditConfigTab(page, this);
2309 2309
2310 2310
2311 2311
2312 HighlightDialogPage *hlPage; 2312 HighlightDialogPage *hlPage;
2313 HlManager *hlManager; 2313 HlManager *hlManager;
2314 HlDataList hlDataList; 2314 HlDataList hlDataList;
2315 ItemStyleList defaultStyleList; 2315 ItemStyleList defaultStyleList;
2316 2316
2317 hlManager = HlManager::self(); 2317 hlManager = HlManager::self();
2318 2318
2319 defaultStyleList.setAutoDelete(true); 2319 defaultStyleList.setAutoDelete(true);
2320 hlManager->getDefaults(defaultStyleList); 2320 hlManager->getDefaults(defaultStyleList);
2321 2321
2322 hlDataList.setAutoDelete(true); 2322 hlDataList.setAutoDelete(true);
2323 //this gets the data from the KConfig object 2323 //this gets the data from the KateConfig object
2324 hlManager->getHlDataList(hlDataList); 2324 hlManager->getHlDataList(hlDataList);
2325 2325
2326 page=kd->addPage(i18n("Highlighting")); 2326 page=kd->addPage(i18n("Highlighting"));
2327 (new QVBoxLayout(page))->setAutoAdd(true); 2327 (new QVBoxLayout(page))->setAutoAdd(true);
2328 2328
2329 hlPage = new HighlightDialogPage(hlManager, &defaultStyleList, &hlDataList, 0, page); 2329 hlPage = new HighlightDialogPage(hlManager, &defaultStyleList, &hlDataList, 0, page);
2330 kd->showMaximized(); 2330 kd->showMaximized();
2331 if (kd->exec()) { 2331 if (kd->exec()) {
2332 // color options 2332 // color options
2333 colorConfig->getColors(colors); 2333 colorConfig->getColors(colors);
2334 myDoc->setFont (fontConfig->getFont()); 2334 myDoc->setFont (fontConfig->getFont());
2335 2335
2336 applyColors(); 2336 applyColors();
2337 // indent options 2337 // indent options
2338 indentConfig->getData(this); 2338 indentConfig->getData(this);
2339 // select options 2339 // select options
2340 selectConfig->getData(this); 2340 selectConfig->getData(this);
2341 // edit options 2341 // edit options
2342 editConfig->getData(this); 2342 editConfig->getData(this);
2343 // spell checker 2343 // spell checker
2344 hlManager->setHlDataList(hlDataList); 2344 hlManager->setHlDataList(hlDataList);
2345 hlManager->setDefaults(defaultStyleList); 2345 hlManager->setDefaults(defaultStyleList);
2346 hlPage->saveData(); 2346 hlPage->saveData();
2347 } 2347 }
2348 2348
2349// delete kd; 2349// delete kd;
2350 2350
2351#endif 2351#endif
2352} 2352}
2353 2353
2354int KateView::getHl() { 2354int KateView::getHl() {
2355 return myDoc->highlightNum(); 2355 return myDoc->highlightNum();
2356} 2356}
2357 2357
2358void KateView::setDontChangeHlOnSave() 2358void KateView::setDontChangeHlOnSave()
2359{ 2359{
2360 myDoc->setDontChangeHlOnSave(); 2360 myDoc->setDontChangeHlOnSave();
2361} 2361}
2362 2362
2363void KateView::setHl(int n) { 2363void KateView::setHl(int n) {
2364 myDoc->setHighlight(n); 2364 myDoc->setHighlight(n);
2365 myDoc->setDontChangeHlOnSave(); 2365 myDoc->setDontChangeHlOnSave();
2366 myDoc->updateViews(); 2366 myDoc->updateViews();
2367} 2367}
2368 2368
2369int KateView::getEol() { 2369int KateView::getEol() {
2370 return myDoc->eolMode; 2370 return myDoc->eolMode;
2371} 2371}
2372 2372
2373void KateView::setEol(int eol) { 2373void KateView::setEol(int eol) {
2374 if (isReadOnly()) 2374 if (isReadOnly())
2375 return; 2375 return;
2376 2376
2377 myDoc->eolMode = eol; 2377 myDoc->eolMode = eol;
2378 myDoc->setModified(true); 2378 myDoc->setModified(true);
2379} 2379}
2380 2380
2381 2381
2382 2382
2383void KateView::paintEvent(QPaintEvent *e) { 2383void KateView::paintEvent(QPaintEvent *e) {
2384 int x, y; 2384 int x, y;
2385 2385
2386 QRect updateR = e->rect(); // update rectangle 2386 QRect updateR = e->rect(); // update rectangle
2387// debug("Update rect = ( %i, %i, %i, %i )", 2387// debug("Update rect = ( %i, %i, %i, %i )",
2388// updateR.x(),updateR.y(), updateR.width(), updateR.height() ); 2388// updateR.x(),updateR.y(), updateR.width(), updateR.height() );
2389 2389
2390 int ux1 = updateR.x(); 2390 int ux1 = updateR.x();
2391 int uy1 = updateR.y(); 2391 int uy1 = updateR.y();
2392 int ux2 = ux1 + updateR.width(); 2392 int ux2 = ux1 + updateR.width();
2393 int uy2 = uy1 + updateR.height(); 2393 int uy2 = uy1 + updateR.height();
2394 2394
2395 QPainter paint; 2395 QPainter paint;
2396 paint.begin(this); 2396 paint.begin(this);
2397 2397
2398 QColorGroup g = colorGroup(); 2398 QColorGroup g = colorGroup();
2399 x = width(); 2399 x = width();
2400 y = height(); 2400 y = height();
2401 2401
2402 paint.setPen(g.dark()); 2402 paint.setPen(g.dark());
2403 if (uy1 <= 0) paint.drawLine(0,0,x-2,0); 2403 if (uy1 <= 0) paint.drawLine(0,0,x-2,0);
2404 if (ux1 <= 0) paint.drawLine(0,1,0,y-2); 2404 if (ux1 <= 0) paint.drawLine(0,1,0,y-2);
2405 2405
2406 paint.setPen(black); 2406 paint.setPen(black);
2407 if (uy1 <= 1) paint.drawLine(1,1,x-3,1); 2407 if (uy1 <= 1) paint.drawLine(1,1,x-3,1);
2408 if (ux1 <= 1) paint.drawLine(1,2,1,y-3); 2408 if (ux1 <= 1) paint.drawLine(1,2,1,y-3);
2409 2409
2410 paint.setPen(g.midlight()); 2410 paint.setPen(g.midlight());
2411 if (uy2 >= y-1) paint.drawLine(1,y-2,x-3,y-2); 2411 if (uy2 >= y-1) paint.drawLine(1,y-2,x-3,y-2);
2412 if (ux2 >= x-1) paint.drawLine(x-2,1,x-2,y-2); 2412 if (ux2 >= x-1) paint.drawLine(x-2,1,x-2,y-2);
2413 2413
2414 paint.setPen(g.light()); 2414 paint.setPen(g.light());
2415 if (uy2 >= y) paint.drawLine(0,y-1,x-2,y-1); 2415 if (uy2 >= y) paint.drawLine(0,y-1,x-2,y-1);
2416 if (ux2 >= x) paint.drawLine(x-1,0,x-1,y-1); 2416 if (ux2 >= x) paint.drawLine(x-1,0,x-1,y-1);
2417 2417
2418 x -= 2 + 16; 2418 x -= 2 + 16;
2419 y -= 2 + 16; 2419 y -= 2 + 16;
2420 if (ux2 > x && uy2 > y) { 2420 if (ux2 > x && uy2 > y) {
2421 paint.fillRect(x,y,16,16,g.background()); 2421 paint.fillRect(x,y,16,16,g.background());
2422 } 2422 }
2423 paint.end(); 2423 paint.end();
2424} 2424}
2425 2425
2426void KateView::resizeEvent(QResizeEvent *) { 2426void KateView::resizeEvent(QResizeEvent *) {
2427 2427
2428// debug("Resize %d, %d",e->size().width(),e->size().height()); 2428// debug("Resize %d, %d",e->size().width(),e->size().height());
2429 2429
2430//myViewInternal->resize(width() -20, height() -20); 2430//myViewInternal->resize(width() -20, height() -20);
2431 myViewInternal->tagAll(); 2431 myViewInternal->tagAll();
2432 myViewInternal->updateView(0/*ufNoScroll*/); 2432 myViewInternal->updateView(0/*ufNoScroll*/);
2433} 2433}
2434 2434
2435 2435
2436// Applies a new pattern to the search context. 2436// Applies a new pattern to the search context.
2437void SConfig::setPattern(QString &newPattern) { 2437void SConfig::setPattern(QString &newPattern) {
2438 bool regExp = (flags & KateView::sfRegularExpression); 2438 bool regExp = (flags & KateView::sfRegularExpression);
2439 2439
2440 m_pattern = newPattern; 2440 m_pattern = newPattern;
2441 if (regExp) { 2441 if (regExp) {
2442 m_regExp.setCaseSensitive(flags & KateView::sfCaseSensitive); 2442 m_regExp.setCaseSensitive(flags & KateView::sfCaseSensitive);
2443 m_regExp.setPattern(m_pattern); 2443 m_regExp.setPattern(m_pattern);
2444 } 2444 }
2445} 2445}
2446 2446
2447// Applies the search context to the given string, and returns whether a match was found. If one is, 2447// Applies the search context to the given string, and returns whether a match was found. If one is,
2448// the length of the string matched is also returned. 2448// the length of the string matched is also returned.
2449int SConfig::search(QString &text, int index) { 2449int SConfig::search(QString &text, int index) {
2450 bool regExp = (flags & KateView::sfRegularExpression); 2450 bool regExp = (flags & KateView::sfRegularExpression);
2451 bool caseSensitive = (flags & KateView::sfCaseSensitive); 2451 bool caseSensitive = (flags & KateView::sfCaseSensitive);
diff --git a/noncore/apps/tinykate/libkate/view/kateview.h b/noncore/apps/tinykate/libkate/view/kateview.h
index 2e78a3a..858e8a1 100644
--- a/noncore/apps/tinykate/libkate/view/kateview.h
+++ b/noncore/apps/tinykate/libkate/view/kateview.h
@@ -1,179 +1,180 @@
1/*************************************************************************** 1/***************************************************************************
2 kateview.h - description 2 kateview.h - description
3 ------------------- 3 -------------------
4 begin : Mon Jan 15 2001 4 begin : Mon Jan 15 2001
5 copyright : (C) 2001 by Christoph "Crossfire" Cullmann 5 copyright : (C) 2001 by Christoph "Crossfire" Cullmann
6 (C) 2002 by Joseph Wenninger 6 (C) 2002 by Joseph Wenninger
7 email : crossfire@babylon2k.de 7 email : crossfire@babylon2k.de
8 jowenn@kde.org 8 jowenn@kde.org
9 ***************************************************************************/ 9 ***************************************************************************/
10 10
11/*************************************************************************** 11/***************************************************************************
12 * * 12 * *
13 * This program is free software; you can redistribute it and/or modify * 13 * This program is free software; you can redistribute it and/or modify *
14 * it under the terms of the GNU General Public License as published by * 14 * it under the terms of the GNU General Public License as published by *
15 * the Free Software Foundation; either version 2 of the License, or * 15 * the Free Software Foundation; either version 2 of the License, or *
16 * (at your option) any later version. * 16 * (at your option) any later version. *
17 * * 17 * *
18 ***************************************************************************/ 18 ***************************************************************************/
19 19
20/* 20/*
21 Copyright (C) 1998, 1999 Jochen Wilhelmy 21 Copyright (C) 1998, 1999 Jochen Wilhelmy
22 digisnap@cs.tu-berlin.de 22 digisnap@cs.tu-berlin.de
23 23
24 This library is free software; you can redistribute it and/or 24 This library is free software; you can redistribute it and/or
25 modify it under the terms of the GNU Library General Public 25 modify it under the terms of the GNU Library General Public
26 License as published by the Free Software Foundation; either 26 License as published by the Free Software Foundation; either
27 version 2 of the License, or (at your option) any later version. 27 version 2 of the License, or (at your option) any later version.
28 28
29 This library is distributed in the hope that it will be useful, 29 This library is distributed in the hope that it will be useful,
30 but WITHOUT ANY WARRANTY; without even the implied warranty of 30 but WITHOUT ANY WARRANTY; without even the implied warranty of
31 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 31 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
32 Library General Public License for more details. 32 Library General Public License for more details.
33 33
34 You should have received a copy of the GNU Library General Public License 34 You should have received a copy of the GNU Library General Public License
35 along with this library; see the file COPYING.LIB. If not, write to 35 along with this library; see the file COPYING.LIB. If not, write to
36 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 36 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
37 Boston, MA 02111-1307, USA. 37 Boston, MA 02111-1307, USA.
38*/ 38*/
39 39
40#ifndef kate_view_h 40#ifndef kate_view_h
41#define kate_view_h 41#define kate_view_h
42 42
43#include "../interfaces/view.h" 43#include "../interfaces/view.h"
44#include "../interfaces/document.h" 44#include "../interfaces/document.h"
45 45
46#include <qlist.h> 46#include <qlist.h>
47#include <qstring.h> 47#include <qstring.h>
48#include <qdialog.h> 48#include <qdialog.h>
49 49
50 50
51class KateDocument; 51class KateDocument;
52class KateConfig;
52class Highlight; 53class Highlight;
53 54
54/* 55/*
55//dialog results 56//dialog results
56const int srYes = QDialog::Accepted; 57const int srYes = QDialog::Accepted;
57const int srNo = 10; 58const int srNo = 10;
58const int srAll = 11; 59const int srAll = 11;
59const int srCancel = QDialog::Rejected; 60const int srCancel = QDialog::Rejected;
60*/ 61*/
61// --- config flags --- 62// --- config flags ---
62// indent 63// indent
63 64
64enum Select_flags { 65enum Select_flags {
65 selectFlag = 0x100000, 66 selectFlag = 0x100000,
66 multiSelectFlag = 0x200000 67 multiSelectFlag = 0x200000
67}; 68};
68//state commands 69//state commands
69enum State_commands { 70enum State_commands {
70 cmToggleInsert = 1, 71 cmToggleInsert = 1,
71 cmToggleVertical = 2 72 cmToggleVertical = 2
72}; 73};
73 74
74class KateViewInternal; 75class KateViewInternal;
75class KateView; 76class KateView;
76 77
77struct PointStruc { 78struct PointStruc {
78 int x; 79 int x;
79 int y; 80 int y;
80}; 81};
81 82
82struct VConfig { 83struct VConfig {
83 KateView *view; 84 KateView *view;
84 PointStruc cursor; 85 PointStruc cursor;
85 int cXPos; 86 int cXPos;
86 int flags; 87 int flags;
87}; 88};
88 89
89struct SConfig { 90struct SConfig {
90 PointStruc cursor; 91 PointStruc cursor;
91 PointStruc startCursor; 92 PointStruc startCursor;
92 int flags; 93 int flags;
93 94
94 // Set the pattern to be used for searching. 95 // Set the pattern to be used for searching.
95 void setPattern(QString &newPattern); 96 void setPattern(QString &newPattern);
96 97
97 // Search the given string. 98 // Search the given string.
98 int search(QString &text, int index); 99 int search(QString &text, int index);
99 100
100 // The length of the last match found using pattern or regExp. 101 // The length of the last match found using pattern or regExp.
101 int matchedLength; 102 int matchedLength;
102 103
103private: 104private:
104 QString m_pattern; 105 QString m_pattern;
105 106
106 // The regular expression corresponding to pattern. Only guaranteed valid if 107 // The regular expression corresponding to pattern. Only guaranteed valid if
107 // flags has sfRegularExpression set. 108 // flags has sfRegularExpression set.
108 QRegExp m_regExp; 109 QRegExp m_regExp;
109}; 110};
110 111
111struct LineRange { 112struct LineRange {
112 int start; 113 int start;
113 int end; 114 int end;
114}; 115};
115 116
116struct BracketMark { 117struct BracketMark {
117 PointStruc cursor; 118 PointStruc cursor;
118 int sXPos; 119 int sXPos;
119 int eXPos; 120 int eXPos;
120}; 121};
121 122
122 123
123class KateIconBorder : public QWidget 124class KateIconBorder : public QWidget
124{ 125{
125public: 126public:
126 KateIconBorder(KateView *view, class KateViewInternal *internalView); 127 KateIconBorder(KateView *view, class KateViewInternal *internalView);
127 ~KateIconBorder(); 128 ~KateIconBorder();
128 129
129 void paintLine(int i); 130 void paintLine(int i);
130 131
131protected: 132protected:
132 void paintEvent(QPaintEvent* e); 133 void paintEvent(QPaintEvent* e);
133 void mousePressEvent(QMouseEvent* e); 134 void mousePressEvent(QMouseEvent* e);
134 135
135private: 136private:
136 137
137 KateView *myView; 138 KateView *myView;
138 class KateViewInternal *myInternalView; 139 class KateViewInternal *myInternalView;
139 bool lmbSetsBreakpoints; 140 bool lmbSetsBreakpoints;
140}; 141};
141 142
142class KateViewInternal : public QWidget { 143class KateViewInternal : public QWidget {
143 Q_OBJECT 144 Q_OBJECT
144 friend class KateDocument; 145 friend class KateDocument;
145 friend class KateView; 146 friend class KateView;
146 friend class KateIconBorder; 147 friend class KateIconBorder;
147 148
148 private: 149 private:
149 long waitForPreHighlight; 150 long waitForPreHighlight;
150 int iconBorderWidth; 151 int iconBorderWidth;
151 int iconBorderHeight; 152 int iconBorderHeight;
152 153
153 protected slots: 154 protected slots:
154 void slotPreHighlightUpdate(long line); 155 void slotPreHighlightUpdate(long line);
155 156
156 public: 157 public:
157 KateViewInternal(KateView *view, KateDocument *doc); 158 KateViewInternal(KateView *view, KateDocument *doc);
158 ~KateViewInternal(); 159 ~KateViewInternal();
159 160
160 virtual void doCursorCommand(VConfig &, int cmdNum); 161 virtual void doCursorCommand(VConfig &, int cmdNum);
161 virtual void doEditCommand(VConfig &, int cmdNum); 162 virtual void doEditCommand(VConfig &, int cmdNum);
162 163
163 void cursorLeft(VConfig &); 164 void cursorLeft(VConfig &);
164 void cursorRight(VConfig &); 165 void cursorRight(VConfig &);
165 void wordLeft(VConfig &); 166 void wordLeft(VConfig &);
166 void wordRight(VConfig &); 167 void wordRight(VConfig &);
167 void home(VConfig &); 168 void home(VConfig &);
168 void end(VConfig &); 169 void end(VConfig &);
169 void cursorUp(VConfig &); 170 void cursorUp(VConfig &);
170 void cursorDown(VConfig &); 171 void cursorDown(VConfig &);
171 void scrollUp(VConfig &); 172 void scrollUp(VConfig &);
172 void scrollDown(VConfig &); 173 void scrollDown(VConfig &);
173 void topOfView(VConfig &); 174 void topOfView(VConfig &);
174 void bottomOfView(VConfig &); 175 void bottomOfView(VConfig &);
175 void pageUp(VConfig &); 176 void pageUp(VConfig &);
176 void pageDown(VConfig &); 177 void pageDown(VConfig &);
177 void cursorPageUp(VConfig &); 178 void cursorPageUp(VConfig &);
178 void cursorPageDown(VConfig &); 179 void cursorPageDown(VConfig &);
179 void top(VConfig &); 180 void top(VConfig &);
@@ -536,264 +537,264 @@ class KateView : public Kate::View
536 void undoHistory(); 537 void undoHistory();
537 /** 538 /**
538 Moves the current line or the selection one position to the right 539 Moves the current line or the selection one position to the right
539 */ 540 */
540 void indent() {doEditCommand(KateView::cmIndent);}; 541 void indent() {doEditCommand(KateView::cmIndent);};
541 /** 542 /**
542 Moves the current line or the selection one position to the left 543 Moves the current line or the selection one position to the left
543 */ 544 */
544 void unIndent() {doEditCommand(KateView::cmUnindent);}; 545 void unIndent() {doEditCommand(KateView::cmUnindent);};
545 /** 546 /**
546 Optimizes the selected indentation, replacing tabs and spaces as needed 547 Optimizes the selected indentation, replacing tabs and spaces as needed
547 */ 548 */
548 void cleanIndent() {doEditCommand(KateView::cmCleanIndent);}; 549 void cleanIndent() {doEditCommand(KateView::cmCleanIndent);};
549 /** 550 /**
550 Selects all text 551 Selects all text
551 */ 552 */
552 void selectAll() {doEditCommand(KateView::cmSelectAll);} 553 void selectAll() {doEditCommand(KateView::cmSelectAll);}
553 /** 554 /**
554 Deselects all text 555 Deselects all text
555 */ 556 */
556 void deselectAll() {doEditCommand(KateView::cmDeselectAll);} 557 void deselectAll() {doEditCommand(KateView::cmDeselectAll);}
557 /** 558 /**
558 Inverts the current selection 559 Inverts the current selection
559 */ 560 */
560 void invertSelection() {doEditCommand(KateView::cmInvertSelection);} 561 void invertSelection() {doEditCommand(KateView::cmInvertSelection);}
561 /** 562 /**
562 comments out current line 563 comments out current line
563 */ 564 */
564 void comment() {doEditCommand(KateView::cmComment);}; 565 void comment() {doEditCommand(KateView::cmComment);};
565 /** 566 /**
566 removes comment signs in the current line 567 removes comment signs in the current line
567 */ 568 */
568 void uncomment() {doEditCommand(KateView::cmUncomment);}; 569 void uncomment() {doEditCommand(KateView::cmUncomment);};
569 570
570 void keyReturn() {doEditCommand(KateView::cmReturn);}; 571 void keyReturn() {doEditCommand(KateView::cmReturn);};
571 void keyDelete() {doEditCommand(KateView::cmDelete);}; 572 void keyDelete() {doEditCommand(KateView::cmDelete);};
572 void backspace() {doEditCommand(KateView::cmBackspace);}; 573 void backspace() {doEditCommand(KateView::cmBackspace);};
573 void killLine() {doEditCommand(KateView::cmKillLine);}; 574 void killLine() {doEditCommand(KateView::cmKillLine);};
574 575
575// cursor commands... 576// cursor commands...
576 577
577 void cursorLeft() {doCursorCommand(KateView::cmLeft);}; 578 void cursorLeft() {doCursorCommand(KateView::cmLeft);};
578 void shiftCursorLeft() {doCursorCommand(KateView::cmLeft | selectFlag);}; 579 void shiftCursorLeft() {doCursorCommand(KateView::cmLeft | selectFlag);};
579 void cursorRight() {doCursorCommand(KateView::cmRight);} 580 void cursorRight() {doCursorCommand(KateView::cmRight);}
580 void shiftCursorRight() {doCursorCommand(KateView::cmRight | selectFlag);} 581 void shiftCursorRight() {doCursorCommand(KateView::cmRight | selectFlag);}
581 void wordLeft() {doCursorCommand(KateView::cmWordLeft);}; 582 void wordLeft() {doCursorCommand(KateView::cmWordLeft);};
582 void shiftWordLeft() {doCursorCommand(KateView::cmWordLeft | selectFlag);}; 583 void shiftWordLeft() {doCursorCommand(KateView::cmWordLeft | selectFlag);};
583 void wordRight() {doCursorCommand(KateView::cmWordRight);}; 584 void wordRight() {doCursorCommand(KateView::cmWordRight);};
584 void shiftWordRight() {doCursorCommand(KateView::cmWordRight | selectFlag);}; 585 void shiftWordRight() {doCursorCommand(KateView::cmWordRight | selectFlag);};
585 void home() {doCursorCommand(KateView::cmHome);}; 586 void home() {doCursorCommand(KateView::cmHome);};
586 void shiftHome() {doCursorCommand(KateView::cmHome | selectFlag);}; 587 void shiftHome() {doCursorCommand(KateView::cmHome | selectFlag);};
587 void end() {doCursorCommand(KateView::cmEnd);}; 588 void end() {doCursorCommand(KateView::cmEnd);};
588 void shiftEnd() {doCursorCommand(KateView::cmEnd | selectFlag);}; 589 void shiftEnd() {doCursorCommand(KateView::cmEnd | selectFlag);};
589 void up() {doCursorCommand(KateView::cmUp);}; 590 void up() {doCursorCommand(KateView::cmUp);};
590 void shiftUp() {doCursorCommand(KateView::cmUp | selectFlag);}; 591 void shiftUp() {doCursorCommand(KateView::cmUp | selectFlag);};
591 void down() {doCursorCommand(KateView::cmDown);}; 592 void down() {doCursorCommand(KateView::cmDown);};
592 void shiftDown() {doCursorCommand(KateView::cmDown | selectFlag);}; 593 void shiftDown() {doCursorCommand(KateView::cmDown | selectFlag);};
593 void scrollUp() {doCursorCommand(KateView::cmScrollUp);}; 594 void scrollUp() {doCursorCommand(KateView::cmScrollUp);};
594 void scrollDown() {doCursorCommand(KateView::cmScrollDown);}; 595 void scrollDown() {doCursorCommand(KateView::cmScrollDown);};
595 void topOfView() {doCursorCommand(KateView::cmTopOfView);}; 596 void topOfView() {doCursorCommand(KateView::cmTopOfView);};
596 void bottomOfView() {doCursorCommand(KateView::cmBottomOfView);}; 597 void bottomOfView() {doCursorCommand(KateView::cmBottomOfView);};
597 void pageUp() {doCursorCommand(KateView::cmPageUp);}; 598 void pageUp() {doCursorCommand(KateView::cmPageUp);};
598 void shiftPageUp() {doCursorCommand(KateView::cmPageUp | selectFlag);}; 599 void shiftPageUp() {doCursorCommand(KateView::cmPageUp | selectFlag);};
599 void pageDown() {doCursorCommand(KateView::cmPageDown);}; 600 void pageDown() {doCursorCommand(KateView::cmPageDown);};
600 void shiftPageDown() {doCursorCommand(KateView::cmPageDown | selectFlag);}; 601 void shiftPageDown() {doCursorCommand(KateView::cmPageDown | selectFlag);};
601 void top() {doCursorCommand(KateView::cmTop);}; 602 void top() {doCursorCommand(KateView::cmTop);};
602 void shiftTop() {doCursorCommand(KateView::cmTop | selectFlag);}; 603 void shiftTop() {doCursorCommand(KateView::cmTop | selectFlag);};
603 void bottom() {doCursorCommand(KateView::cmBottom);}; 604 void bottom() {doCursorCommand(KateView::cmBottom);};
604 void shiftBottom() {doCursorCommand(KateView::cmBottom | selectFlag);}; 605 void shiftBottom() {doCursorCommand(KateView::cmBottom | selectFlag);};
605 606
606//search/replace functions 607//search/replace functions
607 public slots: 608 public slots:
608 /** 609 /**
609 Presents a search dialog to the user 610 Presents a search dialog to the user
610 */ 611 */
611 void find(); 612 void find();
612 /** 613 /**
613 Presents a replace dialog to the user 614 Presents a replace dialog to the user
614 */ 615 */
615 void replace(); 616 void replace();
616 617
617 /** 618 /**
618 Presents a "Goto Line" dialog to the user 619 Presents a "Goto Line" dialog to the user
619 */ 620 */
620 void gotoLine(); 621 void gotoLine();
621 protected: 622 protected:
622 void initSearch(SConfig &, int flags); 623 void initSearch(SConfig &, int flags);
623 void continueSearch(SConfig &); 624 void continueSearch(SConfig &);
624 void findAgain(SConfig &); 625 void findAgain(SConfig &);
625 void replaceAgain(); 626 void replaceAgain();
626 void doReplaceAction(int result, bool found = false); 627 void doReplaceAction(int result, bool found = false);
627 void exposeFound(PointStruc &cursor, int slen, int flags, bool replace); 628 void exposeFound(PointStruc &cursor, int slen, int flags, bool replace);
628 void deleteReplacePrompt(); 629 void deleteReplacePrompt();
629 bool askReplaceEnd(); 630 bool askReplaceEnd();
630 protected slots: 631 protected slots:
631 void replaceSlot(); 632 void replaceSlot();
632 protected: 633 protected:
633 int searchFlags; 634 int searchFlags;
634 int replaces; 635 int replaces;
635 SConfig s; 636 SConfig s;
636 QDialog *replacePrompt; 637 QDialog *replacePrompt;
637 638
638//right mouse button popup menu & bookmark menu 639//right mouse button popup menu & bookmark menu
639 public: 640 public:
640 /** 641 /**
641 Install a Popup Menu. The Popup Menu will be activated on 642 Install a Popup Menu. The Popup Menu will be activated on
642 a right mouse button press event. 643 a right mouse button press event.
643 */ 644 */
644 void installPopup(QPopupMenu *rmb_Menu); 645 void installPopup(QPopupMenu *rmb_Menu);
645 646
646 protected: 647 protected:
647 QPopupMenu *rmbMenu; 648 QPopupMenu *rmbMenu;
648 649
649 signals: 650 signals:
650 void bookAddChanged(bool enabled); 651 void bookAddChanged(bool enabled);
651 void bookClearChanged(bool enabled); 652 void bookClearChanged(bool enabled);
652 653
653//config file / session management functions 654//config file / session management functions
654 public: 655 public:
655 /** 656 /**
656 Reads config entries 657 Reads config entries
657 */ 658 */
658 void readConfig(); 659 void readConfig();
659 /** 660 /**
660 Writes config entries i 661 Writes config entries i
661 */ 662 */
662 void writeConfig(); 663 void writeConfig();
663 /** 664 /**
664 Reads session config out of the KConfig object. This also includes 665 Reads session config out of the KateConfig object. This also includes
665 the actual cursor position and the bookmarks. 666 the actual cursor position and the bookmarks.
666 */ 667 */
667 void readSessionConfig(KConfig *); 668 void readSessionConfig(KateConfig *);
668 /** 669 /**
669 Writes session config into the KConfig object 670 Writes session config into the KateConfig object
670 */ 671 */
671 void writeSessionConfig(KConfig *); 672 void writeSessionConfig(KateConfig *);
672 673
673 674
674 public: 675 public:
675 void setDontChangeHlOnSave(); 676 void setDontChangeHlOnSave();
676 677
677 678
678 // syntax highlight 679 // syntax highlight
679 public slots: 680 public slots:
680 /** 681 /**
681 Presents the setup dialog to the user 682 Presents the setup dialog to the user
682 */ 683 */
683 void configDialog (); 684 void configDialog ();
684 /** 685 /**
685 Gets the highlight number 686 Gets the highlight number
686 */ 687 */
687 int getHl(); 688 int getHl();
688 /** 689 /**
689 Sets the highlight number n 690 Sets the highlight number n
690 */ 691 */
691 void setHl(int n); 692 void setHl(int n);
692 /** 693 /**
693 Get the end of line mode (Unix, Macintosh or Dos) 694 Get the end of line mode (Unix, Macintosh or Dos)
694 */ 695 */
695 int getEol(); 696 int getEol();
696 /** 697 /**
697 Set the end of line mode (Unix, Macintosh or Dos) 698 Set the end of line mode (Unix, Macintosh or Dos)
698 */ 699 */
699 void setEol(int); 700 void setEol(int);
700 701
701//internal 702//internal
702 protected: 703 protected:
703 virtual void paintEvent(QPaintEvent *); 704 virtual void paintEvent(QPaintEvent *);
704 virtual void resizeEvent(QResizeEvent *); 705 virtual void resizeEvent(QResizeEvent *);
705 706
706 void doCursorCommand(int cmdNum); 707 void doCursorCommand(int cmdNum);
707 void doEditCommand(int cmdNum); 708 void doEditCommand(int cmdNum);
708 709
709 KateViewInternal *myViewInternal; 710 KateViewInternal *myViewInternal;
710 KateDocument *myDoc; 711 KateDocument *myDoc;
711 712
712 713
713 // some kwriteview stuff 714 // some kwriteview stuff
714 protected: 715 protected:
715 void insLine(int line) { myViewInternal->insLine(line); }; 716 void insLine(int line) { myViewInternal->insLine(line); };
716 void delLine(int line) { myViewInternal->delLine(line); }; 717 void delLine(int line) { myViewInternal->delLine(line); };
717 void updateCursor() { myViewInternal->updateCursor(); }; 718 void updateCursor() { myViewInternal->updateCursor(); };
718 void updateCursor(PointStruc &newCursor) { myViewInternal->updateCursor(newCursor); }; 719 void updateCursor(PointStruc &newCursor) { myViewInternal->updateCursor(newCursor); };
719 void updateCursor(PointStruc &newCursor, int flags) { myViewInternal->updateCursor(newCursor, flags); }; 720 void updateCursor(PointStruc &newCursor, int flags) { myViewInternal->updateCursor(newCursor, flags); };
720 721
721 void clearDirtyCache(int height) { myViewInternal->clearDirtyCache(height); }; 722 void clearDirtyCache(int height) { myViewInternal->clearDirtyCache(height); };
722 void tagLines(int start, int end, int x1, int x2) { myViewInternal->tagLines(start, end, x1, x2); }; 723 void tagLines(int start, int end, int x1, int x2) { myViewInternal->tagLines(start, end, x1, x2); };
723 void tagAll() { myViewInternal->tagAll(); }; 724 void tagAll() { myViewInternal->tagAll(); };
724 void setPos(int x, int y) { myViewInternal->setPos(x, y); }; 725 void setPos(int x, int y) { myViewInternal->setPos(x, y); };
725 void center() { myViewInternal->center(); }; 726 void center() { myViewInternal->center(); };
726 727
727 void updateView(int flags) { myViewInternal->updateView(flags); }; 728 void updateView(int flags) { myViewInternal->updateView(flags); };
728 729
729 730
730 731
731 public: 732 public:
732 enum Config_flags { 733 enum Config_flags {
733 cfAutoIndent= 0x1, 734 cfAutoIndent= 0x1,
734 cfBackspaceIndents= 0x2, 735 cfBackspaceIndents= 0x2,
735 cfWordWrap= 0x4, 736 cfWordWrap= 0x4,
736 cfReplaceTabs= 0x8, 737 cfReplaceTabs= 0x8,
737 cfRemoveSpaces = 0x10, 738 cfRemoveSpaces = 0x10,
738 cfWrapCursor= 0x20, 739 cfWrapCursor= 0x20,
739 cfAutoBrackets= 0x40, 740 cfAutoBrackets= 0x40,
740 cfPersistent= 0x80, 741 cfPersistent= 0x80,
741 cfKeepSelection= 0x100, 742 cfKeepSelection= 0x100,
742 cfVerticalSelect= 0x200, 743 cfVerticalSelect= 0x200,
743 cfDelOnInput= 0x400, 744 cfDelOnInput= 0x400,
744 cfXorSelect= 0x800, 745 cfXorSelect= 0x800,
745 cfOvr= 0x1000, 746 cfOvr= 0x1000,
746 cfMark= 0x2000, 747 cfMark= 0x2000,
747 cfGroupUndo= 0x4000, 748 cfGroupUndo= 0x4000,
748 cfKeepIndentProfile= 0x8000, 749 cfKeepIndentProfile= 0x8000,
749 cfKeepExtraSpaces= 0x10000, 750 cfKeepExtraSpaces= 0x10000,
750 cfMouseAutoCopy= 0x20000, 751 cfMouseAutoCopy= 0x20000,
751 cfSingleSelection= 0x40000, 752 cfSingleSelection= 0x40000,
752 cfTabIndents= 0x80000, 753 cfTabIndents= 0x80000,
753 cfPageUDMovesCursor= 0x100000, 754 cfPageUDMovesCursor= 0x100000,
754 cfShowTabs= 0x200000, 755 cfShowTabs= 0x200000,
755 cfSpaceIndent= 0x400000, 756 cfSpaceIndent= 0x400000,
756 cfSmartHome = 0x800000}; 757 cfSmartHome = 0x800000};
757 758
758 enum Dialog_results { 759 enum Dialog_results {
759 srYes=QDialog::Accepted, 760 srYes=QDialog::Accepted,
760 srNo=10, 761 srNo=10,
761 srAll, 762 srAll,
762 srCancel=QDialog::Rejected}; 763 srCancel=QDialog::Rejected};
763 764
764//search flags 765//search flags
765 enum Search_flags { 766 enum Search_flags {
766 sfCaseSensitive=1, 767 sfCaseSensitive=1,
767 sfWholeWords=2, 768 sfWholeWords=2,
768 sfFromBeginning=4, 769 sfFromBeginning=4,
769 sfBackward=8, 770 sfBackward=8,
770 sfSelected=16, 771 sfSelected=16,
771 sfPrompt=32, 772 sfPrompt=32,
772 sfReplace=64, 773 sfReplace=64,
773 sfAgain=128, 774 sfAgain=128,
774 sfWrapped=256, 775 sfWrapped=256,
775 sfFinished=512, 776 sfFinished=512,
776 sfRegularExpression=1024}; 777 sfRegularExpression=1024};
777 778
778//update flags 779//update flags
779 enum Update_flags { 780 enum Update_flags {
780 ufDocGeometry=1, 781 ufDocGeometry=1,
781 ufUpdateOnScroll=2, 782 ufUpdateOnScroll=2,
782 ufPos=4}; 783 ufPos=4};
783 784
784//load flags 785//load flags
785 enum Load_flags { 786 enum Load_flags {
786 lfInsert=1, 787 lfInsert=1,
787 lfNewFile=2, 788 lfNewFile=2,
788 lfNoAutoHl=4}; 789 lfNoAutoHl=4};
789 790
790//cursor movement commands 791//cursor movement commands
791 enum Cursor_commands 792 enum Cursor_commands
792 { cmLeft,cmRight,cmWordLeft,cmWordRight, 793 { cmLeft,cmRight,cmWordLeft,cmWordRight,
793 cmHome,cmEnd,cmUp,cmDown, 794 cmHome,cmEnd,cmUp,cmDown,
794 cmScrollUp,cmScrollDown,cmTopOfView,cmBottomOfView, 795 cmScrollUp,cmScrollDown,cmTopOfView,cmBottomOfView,
795 cmPageUp,cmPageDown,cmCursorPageUp,cmCursorPageDown, 796 cmPageUp,cmPageDown,cmCursorPageUp,cmCursorPageDown,
796 cmTop,cmBottom}; 797 cmTop,cmBottom};
797//edit commands 798//edit commands
798 enum Edit_commands { 799 enum Edit_commands {
799 cmReturn=1,cmDelete,cmBackspace,cmKillLine,cmUndo, 800 cmReturn=1,cmDelete,cmBackspace,cmKillLine,cmUndo,
diff --git a/noncore/apps/tinykate/tinykate.cpp b/noncore/apps/tinykate/tinykate.cpp
index 6164fa5..aecc1bd 100644
--- a/noncore/apps/tinykate/tinykate.cpp
+++ b/noncore/apps/tinykate/tinykate.cpp
@@ -1,258 +1,268 @@
1/*************************************************************************** 1/***************************************************************************
2 tinykate.cpp 2 tinykate.cpp
3 Tiny KATE mainwindow 3 Tiny KATE mainwindow
4 ------------------- 4 -------------------
5 begin : November 2002 5 begin : November 2002
6 copyright : (C) 2002 by Joseph Wenninger <jowenn@kde.org> 6 copyright : (C) 2002 by Joseph Wenninger <jowenn@kde.org>
7 ***************************************************************************/ 7 ***************************************************************************/
8 8
9/*************************************************************************** 9/***************************************************************************
10 * * 10 * *
11 * This program is free software; you can redistribute it and/or modify * 11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by * 12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation. * 13 * the Free Software Foundation. *
14 * ONLY VERSION 2 OF THE LICENSE IS APPLICABLE * 14 * ONLY VERSION 2 OF THE LICENSE IS APPLICABLE *
15 * * 15 * *
16 ***************************************************************************/ 16 ***************************************************************************/
17#include <qwidget.h> 17#include <qwidget.h>
18#include <qaction.h> 18#include <qaction.h>
19#include <qlayout.h> 19#include <qlayout.h>
20#include <qpe/qpetoolbar.h> 20#include <qpe/qpetoolbar.h>
21#include <qpe/qpemenubar.h> 21#include <qpe/qpemenubar.h>
22#include <qpe/resource.h> 22#include <qpe/resource.h>
23#include <qpe/global.h> 23#include <qpe/global.h>
24#include <qpe/qpeapplication.h> 24#include <qpe/qpeapplication.h>
25 25
26#include <opie/ofiledialog.h> 26#include <opie/ofiledialog.h>
27 27
28#include "tinykate.h" 28#include "tinykate.h"
29#include "pics/file-new.xpm" 29#include "pics/file-new.xpm"
30#include "pics/file-open.xpm" 30#include "pics/file-open.xpm"
31#include "pics/file-save.xpm" 31#include "pics/file-save.xpm"
32#include "pics/edit-undo.xpm" 32#include "pics/edit-undo.xpm"
33#include "pics/edit-redo.xpm" 33#include "pics/edit-redo.xpm"
34 34
35#include <katedocument.h> 35#include <katedocument.h>
36#include <katehighlight.h> 36#include <katehighlight.h>
37#include <kateview.h> 37#include <kateview.h>
38#include <kglobal.h>
38 39
39TinyKate::TinyKate( QWidget *parent, const char *name, WFlags f) : 40TinyKate::TinyKate( QWidget *parent, const char *name, WFlags f) :
40 QMainWindow( parent, name, f ) 41 QMainWindow( parent, name, f )
41{ 42{
42 nextUnnamed=0; 43 nextUnnamed=0;
43 currentView=0; 44 currentView=0;
44 viewCount=0; 45 viewCount=0;
45 setCaption(tr("TinyKATE")); 46 setCaption(tr("TinyKATE"));
47 KGlobal::setAppName("TinyKATE");
46 48
47 setToolBarsMovable(FALSE); 49 setToolBarsMovable(FALSE);
48 50
49 QPEToolBar *bar = new QPEToolBar( this ); 51 QPEToolBar *bar = new QPEToolBar( this );
50 bar->setHorizontalStretchable( TRUE ); 52 bar->setHorizontalStretchable( TRUE );
51 QPEMenuBar *mb = new QPEMenuBar( bar ); 53 QPEMenuBar *mb = new QPEMenuBar( bar );
52 mb->setMargin( 0 ); 54 mb->setMargin( 0 );
53 55
54 tabwidget=new OTabWidget(this); 56 tabwidget=new OTabWidget(this);
55 setCentralWidget(tabwidget); 57 setCentralWidget(tabwidget);
56 connect(tabwidget,SIGNAL(currentChanged( QWidget *)),this,SLOT(slotCurrentChanged(QWidget *))); 58 connect(tabwidget,SIGNAL(currentChanged( QWidget *)),this,SLOT(slotCurrentChanged(QWidget *)));
57 59
58//FILE ACTIONS 60//FILE ACTIONS
59 QPopupMenu *popup = new QPopupMenu( this ); 61 QPopupMenu *popup = new QPopupMenu( this );
60 62
61 // Action for creating a new document 63 // Action for creating a new document
62 QAction *a = new QAction( tr( "New" ), QPixmap((const char**)file_new_xpm ), QString::null, 0, this, 0 ); 64 QAction *a = new QAction( tr( "New" ), QPixmap((const char**)file_new_xpm ), QString::null, 0, this, 0 );
63 a->addTo( popup ); 65 a->addTo( popup );
64 connect(a, SIGNAL(activated()), this, SLOT(slotNew())); 66 connect(a, SIGNAL(activated()), this, SLOT(slotNew()));
65 67
66 // Action for opening an exisiting document 68 // Action for opening an exisiting document
67 a = new QAction( tr( "Open" ), QPixmap((const char**)file_open_xpm), QString::null, 0, this, 0 ); 69 a = new QAction( tr( "Open" ), QPixmap((const char**)file_open_xpm), QString::null, 0, this, 0 );
68 a->addTo(popup); 70 a->addTo(popup);
69 connect(a, SIGNAL(activated()), this, SLOT(slotOpen())); 71 connect(a, SIGNAL(activated()), this, SLOT(slotOpen()));
70 72
71 73
72 // Action for saving document 74 // Action for saving document
73 a = new QAction( tr( "Save" ), QPixmap((const char**)file_save_xpm), QString::null, 0, this, 0 ); 75 a = new QAction( tr( "Save" ), QPixmap((const char**)file_save_xpm), QString::null, 0, this, 0 );
74 a->addTo(popup); 76 a->addTo(popup);
75 connect(a, SIGNAL(activated()), this, SLOT(slotSave())); 77 connect(a, SIGNAL(activated()), this, SLOT(slotSave()));
76 78
77 // Action for saving document to a new name 79 // Action for saving document to a new name
78 a = new QAction( tr( "Save As" ), QPixmap((const char**)file_save_xpm), QString::null, 0, this, 0 ); 80 a = new QAction( tr( "Save As" ), QPixmap((const char**)file_save_xpm), QString::null, 0, this, 0 );
79 a->addTo(popup); 81 a->addTo(popup);
80 connect(a, SIGNAL(activated()), this, SLOT(slotSaveAs())); 82 connect(a, SIGNAL(activated()), this, SLOT(slotSaveAs()));
81 83
82 // Action for closing the currently active document 84 // Action for closing the currently active document
83 a = new QAction( tr( "Close" ), QPixmap(), QString::null, 0, this, 0 ); 85 a = new QAction( tr( "Close" ), QPixmap(), QString::null, 0, this, 0 );
84 a->addTo(popup); 86 a->addTo(popup);
85 connect(a, SIGNAL(activated()), this, SLOT(slotClose())); 87 connect(a, SIGNAL(activated()), this, SLOT(slotClose()));
86 88
87 89
88 mb->insertItem(tr("File"),popup); 90 mb->insertItem(tr("File"),popup);
89 91
90//EDIT ACTIONS 92//EDIT ACTIONS
91 93
92 // Action for cutting text 94 // Action for cutting text
93 editCut = new QAction( tr( "Cut" ), Resource::loadPixmap( "cut" ), QString::null, 0, this, 0 ); 95 editCut = new QAction( tr( "Cut" ), Resource::loadPixmap( "cut" ), QString::null, 0, this, 0 );
94 editCut->addTo( bar ); 96 editCut->addTo( bar );
95 97
96 // Action for Copying text 98 // Action for Copying text
97 editCopy = new QAction( tr( "Copy" ), Resource::loadPixmap( "copy" ), QString::null, 0, this, 0 ); 99 editCopy = new QAction( tr( "Copy" ), Resource::loadPixmap( "copy" ), QString::null, 0, this, 0 );
98 editCopy->addTo( bar ); 100 editCopy->addTo( bar );
99 101
100 // Action for pasting text 102 // Action for pasting text
101 editPaste = new QAction( tr( "Paste" ), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); 103 editPaste = new QAction( tr( "Paste" ), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 );
102 editPaste->addTo( bar ); 104 editPaste->addTo( bar );
103 105
104 106
105 // Action for finding / replacing text 107 // Action for finding / replacing text
106 editFindReplace = new QAction( tr( "Find/Replace" ), Resource::loadPixmap("find"), QString::null, 0, this, 0 ); 108 editFindReplace = new QAction( tr( "Find/Replace" ), Resource::loadPixmap("find"), QString::null, 0, this, 0 );
107 editFindReplace->addTo( bar ); 109 editFindReplace->addTo( bar );
108 110
109 // Action for undo 111 // Action for undo
110 editUndo = new QAction( tr( "Undo" ), QPixmap((const char**)edit_undo_xpm), QString::null, 0, this, 0 ); 112 editUndo = new QAction( tr( "Undo" ), QPixmap((const char**)edit_undo_xpm), QString::null, 0, this, 0 );
111 editUndo->addTo( bar ); 113 editUndo->addTo( bar );
112 114
113 // Action for redo 115 // Action for redo
114 editRedo = new QAction( tr( "Redo" ), QPixmap((const char**)edit_redo_xpm), QString::null, 0, this, 0 ); 116 editRedo = new QAction( tr( "Redo" ), QPixmap((const char**)edit_redo_xpm), QString::null, 0, this, 0 );
115 editRedo->addTo( bar ); 117 editRedo->addTo( bar );
116 118
117//VIEW ACITONS 119//VIEW ACITONS
118 popup = new QPopupMenu( this ); 120 popup = new QPopupMenu( this );
119 121
120 viewIncFontSizes = new QAction( tr( "Font +" ), QString::null, 0, this, 0 ); 122 viewIncFontSizes = new QAction( tr( "Font +" ), QString::null, 0, this, 0 );
121 viewIncFontSizes->addTo( popup ); 123 viewIncFontSizes->addTo( popup );
122 124
123 viewDecFontSizes = new QAction( tr( "Font -" ), QString::null, 0, this, 0 ); 125 viewDecFontSizes = new QAction( tr( "Font -" ), QString::null, 0, this, 0 );
124 viewDecFontSizes->addTo( popup ); 126 viewDecFontSizes->addTo( popup );
125 127
126 mb->insertItem(tr("View"),popup); 128 mb->insertItem(tr("View"),popup);
127 129
128 130
129 131
130 popup = new QPopupMenu( this ); 132 popup = new QPopupMenu( this );
131 mb->insertItem(tr("Utils"),popup); 133 mb->insertItem(tr("Utils"),popup);
132 134
133//Highlight management 135//Highlight management
134 hlmenu=new QPopupMenu(this); 136 hlmenu=new QPopupMenu(this);
135 HlManager *hlm=HlManager::self(); 137 HlManager *hlm=HlManager::self();
136 for (int i=0;i<hlm->highlights();i++) 138 for (int i=0;i<hlm->highlights();i++)
137 { 139 {
138 hlmenu->insertItem(hlm->hlName(i),i); 140 hlmenu->insertItem(hlm->hlName(i),i);
139 } 141 }
140 popup->insertItem(tr("Highlighting"),hlmenu); 142 popup->insertItem(tr("Highlighting"),hlmenu);
141 143
142 144
143 utilSettings = new QAction( tr( "Settings" ), QString::null, 0, this, 0 ); 145 utilSettings = new QAction( tr( "Settings" ), QString::null, 0, this, 0 );
144 utilSettings->addTo( popup); 146 utilSettings->addTo( popup);
145 147
146 if( qApp->argc() > 1) open(qApp->argv()[1]); 148 if( qApp->argc() > 1) open(qApp->argv()[1]);
147 else slotNew(); 149 else slotNew();
148 150
149} 151}
150 152
153TinyKate::~TinyKate( )
154{
155 qWarning("TinyKate destructor\n");
156 if( KGlobal::config() != 0 ) {
157 qWarning("deleting KateConfig object..\n");
158 delete KGlobal::config();
159 }
160}
151 161
152void TinyKate::slotOpen( ) 162void TinyKate::slotOpen( )
153{ 163{
154 QString filename = OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL, 164 QString filename = OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL,
155 QPEApplication::documentDir()); 165 QPEApplication::documentDir());
156 if (!filename.isEmpty()) { 166 if (!filename.isEmpty()) {
157 open(filename); 167 open(filename);
158 } 168 }
159} 169}
160 170
161void TinyKate::open(const QString & filename) 171void TinyKate::open(const QString & filename)
162{ 172{
163 KateDocument *kd= new KateDocument(false, false, this,0,this); 173 KateDocument *kd= new KateDocument(false, false, this,0,this);
164 KTextEditor::View *kv; 174 KTextEditor::View *kv;
165 QFileInfo fi(filename); 175 QFileInfo fi(filename);
166 QString filenamed = fi.fileName(); 176 QString filenamed = fi.fileName();
167 tabwidget->addTab(kv=kd->createView(tabwidget,"bLAH"),"tinykate/tinykate", filenamed ); 177 tabwidget->addTab(kv=kd->createView(tabwidget,"bLAH"),"tinykate/tinykate", filenamed );
168 qDebug(filename); 178 qDebug(filename);
169 179
170 kd->setDocName( filenamed); 180 kd->setDocName( filenamed);
171 kd->open( filename ); 181 kd->open( filename );
172 viewCount++; 182 viewCount++;
173} 183}
174 184
175void TinyKate::slotCurrentChanged( QWidget * view) 185void TinyKate::slotCurrentChanged( QWidget * view)
176{ 186{
177 if (currentView) { 187 if (currentView) {
178 188
179 disconnect(editCopy,SIGNAL(activated()),currentView,SLOT(copy())); 189 disconnect(editCopy,SIGNAL(activated()),currentView,SLOT(copy()));
180 disconnect(editCut,SIGNAL(activated()),currentView,SLOT(cut())); 190 disconnect(editCut,SIGNAL(activated()),currentView,SLOT(cut()));
181 disconnect(editPaste,SIGNAL(activated()),currentView,SLOT(paste())); 191 disconnect(editPaste,SIGNAL(activated()),currentView,SLOT(paste()));
182 disconnect(editUndo,SIGNAL(activated()),currentView,SLOT(undo())); 192 disconnect(editUndo,SIGNAL(activated()),currentView,SLOT(undo()));
183 disconnect(editRedo,SIGNAL(activated()),currentView,SLOT(redo())); 193 disconnect(editRedo,SIGNAL(activated()),currentView,SLOT(redo()));
184 disconnect(viewIncFontSizes,SIGNAL(activated()), currentView,SLOT(slotIncFontSizes())); 194 disconnect(viewIncFontSizes,SIGNAL(activated()), currentView,SLOT(slotIncFontSizes()));
185 disconnect(viewDecFontSizes,SIGNAL(activated()), currentView,SLOT(slotDecFontSizes())); 195 disconnect(viewDecFontSizes,SIGNAL(activated()), currentView,SLOT(slotDecFontSizes()));
186 disconnect(hlmenu,SIGNAL(activated(int)), currentView,SLOT(setHl(int))); 196 disconnect(hlmenu,SIGNAL(activated(int)), currentView,SLOT(setHl(int)));
187 disconnect(utilSettings,SIGNAL(activated()), currentView,SLOT(configDialog())); 197 disconnect(utilSettings,SIGNAL(activated()), currentView,SLOT(configDialog()));
188 } 198 }
189 199
190 currentView=(KTextEditor::View*)view; 200 currentView=(KTextEditor::View*)view;
191 201
192 connect(editCopy,SIGNAL(activated()),currentView,SLOT(copy())); 202 connect(editCopy,SIGNAL(activated()),currentView,SLOT(copy()));
193 connect(editCut,SIGNAL(activated()),currentView,SLOT(cut())); 203 connect(editCut,SIGNAL(activated()),currentView,SLOT(cut()));
194 connect(editPaste,SIGNAL(activated()),currentView,SLOT(paste())); 204 connect(editPaste,SIGNAL(activated()),currentView,SLOT(paste()));
195 connect(editUndo,SIGNAL(activated()),currentView,SLOT(undo())); 205 connect(editUndo,SIGNAL(activated()),currentView,SLOT(undo()));
196 connect(editRedo,SIGNAL(activated()),currentView,SLOT(redo())); 206 connect(editRedo,SIGNAL(activated()),currentView,SLOT(redo()));
197 connect(viewIncFontSizes,SIGNAL(activated()), currentView,SLOT(slotIncFontSizes())); 207 connect(viewIncFontSizes,SIGNAL(activated()), currentView,SLOT(slotIncFontSizes()));
198 connect(viewDecFontSizes,SIGNAL(activated()), currentView,SLOT(slotDecFontSizes())); 208 connect(viewDecFontSizes,SIGNAL(activated()), currentView,SLOT(slotDecFontSizes()));
199 connect(hlmenu,SIGNAL(activated(int)), currentView,SLOT(setHl(int))); 209 connect(hlmenu,SIGNAL(activated(int)), currentView,SLOT(setHl(int)));
200 connect(utilSettings,SIGNAL(activated()), currentView,SLOT(configDialog())); 210 connect(utilSettings,SIGNAL(activated()), currentView,SLOT(configDialog()));
201 211
202} 212}
203 213
204void TinyKate::slotNew( ) 214void TinyKate::slotNew( )
205{ 215{
206 KateDocument *kd= new KateDocument(false, false, this,0,this); 216 KateDocument *kd= new KateDocument(false, false, this,0,this);
207 KTextEditor::View *kv; 217 KTextEditor::View *kv;
208 tabwidget->addTab(kv=kd->createView(tabwidget,"BLAH"), 218 tabwidget->addTab(kv=kd->createView(tabwidget,"BLAH"),
209 "tinykate/tinykate", 219 "tinykate/tinykate",
210 tr("Unnamed %1").arg(nextUnnamed++)); 220 tr("Unnamed %1").arg(nextUnnamed++));
211 viewCount++; 221 viewCount++;
212} 222}
213 223
214void TinyKate::slotClose( ) 224void TinyKate::slotClose( )
215{ 225{
216 if (currentView==0) return; 226 if (currentView==0) return;
217 KTextEditor::View *dv=currentView; 227 KTextEditor::View *dv=currentView;
218 currentView=0; 228 currentView=0;
219 tabwidget->removePage(dv); 229 tabwidget->removePage(dv);
220 delete dv->document(); 230 delete dv->document();
221 viewCount--; 231 viewCount--;
222 if (!viewCount) slotNew(); 232 if (!viewCount) slotNew();
223} 233}
224 234
225void TinyKate::slotSave() { 235void TinyKate::slotSave() {
226 // feel free to make this how you want 236 // feel free to make this how you want
227 if (currentView==0) return; 237 if (currentView==0) return;
228 238
229 // KateView *kv = (KateView*) currentView; 239 // KateView *kv = (KateView*) currentView;
230 KateDocument *kd = (KateDocument*) currentView->document(); 240 KateDocument *kd = (KateDocument*) currentView->document();
231 // qDebug("saving file "+kd->docName()); 241 // qDebug("saving file "+kd->docName());
232 if( kd->docName().isEmpty()) 242 if( kd->docName().isEmpty())
233 slotSaveAs(); 243 slotSaveAs();
234 else 244 else
235 kd->saveFile(); 245 kd->saveFile();
236 // kv->save(); 246 // kv->save();
237 // kd->saveFile(); 247 // kd->saveFile();
238} 248}
239 249
240void TinyKate::slotSaveAs() { 250void TinyKate::slotSaveAs() {
241 if (currentView==0) return; 251 if (currentView==0) return;
242 KateDocument *kd = (KateDocument*) currentView->document(); 252 KateDocument *kd = (KateDocument*) currentView->document();
243 253
244 QString filename=OFileDialog::getSaveFileName(OFileSelector::EXTENDED_ALL, 254 QString filename=OFileDialog::getSaveFileName(OFileSelector::EXTENDED_ALL,
245 QPEApplication::documentDir()); 255 QPEApplication::documentDir());
246 if (!filename.isEmpty()) { 256 if (!filename.isEmpty()) {
247 qDebug("saving file "+filename); 257 qDebug("saving file "+filename);
248 QFileInfo fi(filename); 258 QFileInfo fi(filename);
249 QString filenamed = fi.fileName(); 259 QString filenamed = fi.fileName();
250 kd->setDocFile( filename); 260 kd->setDocFile( filename);
251 kd->setDocName( filenamed); 261 kd->setDocName( filenamed);
252 kd->saveFile(); 262 kd->saveFile();
253// KTextEditor::View *dv = currentView; 263// KTextEditor::View *dv = currentView;
254// tabwidget->changeTab( dv, filenamed); 264// tabwidget->changeTab( dv, filenamed);
255 // need to change tab label here 265 // need to change tab label here
256 } 266 }
257 267
258} 268}
diff --git a/noncore/apps/tinykate/tinykate.h b/noncore/apps/tinykate/tinykate.h
index 7b61bae..bb32f98 100644
--- a/noncore/apps/tinykate/tinykate.h
+++ b/noncore/apps/tinykate/tinykate.h
@@ -1,67 +1,68 @@
1/*************************************************************************** 1/***************************************************************************
2 tinykate.h 2 tinykate.h
3 Tiny KATE mainwindow 3 Tiny KATE mainwindow
4 ------------------- 4 -------------------
5 begin : November 2002 5 begin : November 2002
6 copyright : (C) 2002 by Joseph Wenninger <jowenn@kde.org> 6 copyright : (C) 2002 by Joseph Wenninger <jowenn@kde.org>
7 ***************************************************************************/ 7 ***************************************************************************/
8 8
9/*************************************************************************** 9/***************************************************************************
10 * * 10 * *
11 * This program is free software; you can redistribute it and/or modify * 11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by * 12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation. * 13 * the Free Software Foundation. *
14 * ONLY VERSION 2 OF THE LICENSE IS APPLICABLE * 14 * ONLY VERSION 2 OF THE LICENSE IS APPLICABLE *
15 * * 15 * *
16 ***************************************************************************/ 16 ***************************************************************************/
17 17
18#ifndef __TINYKATE_H__ 18#ifndef __TINYKATE_H__
19#define __TINYKATE_H__ 19#define __TINYKATE_H__
20 20
21 21
22#include <qmainwindow.h> 22#include <qmainwindow.h>
23#include <opie/otabwidget.h> 23#include <opie/otabwidget.h>
24#include <ktexteditor.h> 24#include <ktexteditor.h>
25 25
26class QAction; 26class QAction;
27class QPopupMenu; 27class QPopupMenu;
28 28
29class TinyKate : public QMainWindow 29class TinyKate : public QMainWindow
30{ 30{
31Q_OBJECT 31Q_OBJECT
32public: 32public:
33 TinyKate( QWidget *parent=0, const char *name=0, WFlags f = 0); 33 TinyKate( QWidget *parent=0, const char *name=0, WFlags f = 0);
34 ~TinyKate( );
34 35
35public slots: 36public slots:
36 QString currentFileName;
37 void slotNew(); 37 void slotNew();
38 38
39protected slots: 39protected slots:
40 void slotOpen(); 40 void slotOpen();
41 void slotClose(); 41 void slotClose();
42 void slotCurrentChanged(QWidget *); 42 void slotCurrentChanged(QWidget *);
43 void slotSave(); 43 void slotSave();
44 void slotSaveAs(); 44 void slotSaveAs();
45protected: 45protected:
46 void open(const QString&); 46 void open(const QString&);
47private: 47private:
48 QString currentFileName;
48 OTabWidget *tabwidget; 49 OTabWidget *tabwidget;
49 KTextEditor::View *currentView; 50 KTextEditor::View *currentView;
50 51
51 QAction *editCopy; 52 QAction *editCopy;
52 QAction *editCut; 53 QAction *editCut;
53 QAction *editPaste; 54 QAction *editPaste;
54 QAction *editUndo; 55 QAction *editUndo;
55 QAction *editRedo; 56 QAction *editRedo;
56 QAction *editFindReplace; 57 QAction *editFindReplace;
57 QAction *viewIncFontSizes; 58 QAction *viewIncFontSizes;
58 QAction *viewDecFontSizes; 59 QAction *viewDecFontSizes;
59 QAction *utilSettings; 60 QAction *utilSettings;
60 61
61 QPopupMenu *hlmenu; 62 QPopupMenu *hlmenu;
62 uint nextUnnamed; 63 uint nextUnnamed;
63 uint viewCount; 64 uint viewCount;
64}; 65};
65 66
66 67
67#endif // __TINYKATE_H__ 68#endif // __TINYKATE_H__
diff --git a/noncore/apps/tinykate/tinykate.pro b/noncore/apps/tinykate/tinykate.pro
index 61b60a6..632bd49 100644
--- a/noncore/apps/tinykate/tinykate.pro
+++ b/noncore/apps/tinykate/tinykate.pro
@@ -1,20 +1,22 @@
1 TEMPLATE= app 1 TEMPLATE= app
2 CONFIG = qt warn_on release 2 CONFIG = qt warn_on release
3 DESTDIR = $(OPIEDIR)/bin 3 DESTDIR = $(OPIEDIR)/bin
4 HEADERS = tinykate.h 4 HEADERS = tinykate.h
5 SOURCES = tinykate.cpp main.cpp 5 SOURCES = tinykate.cpp main.cpp
6 INTERFACES= 6 INTERFACES=
7 INCLUDEPATH+= $(OPIEDIR)/include $(OPIEDIR)/noncore/apps/tinykate/libkate/microkde \ 7 INCLUDEPATH+= $(OPIEDIR)/include \
8 $(OPIEDIR)/noncore/apps/tinykate/libkate \
9 $(OPIEDIR)/noncore/apps/tinykate/libkate/microkde \
8 $(OPIEDIR)/noncore/apps/tinykate/libkate/document \ 10 $(OPIEDIR)/noncore/apps/tinykate/libkate/document \
9 $(OPIEDIR)/noncore/apps/tinykate/libkate/view \ 11 $(OPIEDIR)/noncore/apps/tinykate/libkate/view \
10 $(OPIEDIR)/noncore/apps/tinykate/libkate/interfaces \ 12 $(OPIEDIR)/noncore/apps/tinykate/libkate/interfaces \
11 $(OPIEDIR)/noncore/apps/tinykate/libkate/ktexteditor \ 13 $(OPIEDIR)/noncore/apps/tinykate/libkate/ktexteditor \
12 $(OPIEDIR)/noncore/apps/tinykate/libkate/qt3back 14 $(OPIEDIR)/noncore/apps/tinykate/libkate/qt3back
13 15
14 DEPENDPATH+= $(OPIEDIR)/include 16 DEPENDPATH+= $(OPIEDIR)/include
15LIBS += -lqpe -ltinykate -lopie 17LIBS += -lqpe -ltinykate -lopie
16 TARGET = tinykate 18 TARGET = tinykate
17 19
18 20
19 21
20include ( $(OPIEDIR)/include.pro ) 22include ( $(OPIEDIR)/include.pro )