]> git.r.bdr.sh - rbdr/dotfiles/blob - atom/packages/vim-mode/lib/prefixes.coffee
Remove vim-unimpaired plugin
[rbdr/dotfiles] / atom / packages / vim-mode / lib / prefixes.coffee
1 class Prefix
2 complete: null
3 composedObject: null
4
5 isComplete: -> @complete
6
7 isRecordable: -> @composedObject.isRecordable()
8
9 # Public: Marks this as complete upon receiving an object to compose with.
10 #
11 # composedObject - The next motion or operator.
12 #
13 # Returns nothing.
14 compose: (@composedObject) ->
15 @complete = true
16
17 # Public: Executes the composed operator or motion.
18 #
19 # Returns nothing.
20 execute: ->
21 @composedObject.execute?(@count)
22
23 # Public: Selects using the composed motion.
24 #
25 # Returns an array of booleans representing whether each selections' success.
26 select: ->
27 @composedObject.select?(@count)
28
29 isLinewise: ->
30 @composedObject.isLinewise?()
31
32 #
33 # Used to track the number of times either a motion or operator should
34 # be repeated.
35 #
36 class Repeat extends Prefix
37 count: null
38
39 # count - The initial digit of the repeat sequence.
40 constructor: (@count) -> @complete = false
41
42 # Public: Adds an additional digit to this repeat sequence.
43 #
44 # digit - A single digit, 0-9.
45 #
46 # Returns nothing.
47 addDigit: (digit) ->
48 @count = @count * 10 + digit
49
50 #
51 # Used to track which register the following operator should operate on.
52 #
53 class Register extends Prefix
54 name: null
55
56 # name - The single character name of the desired register
57 constructor: (@name) -> @complete = false
58
59 # Public: Marks as complete and sets the operator's register if it accepts it.
60 #
61 # composedOperator - The operator this register pertains to.
62 #
63 # Returns nothing.
64 compose: (composedObject) ->
65 super(composedObject)
66 composedObject.register = @name if composedObject.register?
67
68 module.exports = {Repeat, Register}