~ubuntu-branches/ubuntu/saucy/kate/saucy

« back to all changes in this revision

Viewing changes to part/vimode/kateviinputmodemanager.cpp

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell, Rohan Garg, Jonathan Riddell
  • Date: 2013-06-21 00:48:29 UTC
  • mfrom: (1.1.28)
  • Revision ID: package-import@ubuntu.com-20130621004829-y2ui02eg0j47h94y
Tags: 4:4.10.80-0ubuntu1
[ Rohan Garg ]
* New upstream release
  - Update and sort install files
  - Drop kubuntu_pate_find_python.diff, kubuntu_kate_initial_preference.patch,
    kubuntu_find_python.diff from debian/patches , not required

[ Jonathan Riddell ]
* New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
#include "katevivisualmode.h"
38
38
#include "katevireplacemode.h"
39
39
#include "katevikeyparser.h"
 
40
#include "kateviemulatedcommandbar.h"
40
41
 
41
42
KateViInputModeManager::KateViInputModeManager(KateView* view, KateViewInternal* viewInternal)
42
43
{
69
70
           this,
70
71
           SLOT(markChanged(KTextEditor::Document*, KTextEditor::Mark,
71
72
                            KTextEditor::MarkInterface::MarkChangeAction)));
 
73
  // We have to do this outside of KateViNormalMode, as we don't want
 
74
  // KateViVisualMode (which inherits from KateViNormalMode) to respond
 
75
  // to changes in the document as well.
 
76
  m_viNormalMode->beginMonitoringDocumentChanges();
72
77
}
73
78
 
74
79
KateViInputModeManager::~KateViInputModeManager()
90
95
    appendKeyEventToLog( copy );
91
96
  }
92
97
 
93
 
  // FIXME: I think we're making things difficult for ourselves here.  Maybe some
94
 
  //        more thought needs to go into the inheritance hierarchy.
95
 
  switch(m_currentViMode) {
96
 
  case NormalMode:
97
 
    res = m_viNormalMode->handleKeypress(e);
98
 
    break;
99
 
  case InsertMode:
100
 
    res = m_viInsertMode->handleKeypress(e);
101
 
    break;
102
 
  case VisualMode:
103
 
  case VisualLineMode:
104
 
  case VisualBlockMode:
105
 
    res = m_viVisualMode->handleKeypress(e);
106
 
    break;
107
 
  case ReplaceMode:
108
 
    res = m_viReplaceMode->handleKeypress(e);
109
 
    break;
110
 
  default:
111
 
    kDebug( 13070 ) << "WARNING: Unhandled keypress";
112
 
    res = false;
 
98
  if (m_view->viModeEmulatedCommandBar()->isVisible())
 
99
  {
 
100
    res = m_view->viModeEmulatedCommandBar()->handleKeyPress(e);
 
101
  }
 
102
  else
 
103
  {
 
104
    // FIXME: I think we're making things difficult for ourselves here.  Maybe some
 
105
    //        more thought needs to go into the inheritance hierarchy.
 
106
    switch(m_currentViMode) {
 
107
      case NormalMode:
 
108
        res = m_viNormalMode->handleKeypress(e);
 
109
        break;
 
110
      case InsertMode:
 
111
        res = m_viInsertMode->handleKeypress(e);
 
112
        break;
 
113
      case VisualMode:
 
114
      case VisualLineMode:
 
115
      case VisualBlockMode:
 
116
        res = m_viVisualMode->handleKeypress(e);
 
117
        break;
 
118
      case ReplaceMode:
 
119
        res = m_viReplaceMode->handleKeypress(e);
 
120
        break;
 
121
      default:
 
122
        kDebug( 13070 ) << "WARNING: Unhandled keypress";
 
123
        res = false;
 
124
    }
113
125
  }
114
126
 
115
127
  return res;
246
258
 
247
259
const QString KateViInputModeManager::getLastSearchPattern() const
248
260
{
249
 
  return m_view->searchPattern();
 
261
  if (!KateViewConfig::global()->viInputModeEmulateCommandBar())
 
262
  {
 
263
    return m_view->searchPattern();
 
264
  }
 
265
  else
 
266
  {
 
267
    return m_lastSearchPattern;
 
268
  }
250
269
}
251
270
 
252
271
void KateViInputModeManager::setLastSearchPattern( const QString &p )
253
272
{
254
 
  m_view->setSearchPattern(p);
 
273
  if (!KateViewConfig::global()->viInputModeEmulateCommandBar())
 
274
  {
 
275
    // This actually triggers a search, so we definitely don't want it to be called
 
276
    // if we are handle searches ourselves in the Emulated Command Bar.
 
277
    m_view->setSearchPattern(p);
 
278
  }
 
279
  m_lastSearchPattern = p;
255
280
}
256
281
 
257
282
void KateViInputModeManager::changeViMode(ViMode newMode)
548
573
  m_marks.insert( mark, doc->newMovingCursor( pos, behavior ) );
549
574
 
550
575
  // Showing what mark we set:
551
 
  if ( showmark && mark != '>' && mark != '<' ) {
 
576
  if ( showmark && mark != '>' && mark != '<' && mark != '[' && mark != '.' && mark != ']') {
552
577
    if( !marktype & KTextEditor::MarkInterface::markType01 ) {
553
578
      m_view->doc()->addMark( pos.line(),
554
579
          KTextEditor::MarkInterface::markType01 );
555
580
    }
556
581
 
557
 
    m_viNormalMode->message("Mark set: " + mark);
 
582
    // only show message for active view
 
583
    if (m_view->doc()->activeView() == m_view) {
 
584
      m_viNormalMode->message(i18n ("Mark set: %1", mark));
 
585
    }
558
586
  }
559
587
 
560
588
  m_mark_set_inside_viinputmodemanager = false;
592
620
        }
593
621
      }
594
622
      if (!char_exist)
595
 
        m_viNormalMode->error("There no more chars for the next bookmark");
 
623
        m_viNormalMode->error(i18n ("There are no more chars for the next bookmark."));
596
624
    }
597
625
  }
598
626
}
653
681
 
654
682
  return res;
655
683
}
 
684
 
 
685
 
 
686
QString KateViInputModeManager::modeToString(ViMode mode)
 
687
{
 
688
  QString modeStr;
 
689
  switch (mode) {
 
690
    case InsertMode:
 
691
      modeStr = i18n("VI: INSERT MODE");
 
692
      break;
 
693
    case NormalMode:
 
694
      modeStr = i18n("VI: NORMAL MODE");
 
695
      break;
 
696
    case VisualMode:
 
697
      modeStr = i18n("VI: VISUAL");
 
698
      break;
 
699
    case VisualBlockMode:
 
700
      modeStr = i18n("VI: VISUAL BLOCK");
 
701
      break;
 
702
    case VisualLineMode:
 
703
      modeStr = i18n("VI: VISUAL LINE");
 
704
      break;
 
705
    case ReplaceMode:
 
706
      modeStr = i18n("VI: REPLACE");
 
707
      break;
 
708
  }
 
709
 
 
710
  return modeStr;
 
711
}