# # The main modes defined here are: # - VisualMode # - VisualLineMode # - CaretMode # # SuppressPrintable and CountPrefix are shared utility base classes. # Movement is a shared vim-like movement base class. # # The class inheritance hierarchy is: # - Mode, SuppressPrintable, CountPrefix, Movement, [ VisualMode | CaretMode ] # - Mode, SuppressPrintable, CountPrefix, Movement, VisualMode, VisualLineMode # # The possible mode states are: # - ..., VisualMode # - ..., VisualLineMode # - ..., CaretMode # - ..., VisualMode, FindMode # - ..., VisualLineMode, FindMode # - ..., CaretMode, FindMode # # This prevents printable characters from being passed through to underlying modes or the underlying page. class SuppressPrintable extends Mode constructor: (options = {}) -> handler = (event) => return @stopBubblingAndTrue if not KeyboardUtils.isPrintable event return @suppressEvent if event.type != "keydown" # Completely suppress Backspace and Delete, they change the selection. return @suppressEvent if event.keyCode in [ keyCodes.backspace, keyCodes.deleteKey ] # Suppress propagation (but not preventDefault) for keydown, printable events. DomUtils.suppressPropagation event @stopBubblingAndFalse super extend options, keydown: handler, keypress: handler, keyup: handler # This monitors keypresses and maintains the count prefix. class CountPrefix extends SuppressPrintable constructor: (options) -> @countPrefix = "" # This is an initial multiplier for the first count. @countPrefixFactor = options.initialCountPrefix || 1 super options @push _name: "#{@id}/count-prefix" keypress: (event) => @alwaysContinueBubbling => unless event.metaKey or event.ctrlKey or event.altKey keyChar = String.fromCharCode event.charCode @countPrefix = if keyChar.length == 1 and "0" <= keyChar <= "9" and @countPrefix + keyChar != "0" @countPrefix + keyChar else "" getCountPrefix: -> count = @countPrefixFactor * (if 0 < @countPrefix.length then parseInt @countPrefix else 1) @countPrefix = ""; @countPrefixFactor = 1 count # Symbolic names for some common strings. forward = "forward" backward = "backward" character = "character" word = "word" line = "line" sentence = "sentence" paragraph = "paragraph" vimword = "vimword" lineboundary= "lineboundary" # This implements vim-like movements, and includes quite a number of gereral utility methods. class Movement extends CountPrefix opposite: forward: backward, backward: forward # Paste from clipboard. paste: (callback) -> chrome.runtime.sendMessage handler: "pasteFromClipboard", (response) -> callback response # Copy to clipboard. copy: (text, isFinalUserCopy = false) -> chrome.runtime.sendMessage handler: "copyToClipboard", data: text # If isFinalUserCopy is set, then we're copying the final text selected by the user (and exiting). # However, @protectClipboard may later try to restore the original clipboard contents. Therefore, we # disable copy so that subsequent copies do not propagate. @copy = (->) if isFinalUserCopy # This is used whenever manipulating the selection may, as a side effect, change the clipboard's contents. # We restore the original clipboard contents when we're done. May be asynchronous. We use a lock so that # calls can be nested. protectClipboard: do -> locked = false (func) -> if locked then func() else locked = true @paste (text) => func(); @copy text; locked = false # Replace the current mode with another. For example, replace caret mode with visual mode, or replace visual # mode with visual-line mode. changeMode: (mode, options = {}) -> @exit() new mode options # Return the character following (to the right of) the focus, and leave the selection unchanged. Returns # undefined if no such character exists. getNextForwardCharacter: -> beforeText = @selection.toString() if beforeText.length == 0 or @getDirection() == forward @selection.modify "extend", forward, character afterText = @selection.toString() if beforeText != afterText @selection.modify "extend", backward, character afterText[afterText.length - 1] else beforeText[0] # Existing range selection is backwards. # As above, but backwards. getNextBackwardCharacter: -> beforeText = @selection.toString() if beforeText.length == 0 or @getDirection() == backward @selection.modify "extend", backward, character afterText = @selection.toString() if beforeText != afterText @selection.modify "extend", forward, character afterText[0] else beforeText[beforeText.length - 1] # Existing range selection is forwards. # Test whether the character following the focus is a word character (and leave the selection unchanged). nextCharacterIsWordCharacter: do -> regexp = null -> # This regexp matches "word" characters (apparently in any language). # From http://stackoverflow.com/questions/150033/regular-expression-to-match-non-english-characters regexp || = /[_0-9\u0041-\u005A\u0061-\u00
## www.pubnub.com - PubNub Real-time push service in the cloud. # coding=utf8 ## PubNub Real-time Push APIs and Notifications Framework ## Copyright (c) 2010 Stephen Blum ## http://www.pubnub.com/ import sys from Pubnub import PubnubTwisted as Pubnub publish_key = len(sys.argv) > 1 and sys.argv[1] or 'pam' subscribe_key = len(sys.argv) > 2 and sys.argv[2] or 'pam' secret_key = len(sys.argv) > 3 and sys.argv[3] or 'pam' cipher_key = len(sys.argv) > 4 and sys.argv[4] or '' ssl_on = len(sys.argv) > 5 and bool(sys.argv[5]) or False ## ----------------------------------------------------------------------- ## Initiate Pubnub State ## ----------------------------------------------------------------------- pubnub = Pubnub(publish_key=publish_key, subscribe_key=subscribe_key, secret_key=secret_key, cipher_key=cipher_key, ssl_on=ssl_on) channel = 'hello_world' authkey = "abcd" def callback(message): print(message) pubnub.revoke(channel, authkey, callback=callback, error=callback) pubnub.start()