Skip to content
Permalink
Browse files

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.
  • Loading branch information
mrjbq7 committed Jan 29, 2020
1 parent a62ea78 commit 94cbe2b4796fd97d99e8ab32244f1fd3f7362721
Showing with 11 additions and 4 deletions.
  1. +11 −4 basis/ui/gadgets/panes/panes.factor
@@ -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 ;

0 comments on commit 94cbe2b

Please sign in to comment.
You can’t perform that action at this time.