inspector improvements
parent
7cc598f4eb
commit
764cf6d314
|
@ -4,22 +4,66 @@ IN: inspector
|
||||||
USING: arrays generic hashtables io kernel kernel-internals
|
USING: arrays generic hashtables io kernel kernel-internals
|
||||||
lists math prettyprint sequences strings vectors words ;
|
lists math prettyprint sequences strings vectors words ;
|
||||||
|
|
||||||
|
GENERIC: summary ( object -- string )
|
||||||
|
|
||||||
|
: sign-string ( n -- string )
|
||||||
|
0 > "a positive " "a negative " ? ;
|
||||||
|
|
||||||
|
M: integer summary
|
||||||
|
dup sign-string over 2 mod 0 = "even " "odd " ?
|
||||||
|
rot class word-name append3 ;
|
||||||
|
|
||||||
|
M: real summary
|
||||||
|
dup sign-string swap class word-name append ;
|
||||||
|
|
||||||
|
: quadrant ( z -- n )
|
||||||
|
>rect >r 0 >= 2 0 ? r> 0 >= 1 0 ? + ;
|
||||||
|
|
||||||
|
M: complex summary
|
||||||
|
"a complex number in the "
|
||||||
|
swap quadrant { "first" "second" "third" "fourth" } nth
|
||||||
|
" quadrant" append3 ;
|
||||||
|
|
||||||
GENERIC: sheet ( obj -- sheet )
|
GENERIC: sheet ( obj -- sheet )
|
||||||
|
|
||||||
|
M: object summary
|
||||||
|
"an instance of the " swap class word-name " class" append3 ;
|
||||||
|
|
||||||
M: object sheet ( obj -- sheet )
|
M: object sheet ( obj -- sheet )
|
||||||
dup class "slots" word-prop
|
dup class "slots" word-prop
|
||||||
dup [ second ] map -rot
|
dup [ second ] map -rot
|
||||||
[ first slot ] map-with
|
[ first slot ] map-with
|
||||||
2array ;
|
2array ;
|
||||||
|
|
||||||
|
M: sequence summary
|
||||||
|
dup length 1 = [
|
||||||
|
drop "a sequence of 1 element"
|
||||||
|
] [
|
||||||
|
"a sequence of " swap length number>string
|
||||||
|
" elements" append3
|
||||||
|
] if ;
|
||||||
|
|
||||||
M: list sheet 1array ;
|
M: list sheet 1array ;
|
||||||
|
|
||||||
M: vector sheet 1array ;
|
M: vector sheet 1array ;
|
||||||
|
|
||||||
M: array sheet 1array ;
|
M: array sheet 1array ;
|
||||||
|
|
||||||
|
M: hashtable summary
|
||||||
|
"a hashtable storing " swap hash-size number>string
|
||||||
|
" keys" append3 ;
|
||||||
|
|
||||||
M: hashtable sheet dup hash-keys swap hash-values 2array ;
|
M: hashtable sheet dup hash-keys swap hash-values 2array ;
|
||||||
|
|
||||||
|
M: word summary ( word -- )
|
||||||
|
dup word-vocabulary [
|
||||||
|
dup interned?
|
||||||
|
"a word in the " "a word orphaned from the " ?
|
||||||
|
swap word-vocabulary " vocabulary" append3
|
||||||
|
] [
|
||||||
|
drop "a uniquely generated symbol"
|
||||||
|
] if ;
|
||||||
|
|
||||||
: format-column ( list ? -- list )
|
: format-column ( list ? -- list )
|
||||||
>r [ unparse-short ] map
|
>r [ unparse-short ] map
|
||||||
r> [
|
r> [
|
||||||
|
@ -39,7 +83,7 @@ DEFER: describe
|
||||||
dup format-sheet swap peek
|
dup format-sheet swap peek
|
||||||
[ dup [ describe ] curry write-outliner ] 2each ;
|
[ dup [ describe ] curry write-outliner ] 2each ;
|
||||||
|
|
||||||
: describe ( object -- ) sheet sheet. ;
|
: describe ( object -- ) dup summary print sheet sheet. ;
|
||||||
|
|
||||||
: word. ( word -- )
|
: word. ( word -- )
|
||||||
dup word-name swap dup [ see ] curry write-outliner ;
|
dup word-name swap dup [ see ] curry write-outliner ;
|
||||||
|
|
|
@ -5,31 +5,6 @@ USING: arrays generic io kernel listener memory namespaces
|
||||||
prettyprint sequences words ;
|
prettyprint sequences words ;
|
||||||
|
|
||||||
! Interactive inspector
|
! Interactive inspector
|
||||||
GENERIC: extra-banner ( obj -- )
|
|
||||||
|
|
||||||
M: word extra-banner ( word -- )
|
|
||||||
dup word-vocabulary [
|
|
||||||
dup interned? [
|
|
||||||
"This word is located in the " write
|
|
||||||
] [
|
|
||||||
"This is an orphan not part of the dictionary." print
|
|
||||||
"It claims to belong to the " write
|
|
||||||
] if
|
|
||||||
word-vocabulary pprint " vocabulary." print
|
|
||||||
] [
|
|
||||||
drop
|
|
||||||
"The word is a uniquely generated symbol." print
|
|
||||||
] if ;
|
|
||||||
|
|
||||||
M: object extra-banner ( obj -- ) drop ;
|
|
||||||
|
|
||||||
: inspect-banner ( obj -- )
|
|
||||||
"You are looking at an instance of the " write dup class pprint
|
|
||||||
" class:" print
|
|
||||||
" " write dup pprint-short terpri
|
|
||||||
"It takes up " write dup size pprint " bytes of memory." print
|
|
||||||
extra-banner ;
|
|
||||||
|
|
||||||
SYMBOL: inspector-slots
|
SYMBOL: inspector-slots
|
||||||
|
|
||||||
: sheet-numbers ( sheet -- sheet )
|
: sheet-numbers ( sheet -- sheet )
|
||||||
|
@ -42,7 +17,7 @@ SYMBOL: inspector-stack
|
||||||
|
|
||||||
: (inspect) ( obj -- )
|
: (inspect) ( obj -- )
|
||||||
dup inspector-stack get push
|
dup inspector-stack get push
|
||||||
dup inspect-banner
|
dup summary print
|
||||||
sheet sheet-numbers sheet. ;
|
sheet sheet-numbers sheet. ;
|
||||||
|
|
||||||
: inspector-help ( -- )
|
: inspector-help ( -- )
|
||||||
|
|
|
@ -72,7 +72,7 @@ TUPLE: editor line caret ;
|
||||||
dup screen-loc swap editor-caret rect-extent nip v+ ;
|
dup screen-loc swap editor-caret rect-extent nip v+ ;
|
||||||
|
|
||||||
: <completion-item> ( completion editor -- menu-item )
|
: <completion-item> ( completion editor -- menu-item )
|
||||||
dupd [ [ complete ] with-editor ] curry curry cons ;
|
dupd [ [ complete ] with-editor drop ] curry curry cons ;
|
||||||
|
|
||||||
: <completion-menu> ( editor completions -- menu )
|
: <completion-menu> ( editor completions -- menu )
|
||||||
[ swap <completion-item> ] map-with <menu> ;
|
[ swap <completion-item> ] map-with <menu> ;
|
||||||
|
|
|
@ -5,13 +5,13 @@ USING: kernel parser sequences io ;
|
||||||
"/library/ui/hierarchy.factor"
|
"/library/ui/hierarchy.factor"
|
||||||
"/library/ui/paint.factor"
|
"/library/ui/paint.factor"
|
||||||
"/library/ui/theme.factor"
|
"/library/ui/theme.factor"
|
||||||
|
"/library/ui/world.factor"
|
||||||
|
"/library/ui/gestures.factor"
|
||||||
|
"/library/ui/hand.factor"
|
||||||
"/library/ui/fonts.factor"
|
"/library/ui/fonts.factor"
|
||||||
"/library/ui/text.factor"
|
"/library/ui/text.factor"
|
||||||
"/library/ui/gestures.factor"
|
|
||||||
"/library/ui/borders.factor"
|
"/library/ui/borders.factor"
|
||||||
"/library/ui/frames.factor"
|
"/library/ui/frames.factor"
|
||||||
"/library/ui/world.factor"
|
|
||||||
"/library/ui/hand.factor"
|
|
||||||
"/library/ui/labels.factor"
|
"/library/ui/labels.factor"
|
||||||
"/library/ui/buttons.factor"
|
"/library/ui/buttons.factor"
|
||||||
"/library/ui/line-editor.factor"
|
"/library/ui/line-editor.factor"
|
||||||
|
|
|
@ -50,7 +50,7 @@ DEFER: handle-event
|
||||||
|
|
||||||
: world-step ( -- ? )
|
: world-step ( -- ? )
|
||||||
world get dup world-invalid >r layout-world r>
|
world get dup world-invalid >r layout-world r>
|
||||||
[ dup world-hand update-hand draw-world ] [ drop ] if ;
|
[ dup world-hand update-hand dup draw-world ] when drop ;
|
||||||
|
|
||||||
: next-event ( -- event ? ) <event> dup SDL_PollEvent ;
|
: next-event ( -- event ? ) <event> dup SDL_PollEvent ;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue