From 1cc4c52c7aacdc4f1f8bfa27649d9983b3828a4f Mon Sep 17 00:00:00 2001 From: Garen Torikian Date: Fri, 19 Apr 2013 16:02:36 -0700 Subject: [PATCH] Style emoji --- src/app/edit-session.coffee | 28 +++++++++---------- .../lib/markdown-preview-view.coffee | 21 +++++++++++++- .../stylesheets/markdown-preview.less | 5 ++++ 3 files changed, 39 insertions(+), 15 deletions(-) diff --git a/src/app/edit-session.coffee b/src/app/edit-session.coffee index 31f224edf..e8b6ae40b 100644 --- a/src/app/edit-session.coffee +++ b/src/app/edit-session.coffee @@ -94,7 +94,7 @@ class EditSession # Retrieves the filename of the open file. # # This is `'untitled'` if the file is new and not saved to the disk. - # + # # Returns a {String}. getTitle: -> if path = @getPath() @@ -175,7 +175,7 @@ class EditSession setSoftWrap: (@softWrap) -> # Retrieves that character used to indicate a tab. - # + # # If soft tabs are enabled, this is a space (`" "`) times the {.getTabLength} value. # Otherwise, it's a tab (`\t`). # @@ -191,22 +191,22 @@ class EditSession # # tabLength - A {Number} that defines the new tab length. setTabLength: (tabLength) -> @displayBuffer.setTabLength(tabLength) - + # Given a position, this clips it to a real position. # # For example, if `position`'s row exceeds the row count of the buffer, - # or if its column goes beyond a line's length, this "sanitizes" the value + # or if its column goes beyond a line's length, this "sanitizes" the value # to a real position. # # position - The {Point} to clip # # Returns the new, clipped {Point}. Note that this could be the same as `position` if no clipping was performed. clipBufferPosition: (bufferPosition) -> @buffer.clipPosition(bufferPosition) - + # Given a range, this clips it to a real range. # # For example, if `range`'s row exceeds the row count of the buffer, - # or if its column goes beyond a line's length, this "sanitizes" the value + # or if its column goes beyond a line's length, this "sanitizes" the value # to a real range. # # range - The {Point} to clip @@ -319,13 +319,13 @@ class EditSession # {Delegates to: DisplayBuffer.screenPositionForBufferPosition} screenPositionForBufferPosition: (bufferPosition, options) -> @displayBuffer.screenPositionForBufferPosition(bufferPosition, options) - + # {Delegates to: DisplayBuffer.bufferPositionForScreenPosition} bufferPositionForScreenPosition: (screenPosition, options) -> @displayBuffer.bufferPositionForScreenPosition(screenPosition, options) - + # {Delegates to: DisplayBuffer.screenRangeForBufferRange} screenRangeForBufferRange: (bufferRange) -> @displayBuffer.screenRangeForBufferRange(bufferRange) - + # {Delegates to: DisplayBuffer.bufferRangeForScreenRange} bufferRangeForScreenRange: (screenRange) -> @displayBuffer.bufferRangeForScreenRange(screenRange) @@ -592,7 +592,7 @@ class EditSession # Given a buffer row, this returns a suggested indentation level. # - # The indentation level provided is based on the current language. + # The indentation level provided is based on the current language. # # bufferRow - A {Number} indicating the buffer row # @@ -806,7 +806,7 @@ class EditSession # {Delegates to: DisplayBuffer.getMarkerHeadScreenPosition} getMarkerHeadScreenPosition: (args...) -> @displayBuffer.getMarkerHeadScreenPosition(args...) - + # {Delegates to: DisplayBuffer.setMarkerHeadScreenPosition} setMarkerHeadScreenPosition: (args...) -> @displayBuffer.setMarkerHeadScreenPosition(args...) @@ -826,7 +826,7 @@ class EditSession # {Delegates to: DisplayBuffer.setMarkerTailScreenPosition} setMarkerTailScreenPosition: (args...) -> @displayBuffer.setMarkerTailScreenPosition(args...) - + # {Delegates to: DisplayBuffer.getMarkerTailBufferPosition} getMarkerTailBufferPosition: (args...) -> @displayBuffer.getMarkerTailBufferPosition(args...) @@ -990,7 +990,7 @@ class EditSession # # Returns an {Array} of {Selection}s. getSelections: -> new Array(@selections...) - + # Gets the selection at the specified index. # # index - The id {Number} of the selection @@ -1268,7 +1268,7 @@ class EditSession # Selects all the text from the current cursor position to the beginning of the next word. selectToBeginningOfNextWord: -> @expandSelectionsForward (selection) => selection.selectToBeginningOfNextWord() - + # Selects the current word. selectWord: -> @expandSelectionsForward (selection) => selection.selectWord() diff --git a/src/packages/markdown-preview/lib/markdown-preview-view.coffee b/src/packages/markdown-preview/lib/markdown-preview-view.coffee index 6f4707453..1ec526b68 100644 --- a/src/packages/markdown-preview/lib/markdown-preview-view.coffee +++ b/src/packages/markdown-preview/lib/markdown-preview-view.coffee @@ -1,7 +1,10 @@ $ = require 'jquery' +_ = require 'underscore' ScrollView = require 'scroll-view' {$$$} = require 'space-pen' roaster = require 'roaster' +LanguageMode = require 'language-mode' +Buffer = require 'text-buffer' module.exports = class MarkdownPreviewView extends ScrollView @@ -66,5 +69,21 @@ class MarkdownPreviewView extends ScrollView if err @setErrorHtml(err) else - @html(html) + result = @html(html) + preList = result.find("pre") + for pre in preList + grammar = _.find syntax.grammars, (grammar) -> + return "ruby" == grammar.scopeName.split(".").pop() + + if grammar + languageMode = new LanguageMode(this, grammar) + console.log pre + code = pre.childNodes[0] + text = code.textContent.split("\n") + + for line in text + tokens = languageMode.tokenizeLine(text) + console.log tokens + #codeBuffer = new Buffer("", text) + #x = 1 ) diff --git a/src/packages/markdown-preview/stylesheets/markdown-preview.less b/src/packages/markdown-preview/stylesheets/markdown-preview.less index 608389a88..533eab598 100644 --- a/src/packages/markdown-preview/stylesheets/markdown-preview.less +++ b/src/packages/markdown-preview/stylesheets/markdown-preview.less @@ -400,4 +400,9 @@ background-color: transparent; border: none; } + + .emoji { + height: 20px; + width: 20px; + } }