ui.tools.inspector: string inspection shows characters.

freebsd-work
John Benediktsson 2018-12-30 12:50:49 -08:00
parent 1e2bb358c2
commit d9df9fc3cc
1 changed files with 29 additions and 6 deletions

View File

@ -1,13 +1,14 @@
! Copyright (C) 2006, 2009 Slava Pestov. ! Copyright (C) 2006, 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: accessors arrays assocs classes combinators fonts fry USING: accessors arrays assocs classes combinators fonts
hashtables inspector io io.styles kernel math.vectors mirrors formatting fry hashtables inspector io io.styles kernel math
models models.arrow namespaces prettyprint sequences sorting ui math.parser math.vectors mirrors models models.arrow namespaces
ui.commands ui.gadgets ui.gadgets.labeled ui.gadgets.panes prettyprint sequences sorting strings ui ui.commands ui.gadgets
ui.gadgets.scrollers ui.gadgets.status-bar ui.gadgets.tables ui.gadgets.labeled ui.gadgets.panes ui.gadgets.scrollers
ui.gadgets.status-bar ui.gadgets.tables
ui.gadgets.tables.private ui.gadgets.toolbar ui.gadgets.tracks ui.gadgets.tables.private ui.gadgets.toolbar ui.gadgets.tracks
ui.gestures ui.operations ui.theme ui.tools.browser ui.gestures ui.operations ui.theme ui.tools.browser
ui.tools.common ui.tools.inspector.slots ; ui.tools.common ui.tools.inspector.slots unicode ;
IN: ui.tools.inspector IN: ui.tools.inspector
@ -68,6 +69,28 @@ GENERIC: make-slot-descriptions ( obj -- seq )
M: object make-slot-descriptions M: object make-slot-descriptions
make-mirror [ <slot-description> ] { } assoc>map ; make-mirror [ <slot-description> ] { } assoc>map ;
M: string make-slot-descriptions
[
swap [ dup number>string ] dip dup
dup printable? [ 1string ] [
dup 0xff <= [
H{
{ CHAR: \a "\\a" }
{ CHAR: \b "\\b" }
{ CHAR: \e "\\e" }
{ CHAR: \f "\\f" }
{ CHAR: \n "\\n" }
{ CHAR: \r "\\r" }
{ CHAR: \t "\\t" }
{ CHAR: \v "\\v" }
{ CHAR: \0 "\\0" }
} ?at [ "\\x%02x" sprintf ] unless
] [
"\\u{%x}" sprintf
] if
] if slot-description boa
] map-index ;
M: hashtable make-slot-descriptions M: hashtable make-slot-descriptions
call-next-method [ key-string>> ] sort-with ; call-next-method [ key-string>> ] sort-with ;