 # Grim  = require 'grim'
-
-SUPPPOTED_MODES = [
-  'normal-mode'
-  'insert-mode'
-  'visual-mode'
-  'operator-pending-mode'
-]
 
 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'
 
-  isNormalMode: ->
-    @vimState.mode is 'normal'
-
-  isInsertMode: ->
-    @vimState.mode is 'insert'
-
-  isOperatorPendingMode: ->
-    @vimState.mode is 'operator-pending'
+  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')
-    @changeModeClass('normal-mode')
 
     @vimState.operationStack.clear()
     for selection in @editor.getSelections()

  activateReplaceMode: ->
    @activateInsertMode('replace')
    @editorElement.classList.add('replace-mode')
    @replaceModeCounter = 0
    @vimState.subscriptions.add @replaceModeListener = @editor.onWillInsertText @replaceModeInsertHandler
    @vimState.subscriptions.add @replaceModeUndoListener = @editor.onDidInsertText @replaceModeUndoHandler

    else
      @deactivateInsertMode()
      @setMode('visual', submode)

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