Skip to content

Instantly share code, notes, and snippets.

module Button.Model (Model)
-- nothing changed here
type alias Model =
{ initialsSaved : Bool
}
initialModel : Model
@daphee
daphee / main.elm
Last active March 23, 2016 22:55 — forked from ethagnawl/main.elm
sharing actions
module ColorPicker where
import Model exposing (initialModel)
import Action exposing (update)
import View exposing (view)
type Action =
InitialsSaved Bool
| Noop
require "colorize"
# I think a pure regex solution isn't possible unfortunately
# This regex is still reall handy becomes you can
# go from escape code group to escape code and get the text in between
FORMAT_GROUPS_REG = /(?:\e\[(?:(?:[0-9]{1,3});)*(?:[0-9]{1,3})m)+([^\e]+)/
# Procues something like #<MatchData "\e[33;1m\e[99mT" 1:"T">
# This now exctracts the styles from the groups of escape codes
# This is a number either followed by a 'm' or a ';'
def get_logger
l = @@logger || begin
l = Logger.new(@@logger_file||"log")
l.level = Logger::DEBUG
l
end
@@logger = l
l
end
def bind_key(c : Char, f : Int32,Int32 -> Int32)
raise ArgumentError.new "not a valid ASCII character: '#{c}'" if !(0 <= c.ord <= 255)
wrapper = BindingProc.new {|count, key| LibReadline::Int.cast(f.call(count.to_i32, key.to_i32))}
LibReadline.rl_bind_key(c.ord, wrapper)
end
class MemoryCursor
property :addr
def initialize @memory, @addr
@chunk = Array(UInt8).new
end
def read_byte
@chunk << @memory.read_byte @addr
@addr += 1
module Test
def self.logger
@@logger
end
def self.logger= logger
@@logger = logger
end
end