This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ColorPicker where | |
import Model exposing (initialModel) | |
import Action exposing (update) | |
import View exposing (view) | |
type Action = | |
InitialsSaved Bool | |
| Noop | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ';' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_logger | |
l = @@logger || begin | |
l = Logger.new(@@logger_file||"log") | |
l.level = Logger::DEBUG | |
l | |
end | |
@@logger = l | |
l | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MemoryCursor | |
property :addr | |
def initialize @memory, @addr | |
@chunk = Array(UInt8).new | |
end | |
def read_byte | |
@chunk << @memory.read_byte @addr | |
@addr += 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Test | |
def self.logger | |
@@logger | |
end | |
def self.logger= logger | |
@@logger = logger | |
end | |
end |