ui.gadgets.*: updated docs and new tests
As mentioned on the mailing list, the editor class doesn't have a color slot.char-rename
parent
cb39da4b31
commit
351838fcff
basis/ui/gadgets
|
@ -1,21 +1,23 @@
|
|||
USING: documents help.markup help.syntax ui.gadgets
|
||||
ui.gadgets.scrollers models strings ui.commands sequences
|
||||
ui.text colors fonts help.tips ;
|
||||
USING: colors documents fonts help.markup help.syntax help.tips models
|
||||
sequences strings ui.commands ui.gadgets ui.gadgets.line-support
|
||||
ui.gadgets.scrollers ;
|
||||
IN: ui.gadgets.editors
|
||||
|
||||
HELP: <multiline-editor>
|
||||
{ $values { "editor" multiline-editor } }
|
||||
{ $description "Creates a new multi-line editor gadget." } ;
|
||||
|
||||
HELP: editor
|
||||
{ $class-description "An editor is a control for editing a multi-line passage of text stored in a " { $link document } " model. Editors are crated by calling " { $link <editor> } "."
|
||||
$nl
|
||||
"Editors have the following slots:"
|
||||
{ $list
|
||||
{ { $snippet "font" } " - a " { $link font } "." }
|
||||
{ { $snippet "color" } " - a " { $link color } "." }
|
||||
{ { $snippet "caret-color" } " - a " { $link color } "." }
|
||||
{ { $snippet "selection-color" } " - a " { $link color } "." }
|
||||
{ { $snippet "caret" } " - a " { $link model } " storing a line/column pair." }
|
||||
{ { $snippet "mark" } " - a " { $link model } " storing a line/column pair. If there is no selection, the mark is equal to the caret, otherwise the mark is located at the opposite end of the selection from the caret." }
|
||||
{ { $snippet "focused?" } " - a boolean." }
|
||||
} } ;
|
||||
} }
|
||||
{ $see-also line-gadget } ;
|
||||
|
||||
HELP: <editor>
|
||||
{ $values { "editor" "a new " { $link editor } } }
|
||||
|
|
|
@ -1,5 +1,43 @@
|
|||
USING: arrays colors fonts help.markup help.syntax
|
||||
ui.gadgets.scrollers ;
|
||||
IN: ui.gadgets.line-support
|
||||
USING: help.markup help.syntax ;
|
||||
|
||||
HELP: line-gadget
|
||||
{ $class-description "Base class for gadgets that implements display of sequences of text."
|
||||
$nl
|
||||
"Line gadgets have the following slots:"
|
||||
{ $table
|
||||
{
|
||||
{ $slot "font" }
|
||||
{ "a " { $link font } "." }
|
||||
}
|
||||
{
|
||||
{ $slot "selection-color" }
|
||||
{ "a " { $link color } "." }
|
||||
}
|
||||
{
|
||||
{ $slot "min-rows" }
|
||||
{ "The preferred minimum number of visible rows when the gadget is contained in a viewport." }
|
||||
}
|
||||
{
|
||||
{ $slot "max-rows" }
|
||||
{ "The preferred maximum number of visible rows when the gadget is cotnained in a viewport." }
|
||||
}
|
||||
{
|
||||
{ $slot "min-cols" }
|
||||
{ "The preferred minimum number of visible columns when the gadget is contained in a viewport." }
|
||||
}
|
||||
{
|
||||
{ $slot "max-cols" }
|
||||
{ "The preferred maximum number of visible columns when the gadget is contained in a viewport." }
|
||||
}
|
||||
}
|
||||
} ;
|
||||
|
||||
HELP: pref-viewport-dim*
|
||||
{ $values { "gadget" line-gadget } { "dim" array } }
|
||||
{ $description "Calculates the preferred viewport dimenstions of the line gadget." }
|
||||
{ $see-also pref-viewport-dim } ;
|
||||
|
||||
ARTICLE: "ui.gadgets.line-support" "Gadget line support"
|
||||
"The " { $vocab-link "ui.gadgets.line-support" } " vocabulary provides common code shared by gadgets which display a sequence of lines of text. Currently, the two gadgets that use it are " { $link "ui.gadgets.editors" } " and " { $link "ui.gadgets.tables" } "."
|
||||
|
|
|
@ -1,4 +1,27 @@
|
|||
! Copyright (C) 2009 Slava Pestov.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: tools.test ui.gadgets.line-support ;
|
||||
USING: accessors arrays kernel tools.test ui.gadgets.editors
|
||||
ui.gadgets.line-support ui.gadgets.line-support.private ui.text ;
|
||||
IN: ui.gadgets.line-support.tests
|
||||
|
||||
! line-gadget-height
|
||||
{ t } [
|
||||
{ 0 0 } <multiline-editor>
|
||||
[ 1 >>min-rows line-gadget-height ]
|
||||
[ line-height ] bi =
|
||||
] unit-test
|
||||
|
||||
! line-gadget-width
|
||||
{ t } [
|
||||
{ 0 0 } <multiline-editor>
|
||||
[ 1 >>min-cols line-gadget-width ]
|
||||
[ font>> em ] bi =
|
||||
] unit-test
|
||||
|
||||
! pref-viewport-dim*
|
||||
{ t } [
|
||||
<multiline-editor>
|
||||
[ 1 >>min-rows 1 >>min-cols pref-viewport-dim* ] [
|
||||
[ font>> "m" text-width ] [ line-height ] bi 2array
|
||||
] bi =
|
||||
] unit-test
|
||||
|
|
|
@ -8,15 +8,14 @@ IN: ui.gadgets.line-support
|
|||
|
||||
! Some code shared by table and editor gadgets
|
||||
TUPLE: line-gadget < gadget
|
||||
font selection-color
|
||||
min-rows max-rows
|
||||
min-cols max-cols
|
||||
line-leading line-height
|
||||
pref-viewport-dim ;
|
||||
font selection-color
|
||||
min-rows max-rows
|
||||
min-cols max-cols
|
||||
line-leading line-height
|
||||
pref-viewport-dim ;
|
||||
|
||||
: new-line-gadget ( class -- gadget )
|
||||
new
|
||||
selection-color >>selection-color ;
|
||||
new selection-color >>selection-color ;
|
||||
|
||||
GENERIC: line-leading* ( gadget -- n )
|
||||
|
||||
|
|
Loading…
Reference in New Issue