~ubuntu-branches/ubuntu/gutsy/kde4libs/gutsy

« back to all changes in this revision

Viewing changes to kate/part/katecmds.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2007-02-21 11:00:12 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20070221110012-6kw8khr9knv6lmg1
Tags: 3.80.3-0ubuntu1
New upstream unstable release

Show diffs side-by-side

added added

removed removed

Lines of Context:
79
79
    << "set-indent-width"
80
80
    << "set-indent-mode" << "set-auto-indent"
81
81
    << "set-line-numbers" << "set-folding-markers" << "set-icon-border"
 
82
    << "set-wrap-cursor"
82
83
    << "set-word-wrap" << "set-word-wrap-column"
83
84
    << "set-replace-tabs-save" << "set-remove-trailing-space-save"
84
85
    << "set-highlight" << "set-show-indent";
86
87
  return l;
87
88
}
88
89
 
89
 
QString KateCommands::CoreCommands::name(const QString& cmd) const
90
 
{
91
 
  // TODO: return meaningful names, like "Indent", "Unindent",
92
 
  // "Clean Indentation", "Comment", "Uncomment", "Goto", "Kill line",
93
 
  return QString();
94
 
}
95
 
 
96
 
QString KateCommands::CoreCommands::description(const QString& cmd) const
97
 
{
98
 
  // TODO: return meaningful descriptions, like
99
 
  // "Increase indentation level.", "Decrease indentation level.",
100
 
  // "Remove indentation."
101
 
  return QString();
102
 
}
103
 
 
104
 
QString KateCommands::CoreCommands::category(const QString& cmd) const
105
 
{
106
 
  // TODO: return meaningful descriptions, like
107
 
  // "Increase indentation level.", "Decrease indentation level.",
108
 
  // "Remove indentation."
109
 
  return QString();
110
 
}
111
 
 
112
90
bool KateCommands::CoreCommands::exec(KTextEditor::View *view,
113
91
                            const QString &_cmd,
114
92
                            QString &errorMsg)
172
150
  }
173
151
  else if ( cmd == "set-highlight" )
174
152
  {
175
 
    QString val = _cmd.section( ' ', 1 ).toLower();
176
 
    for ( uint i=0; i < v->doc()->hlModeCount(); i++ )
177
 
    {
178
 
      if ( v->doc()->hlModeName( i ).toLower() == val )
179
 
      {
180
 
        v->doc()->setHlMode( i );
181
 
        return true;
182
 
      }
183
 
    }
 
153
    if ( v->doc()->setHighlighting( args.first()) )
 
154
      return true;
 
155
      
184
156
    KCC_ERR( i18n("No such highlight '%1'",  args.first() ) );
185
157
  }
186
158
 
236
208
            cmd == "set-remove-trailing-space" ||
237
209
            cmd == "set-show-tabs" ||
238
210
            cmd == "set-word-wrap" ||
 
211
            cmd == "set-wrap-cursor" ||
239
212
            cmd == "set-replace-tabs-save" ||
240
213
            cmd == "set-remove-trailing-space-save" ||
241
214
            cmd == "set-show-indent" )
259
232
        setDocFlag( KateDocumentConfig::cfRemoveTrailingDyn, enable, v->doc() );
260
233
      else if ( cmd == "set-show-tabs" )
261
234
        setDocFlag( KateDocumentConfig::cfShowTabs, enable, v->doc() );
 
235
      else if ( cmd == "set-show-trailing-spaces" )
 
236
        setDocFlag( KateDocumentConfig::cfShowSpaces, enable, v->doc() );
262
237
      else if ( cmd == "set-word-wrap" )
263
238
        v->doc()->setWordWrap( enable );
264
239
      else if ( cmd == "set-remove-trailing-space-save" )
265
240
        setDocFlag( KateDocumentConfig::cfRemoveSpaces, enable, v->doc() );
 
241
      else if ( cmd == "set-wrap-cursor" )
 
242
        setDocFlag( KateDocumentConfig::cfWrapCursor, enable, v->doc() );
266
243
 
267
244
      return true;
268
245
    }
535
512
    res += sedMagic(doc, line, find, replace, d, !noCase, repeat);
536
513
  }
537
514
 
538
 
  msg = i18np("1 replacement done", "%n replacements done",res );
 
515
  msg = i18np("1 replacement done", "%1 replacements done",res );
539
516
 
540
517
  doc->editEnd();
541
518
 
542
519
  return true;
543
520
}
544
521
 
545
 
QString KateCommands::SedReplace::name (const QString& cmd) const
546
 
{
547
 
  Q_UNUSED(cmd);
548
 
  return i18n("Sed Replace");
549
 
}
550
 
 
551
 
QString KateCommands::SedReplace::description (const QString& cmd) const
552
 
{
553
 
  Q_UNUSED(cmd);
554
 
  return i18n("Support for sed-like search and replace.");
555
 
}
556
 
 
557
 
QString KateCommands::SedReplace::category (const QString& cmd) const
558
 
{
559
 
  Q_UNUSED(cmd);
560
 
  return i18n("Edit");
561
 
}
562
522
//END SedReplace
563
523
 
564
524
//BEGIN Character
604
564
  return true;
605
565
}
606
566
 
607
 
QString KateCommands::Character::name (const QString& cmd) const
608
 
{
609
 
  Q_UNUSED(cmd);
610
 
  return i18n("Insert Character");
611
 
}
612
 
 
613
 
QString KateCommands::Character::description (const QString& cmd) const
614
 
{
615
 
  Q_UNUSED(cmd);
616
 
  return i18n("Insert a unicode or ASCII character.");
617
 
}
618
 
 
619
 
QString KateCommands::Character::category (const QString& cmd) const
620
 
{
621
 
  Q_UNUSED(cmd);
622
 
  return i18n("Edit");
623
 
}
624
567
//END Character
625
568
 
626
569
//BEGIN Date
627
570
bool KateCommands::Date::exec (KTextEditor::View *view, const QString &cmd, QString &)
628
571
{
629
 
  if (cmd.left(4) != "date")
 
572
  if (!cmd.startsWith(QLatin1String("date")))
630
573
    return false;
631
574
 
632
575
  if (QDateTime::currentDateTime().toString(cmd.mid(5, cmd.length()-5)).length() > 0)
637
580
  return true;
638
581
}
639
582
 
640
 
QString KateCommands::Date::name (const QString& cmd) const
641
 
{
642
 
  Q_UNUSED(cmd);
643
 
  return i18n("Insert Date/Time");
644
 
}
645
 
 
646
 
QString KateCommands::Date::description (const QString& cmd) const
647
 
{
648
 
  Q_UNUSED(cmd);
649
 
  return i18n("Insert the current Date and time.");
650
 
}
651
 
 
652
 
QString KateCommands::Date::category (const QString& cmd) const
653
 
{
654
 
  Q_UNUSED(cmd);
655
 
  return i18n("Edit");
656
 
}
657
583
//END Date
658
584
 
659
585
// kate: space-indent on; indent-width 2; replace-tabs on;