#module
#deffunc wordchk val, int
mref txt, 24 : mref ichi, 1
mref stt, 64
peek chk, txt, ichi
if chk = 0 : stt = -1 : return // 範囲外
if (chk > 128 & (chk < 160)) | (chk > 223) : stt = 1 : else : stt = 0 // 1byte=0 2byte=1
return
#deffunc retmes str, int
mref string, 32 : mref w, 1
mref bmscr, 67
sdim data, 4096
data = string
cx = csrx : cy = csry
x = cx : y = cy
strlen len, data
repeat len
// 改行
strmid tmp, data, cnt
if tmp = "\n" {
x = cx : y += bmscr.32 // フォント高さ分下の位置にずらす
continue cnt + 2
}
// その他の文字
wordchk data, cnt
strmid tmp, data, cnt, stat + 1
pos 0, dispy : mes tmp
ginfo 7
if x - cx + prmx >= w : x = cx : y += prmy // 指定幅を超えたら改行
pos x, y : mes tmp
x += prmx
if stat + 1 = 2 : continue cnt + 2 //全角文字なら、次回チェック位置を2バイト先に進める
loop
pos cx, y + ginfo_mesy
return
#global
haba = 200
color 200, 200, 200 : boxf 200, 50, 200 + haba // 表示領域を色付け
color
pos 200, 50 : retmes "自動的に折り返すような、少し長めのtextを表示してみるtest。", haba
stop
|