   # Private: Used to enable operator-pending mode.
   activateOperatorPendingMode: ->
     @deactivateInsertMode()
-    @setMode('operator-pending', null)
-    @changeModeClass('operator-pending-mode')
-    @updateStatusBar()
-
-  changeModeClass: (targetMode) ->
-    for mode in SUPPPOTED_MODES
-      if mode is targetMode
-        @editorElement.classList.add(mode)
-      else
-        @editorElement.classList.remove(mode)
+    @setMode('operator-pending')
+    @updateStatusBar()
 
   # Private: Resets the normal mode back to it's initial state.
   #

    else
      @deactivateInsertMode()
      @setMode('visual', submode)
      @changeModeClass('visual-mode')

      if @vimState.submode is 'linewise'
        @editor.selectLinesContainingCursors()

# Grim  = require 'grim'

module.exports =
class ModeManager
  constructor: (@vimState) ->
    {@editor, @editorElement} = @vimState

  isNormalMode: ->
    @vimState.mode is 'normal'

  isInsertMode: ->
    @vimState.mode is 'insert'

  isOperatorPendingMode: ->
    @vimState.mode is 'operator-pending'

  isVisualMode: ->
    @vimState.mode is 'visual'

  isVisualCharacterwiseMode: ->
    @vimState.mode is 'visual' and @vimState.submode is 'characterwise'

  isVisualBlockwiseMode: ->
    @vimState.mode is 'visual' and @vimState.submode is 'blockwise'

  isVisualLinewiseMode: ->
    @vimState.mode is 'visual' and @vimState.submode is 'linewise'


  setMode: (mode, submode=null) ->
    @vimState.mode = mode
    @vimState.submode = submode
    modes = ['normal', 'insert', 'visual', 'operator-pending']

    for _mode in modes
      @editorElement.classList.remove "#{_mode}-mode"
    @editorElement.classList.add "#{mode}-mode"

  activateNormalMode: ->
    @deactivateInsertMode()
    @deactivateVisualMode()
    @setMode('normal')

    @vimState.operationStack.clear()
    for selection in @editor.getSelections()
