ui.gadgets.panes: fix for big strings on windows and linux.

Using 3639 grapheme length, which is win32 limit. Maybe cairo supports
4681 graphemes, but use the lower limit for now.
flac
John Benediktsson 2020-01-28 16:16:09 -08:00 committed by Steve Ayerhart
parent 42b6fbec70
commit 200465c121
No known key found for this signature in database
GPG Key ID: 5BFD39C5359E967D
1 changed files with 11 additions and 4 deletions

View File

@ -1,7 +1,7 @@
! Copyright (C) 2005, 2010 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors assocs classes combinators destructors
documents.private fonts fry io io.styles kernel locals
documents.private fonts fry io io.styles kernel locals math
math.rectangles math.vectors memoize models namespaces sequences
sorting splitting strings ui.baseline-alignment ui.clipboards
ui.gadgets ui.gadgets.borders ui.gadgets.grid-lines
@ -10,7 +10,7 @@ ui.gadgets.labels ui.gadgets.menus ui.gadgets.packs
ui.gadgets.paragraphs ui.gadgets.presentations
ui.gadgets.private ui.gadgets.scrollers ui.gadgets.tracks
ui.gestures ui.images ui.pens.solid ui.render ui.theme
ui.traverse ;
ui.traverse unicode ;
FROM: io.styles => foreground background ;
FROM: ui.gadgets.wrappers => <wrapper> ;
IN: ui.gadgets.panes
@ -117,11 +117,18 @@ M: pane-stream stream-nl
M: pane-stream stream-write1
[ current>> stream-write1 ] do-pane-stream ;
: split-pane ( str quot: ( str -- ) -- )
'[
dup length 3639 >
[ 3639 over last-grapheme-from cut-slice ] [ f ] if
swap "" like split-lines @ dup
] loop drop ; inline
M: pane-stream stream-write
[ [ split-lines ] dip pane-write ] do-pane-stream ;
[ '[ _ pane-write ] split-pane ] do-pane-stream ;
M: pane-stream stream-format
[ [ split-lines ] 2dip pane-format ] do-pane-stream ;
[ '[ _ _ pane-format ] split-pane ] do-pane-stream ;
M: pane-stream dispose drop ;