[Gambas-user] Maximum character number in console line
Gianluigi
bagonergi at gmail.com
Sat Aug 29 16:13:18 CEST 2020
Il giorno ven 28 ago 2020 alle ore 19:23 <vuott at tiscali.it> ha scritto:
> Hello,
> is it possible to know how many characters a single line contains easily
> in the IDE console, without it continuing on the next line due to an excess
> of printed characters?
>
>
Hi,
I thought that collecting data from the IDE settings might work, but here
it doesn't.
It looks like panProject.width is underestimated.
'--------------------------------------------------------------------------------------
Dim sPrint As String = "Lorem ipsum dolor sit amet, consectetuer adipiscing
elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna
aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci
tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo
consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit
esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at
vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum
zzril delenit augue duis dolore te feugait nulla facilisi. Nam liber tempor
cum soluta nobis eleifend option congue nihil imperdiet doming id quod
mazim placerat facer possim assum. Nam liber tempor cum soluta nobis
eleifend option congue nihil imperdiet doming id quod mazim placerat facer
possim assum."
Dim sConf, sFont As String
Dim aConf As String[]
Dim i, iWidth, iProject As Integer
Dim hFont As Font
If Exist("~/.config/gambas3/gambas3.conf") Then
sConf = File.Load("~/.config/gambas3/gambas3.conf")
If sConf Then
aConf = Split(sConf, "\n", Null, True)
i = aConf.Find("[FMain]")
If i <> -1 Then
iWidth = Val(Scan(aConf[i + 1], "*,*,*,*,*")[2])
'Stop
If Scan(aConf[i + 4], "*[[]*,*")[1] = "False" Then
If Scan(aConf[i + 2], "*[[]*,*")[1] = "False" Then
iProject = Val(Scan(aConf[i + 2], "*[[]*,*,*")[2])
iWidth -= iProject
Endif
Endif
Print iWidth
Endif
i = aConf.Find("FixedFont*", gb.Like)
If i <> -1 Then
sFont = UnQuote(Scan(aConf[i], "*=*")[1])
hFont = Font[sFont]
Endif
Endif
Endif
aConf = RowsPrint(sPrint, iWidth, hFont)
For Each sConf In aConf
Print sConf
Print
Next
End
Private Function RowsPrint(value As String, iWidth As Integer, hFont As
Font) As String[]
Dim i As Integer
Dim ss As String[]
Dim rr As New String[]
Dim sRow As String
If hFont.TextWidth(value) < iWidth Then
rr.Push(value)
Return rr
Endif
ss = Split(value, " ")
For Each s As String In ss
sRow &= " " & s
If hFont.TextWidth(sRow) > iWidth Then
sRow = Replace(sRow, s, "")
rr.Push(sRow)
sRow = s
Endif
Next
Return rr
End
'-----------------------------------------------------------------------------------------------
Regards
Gianluigi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20200829/e4744563/attachment.htm>
More information about the User
mailing list