-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Included in widget modules and allows convinience shortcuts in property formats such as: span @default, :font => "terminus 12" underline @time background :red, @artist foreground :blue, @title bold @count * lib/amazing/helpers/pango_markup.rb: (span) simple span tag generator. (background) shortcut for background span. (foreground) shortcut for foreground span. (underline) shortcut for underline span. (bold) shortcut for weighted span. * lib/amazing/widget.rb: (Widget) include pango markup helper.
- Loading branch information
Showing
2 changed files
with
28 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
module Amazing | ||
module Helpers | ||
module PangoMarkup | ||
def span(text, opts) | ||
attrs = opts.map {|key, value| "#{key}=#{value.to_s.inspect}" }.join(" ") | ||
"<span #{attrs}>#{text}</span>" | ||
end | ||
|
||
def background(color, text) | ||
span(text, :background => color) | ||
end | ||
|
||
def foreground(color, text) | ||
span(text, :foreground => color) | ||
end | ||
|
||
def underline(text, style=:single) | ||
span(text, :underline => style) | ||
end | ||
|
||
def bold(text, level=:bold) | ||
span(text, :weight => level) | ||
end | ||
end | ||
end | ||
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