~ubuntu-branches/ubuntu/lucid/kde4libs/lucid-updates

« back to all changes in this revision

Viewing changes to kate/document/katedocument.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Thomas
  • Date: 2010-01-19 20:32:41 UTC
  • mfrom: (1.1.42 upstream)
  • Revision ID: james.westby@ubuntu.com-20100119203241-6qlz4p6emiawose6
Tags: 4:4.3.95-0ubuntu1
* New upstream release candidate:
  - Remove kubuntu_71_knewstuff_crashes.diff, applied upstream
  - Remove kubuntu_72_popupapplet_crash_fix.diff, applied upstream
  - Refresh kubuntu_70_dbusmenu.diff
  - Bump RUNTIME_DEPS value in debian/rules to 4.3.90
  - Update .install files

Show diffs side-by-side

added added

removed removed

Lines of Context:
2701
2701
        if (ch == '[') { bracketInserted = true; buf.append (']'); }
2702
2702
        if (ch == '{') { bracketInserted = true; buf.append ('}'); }
2703
2703
        if (ch == '"') { bracketInserted = true; buf.append ('"'); }
 
2704
        if (ch == '\'') { bracketInserted = true; buf.append ('\''); }
2704
2705
      }
2705
2706
    }
2706
2707
  }
2823
2824
  if ((col == 0) && (line == 0))
2824
2825
    return;
2825
2826
 
 
2827
  int complement = 0;
2826
2828
  if (col > 0)
2827
2829
  {
 
2830
    if (config()->configFlags() & KateDocumentConfig::cfAutoBrackets)
 
2831
    {
 
2832
      // if inside empty (), {}, [], '', "" delete both
 
2833
      KateTextLine::Ptr tl = m_buffer->plainLine(line);
 
2834
      if(!tl) return;
 
2835
      QChar prevChar = tl->at(col-1);
 
2836
      QChar nextChar = tl->at(col);
 
2837
 
 
2838
      if ( (prevChar == '"' && nextChar == '"') ||
 
2839
           (prevChar == '\'' && nextChar == '\'') ||
 
2840
           (prevChar == '(' && nextChar == ')') ||
 
2841
           (prevChar == '[' && nextChar == ']') ||
 
2842
           (prevChar == '{' && nextChar == '}') )
 
2843
      {
 
2844
        complement = 1;
 
2845
      }
 
2846
    }
2828
2847
    if (!(config()->configFlags() & KateDocumentConfig::cfBackspaceIndents))
2829
2848
    {
2830
2849
      // ordinary backspace
2831
2850
      //c.cursor.col--;
2832
 
      removeText(KTextEditor::Range(line, col-1, line, col));
 
2851
      removeText(KTextEditor::Range(line, col-1, line, col+complement));
2833
2852
    }
2834
2853
    else
2835
2854
    {
2851
2870
        indent( view, line, -1);
2852
2871
      }
2853
2872
      else
2854
 
        removeText(KTextEditor::Range(line, col-1, line, col));
 
2873
        removeText(KTextEditor::Range(line, col-1, line, col+complement));
2855
2874
    }
2856
2875
  }
2857
2876
  else
3177
3196
 
3178
3197
  editStart();
3179
3198
 
3180
 
  insertText (range.end(), endComment);
3181
 
  insertText (range.start(), startComment);
 
3199
  if (!view->blockSelection()) {
 
3200
    insertText(range.end(), endComment);
 
3201
    insertText(range.start(), startComment);
 
3202
  } else {
 
3203
    for (int line = range.start().line(); line <= range.end().line(); line++ ) {
 
3204
      KTextEditor::Range subRange = rangeOnLine(range, line);
 
3205
      insertText(subRange.end(), endComment);
 
3206
      insertText(subRange.start(), startComment);
 
3207
    }
 
3208
  }
3182
3209
 
3183
3210
  editEnd ();
3184
3211
  // selection automatically updated (KateSmartRange)
3462
3489
    else
3463
3490
    {
3464
3491
      // anders: this seems like it will work with above changes :)
3465
 
      removed = ( hasStartLineCommentMark
3466
 
          && removeStartLineCommentFromSelection( v, startAttrib ) )
3467
 
        || ( hasStartStopCommentMark
3468
 
          && removeStartStopCommentFromSelection( v, startAttrib ) );
 
3492
      removed = ( hasStartStopCommentMark
 
3493
          && removeStartStopCommentFromSelection( v, startAttrib ) )
 
3494
      || ( hasStartLineCommentMark
 
3495
          && removeStartLineCommentFromSelection( v, startAttrib ) );
3469
3496
    }
3470
3497
  }
3471
3498
}
5493
5520
 
5494
5521
KTextEditor::Attribute::Ptr KateDocument::defaultStyle(const KTextEditor::HighlightInterface::DefaultStyle ds) const
5495
5522
{
5496
 
  return KateHlManager::self()->getDefaultAttribute(ds);
 
5523
  ///TODO: should this maybe be put into the View until the glory day the renderer does not require a View?
 
5524
  KateView* view = activeKateView();
 
5525
  Q_ASSERT(view);
 
5526
 
 
5527
  KateAttributeList list;
 
5528
  return highlight()->attributes(view->renderer()->config()->schema()).at(ds);
5497
5529
}
5498
5530
 
5499
5531
QList< KTextEditor::HighlightInterface::AttributeBlock > KateDocument::lineAttributes(const unsigned int line)