Skip to content

Commit

Permalink
ui.gadgets.panes: fix for big strings on windows and linux.
Browse files Browse the repository at this point in the history
Using 3639 grapheme length, which is win32 limit. Maybe cairo supports
4681 graphemes, but use the lower limit for now.
  • Loading branch information
mrjbq7 committed Jan 29, 2020
1 parent a62ea78 commit 94cbe2b
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions basis/ui/gadgets/panes/panes.factor
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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 ;

Expand Down

0 comments on commit 94cbe2b

Please sign in to comment.