'On Error GoTo BadExit
'$ExeIcon:'qXedlogo.ico'
Const KeyboardF10
= 17408 Const KeyboardF11
= 34048 Const KeyboardF12
= 34304 Const KeyboardHome
= 18176 Const KeyboardUpArrow
= 18432 Const KeyboardPgUp
= 18688 Const KeyboardLeftArrow
= 19200 Const KeyboardRightArrow
= 19712 Const KeyboardEnd
= 20224 Const KeyboardDnArrow
= 20480 Const KeyboardPgDn
= 20736 Const KeyboardIns
= 20992 Const KeyboardDel
= 21248 Const KeyboardRightShift
= 100304 Const KeyboardLeftShift
= 100304 Const KeyboardRightCtrl
= 100305 Const KeyboardLeftCtrl
= 100306 Const KeyboardRightAlt
= 100307 Const KeyboardLeftAlt
= 100308
ColorTheme = 1
scrHand
= _NewImage(1 * 80, 1 * 24, 0) ' 8, 16, 0
' Define fundamental structures.
ChainLimit = 1 * 10 ^ 6
BOC = 0
EOC = ChainLimit
' Define text window properties.
' Set window properties.
' Set display state.
HScroll = 1
TextWrapping = 1
TextFormatting = -1
InsertKey = -1
' Initiate text inside window.
' Auxiliary 2D text grid.
GOLSwitch = -1
' Create memory space for string.
' File I/O.
Highlight = "qXed"
' Load text file into memory if applicable, use example string if not.
' Prime main loop.
Call CalibrateCursor
(ID1
) Call CalibrateCursor
(ID2
)
' Main loop.
oldHand = scrHand
ReDim LineAsMapped
(TextHeight
) ReDim AuxGrid
(TextWidth
, TextHeight
, 2) Call CalibrateCursor
(ID1
) Call CalibrateCursor
(ID2
)
Call CalibrateCursor
(ID1
) Call CalibrateCursor
(ID2
)
BadExit:
TheERROR
= RequestCode
+ Str$(x
) + Str$(y
) + " " + txt
'_PrintString (x * 8, y * 16), txt
WindowWidth
= _Width / 1 - 0 * 1 '8, 1 WindowHeight
= _Height / 1 - 0 * 1 '16, 1 TopIndent = 1 '0
LeftIndent = 1 '0
TextHeight = WindowHeight - (1 + TopIndent)
TextWidth = WindowWidth - (1 + LeftIndent)
BackgroundColor = 0
Cursor1Back = 3
Cursor2Back = 7
CursorBlinkFace = 16 + 6
CursorMixedBack = 7
CursorStdFace = 0
ScrollbarBack = 7
ScrollbarBase = 8
ScrollbarFace = 1
StatusBarColor = 3
TextBackColor = 1
TextFaceColor = 11
TextHighBack = 2
TextHighFace = 1
TitleColor = 3
WireColor = 8
oldHand = scrHand
q = ""
q = q + r + CR
j = i - 1
q = ""
'q = q + "Working file is:" + CR + Chr$(9) + WorkingFileName + CR + CR + "Press F6 to save." + CR
q = q + "Welcome to qXed" + CR
q = q + "... a hackable text editor" + CR
q = q + "... now boosted with Pipecom!" + CR
q = q + CR
q = q + "Use Pipecom by starting a line with a bracket '>'." + CR
q = q + "Press Ctrl+Enter to evaluate that line." + CR
q = q + CR
q = q + "For example, place the cursor after 'dir', and press Ctrl+Enter:" + CR
q = q + "(Or, replace 'dir' with 'ls' for Linux.)" + CR
q = q + CR
q = q + ">dir"
q = q + CR
q = q + CR
q = q + "This program has a steeper learning curve than Notepad, so beware." + CR
q = q + CR
q = q + "Press F3 to change search term." + CR
q = q + "Press F10 to toggle high contrast mode." + CR
q = q + "Press F11 to see break returns and whitespace." + CR
q = q + "Press F12 to cycle text wrapping modes." + CR
' Create character list.
TheChain(k).Identity = 0
ID2 = Assimilate&(q, BOC, EOC)
'StartIndex = 1
ID1 = StartIndex
GOLSwitch = -1
' Maps a raw string of text between a set of identities.
previousID = st
nextID = NextOpenIdentity&(1)
previousID = TheChain(st).Lagger
nextID = NextOpenIdentity&(st)
n0 = nextID
b = a
c = " "
b = " " + b
c = CR
j = nextID
TheChain(j).Identity = j
TheChain(j).Content = c
TheChain(j).Lagger = previousID
If (previousID
<> BOC
) Then TheChain
(previousID
).Pointer
= j
previousID = j
nextID = NextOpenIdentity&(j)
TheChain(j).Pointer = en
TheChain(en).Lagger = j
TheChain(j).Pointer = st
TheChain(st).Lagger = j
StartIndex = n0
StartIndex = BackBreak&(StartIndex)
Assimilate& = n0
InsertString& = Assimilate&(a, st, TheChain(st).Pointer)
' Returns the address that is b jumps ahead of address a.
i = a
j = 0
k = 0
k = k + 1
j = i
i = TheChain(j).Pointer
'''
j = StartIndex
'''
NthP& = j
' Returns the address that is b jumps behind address a.
i = a
k = 0
k = k + 1
j = i
i = TheChain(j).Lagger
NthL& = j
Print "Chain limit exceeded." NextOpenIdentity& = j
' Function for scrolling up.
j = a
lastBreak = 0
c = ""
k = TheChain(j).Lagger
lastBreak = j
j = k
d = TheChain(j).Content
c = d + c
lastBreak = j
If (lastBreak
<> 0) Then j
= lastBreak
BackBreak& = j
j = a
lastBreak = 0
c = ""
k = TheChain(j).Lagger
lastBreak = j
j = k
d = TheChain(j).Content
c = d + c
'If ((d = " ") Or (d = CR)) Then
lastBreak = TheChain(j).Pointer
'lastBreak = j
'If (d = CR) Then
If (lastBreak
<> 0) Then j
= lastBreak
BackBreak2& = j
' Inserts a single cell before address a in the chain.
j = NextOpenIdentity&(a)
lg = TheChain(a).Lagger
TheChain(j).Identity = j
TheChain(j).Pointer = a
TheChain(j).Lagger = lg
TheChain(j).Content = b
TheChain(a).Lagger = j
StartIndex = j
TheChain(lg).Pointer = j
ID1 = NthP&(ID1, 2)
If (Cursor1.X
- LeftIndent
= TextWidth
) Then HScroll = HScroll + 1
' Inserts a single cell after address a in the chain.
j = NextOpenIdentity&(a)
p = TheChain(a).Pointer
TheChain(j).Identity = j
TheChain(j).Pointer = p
TheChain(j).Lagger = a
TheChain(j).Content = b
TheChain(a).Pointer = j
TheChain(p).Lagger = j
InsertAfter& = j
LinearCount& = LinearCountProto&(a, b, ChainLimit + 1)
' Returns number of links between two addresses, with exit condition.
i = a
k = 0
k = k + 1
j = i
i = TheChain(j).Pointer
LinearCountProto& = k
' Returns the linear content for all address between a and b, inclusive.
TheReturn = ""
TheReturn = TheChain(a).Content
j = a
c = TheChain(j).Content
TheReturn = TheReturn + c
k = TheChain(j).Pointer
j = k
Projection$ = TheReturn
brsymbol = "~"
brsymbol = " "
j = StartIndex
i = 1
q = ""
d = ""
Do ' Begin with any left-over text from previous iteration. q = d
d = ""
'''
k1 = NthP&(j, r)
If (TheChain
(k1
).Pointer
= EOC
) Then k1
= EOC
k1 = NthP&(j, r)
If (TheChain
(k1
).Pointer
= EOC
) Then k1
= EOC
k1 = EOC
'''
k2 = j
k2 = TheChain(k2).Pointer
c1 = LinearCount&(j, k1)
c1 = LinearCountProto&(j, k1, TextWidth * TextHeight)
c2 = LinearCount&(j, k2)
If (c2
= 0) Then ' Line has one character (except in Fluid mode). k = k2
If (TheChain
(j
).Content
= CR
) Then q = q + brsymbol
q = q + TheChain(j).Content
j = NthP&(k, 2)
If (c1
= c2
) Then ' End of line. (Possible end of chain?) '''
k = k1
If (TheChain
(k
).Content
= CR
) Then q = q + Projection$(j, TheChain(k).Lagger) + brsymbol
q = q + Projection$(j, k)
j = NthP&(k, 2)
k = TheChain(k1).Lagger
If (TheChain
(k
).Content
= CR
) Then q = q + Projection$(j, TheChain(k).Lagger) + brsymbol
q = q + Projection$(j, k)
j = NthP&(k, 2)
k = k1 ' == EOC
q = q + Projection$(j, k)
j = NthP&(k, 2)
'''
If (c1
< c2
) Then ' Width limit case (not always maximum). k = k1
q = q + Projection$(j, k)
j = NthP&(k, 2)
If (c1
> c2
) Then ' Break return somewhere in line (not first). k = k2
n = TheChain(k).Pointer
''' Clean this up if compelled.
q = q + Projection$(j, TheChain(k).Lagger) + brsymbol
j = n
If (TheChain
(k
).Content
= CR
) Then q = q + Projection$(j, TheChain(k).Lagger) + brsymbol
q = q + Projection$(j, k)
'''
If (TextWrapping
= 1) Then ' Wrap text at first breaking character from right, send remainder to next line. If ((c
= " ") Or (c
= "-") Or (c
= ".") Or (c
= "_") Or (c
= brsymbol
)) Then d = c + d
If (m
= 0) Then ' Text is too long for line and contains no wrapping characters. d = ""
LineAsMapped(i) = q
i = i + 1
LineAsMapped(i) = d
i = i + 1
'IF (d <> "") THEN BEEP
'IF (d <> "") THEN BEEP
VisibleLines = i - 1
z = InsertString&(b, a)
' Place Cursor under ID on rendered line.
s = StartIndex
If ((TextWrapping
= 2) And (HScroll
> 1)) Then s
= NthP&
(s
, HScroll
) c = LinearCount&(s, a)
k = 0
i = -1
For j
= 1 To VisibleLines
k = k + n
i = c - k + 1
If (i
>= 1 + Len(LineAsMapped
(j
))) Then ''' Clean this line up a little. i = 1
j = j + 1
Cursor1.X = LeftIndent + i
Cursor1.Y = TopIndent + j
Cursor2.X = LeftIndent + i
Cursor2.Y = TopIndent + j
' Find identity under a mapped location.
relx = a - LeftIndent
rely = b - TopIndent
t
= t
+ Len(LineAsMapped
(k
)) t = t + relx
FindID% = t
ID1 = NthP&(StartIndex, FindID%(Cursor1.X, Cursor1.Y) + (HScroll - 1))
ID2 = NthP&(StartIndex, FindID%(Cursor2.X, Cursor2.Y) + (HScroll - 1))
Color BackgroundColor
, BackgroundColor
Call PrintStatusBars
(VerticalScrollbar#
)
Color WireColor
, BackgroundColor
Call StringPrint
("PrintWires", WindowWidth
, WindowHeight
- 1, Chr$(217)) Call StringPrint
("PrintWires", LeftIndent
, WindowHeight
- 1, Chr$(192)) For i
= 1 + TopIndent
To WindowHeight
- 2 Call StringPrint
("PrintWires", LeftIndent
, i
, Chr$(179)) Call StringPrint
("PrintWires", LeftIndent
, TopIndent
, Chr$(218)) Call StringPrint
("PrintWires", WindowWidth
, TopIndent
, Chr$(191)) For i
= 1 + LeftIndent
To WindowWidth
- 1 Call StringPrint
("PrintWires", i
, TopIndent
, Chr$(196))
Color ScrollbarBase
, BackgroundColor
For i
= (1 + LeftIndent
) To (WindowWidth
- 1) Call StringPrint
("HorizontalScrollbar1", i
, WindowHeight
- 1, Chr$(177)) p = LinearCount&(NthP&(StartIndex, FindID%(LeftIndent + 1, Cursor1.Y)), ID1)
q
= Len(LineAsMapped
(Cursor1.Y
- TopIndent
)) r = p / (q - 1)
r = 0
s = r * (WindowWidth - LeftIndent - 2)
i
= (1 + LeftIndent
) + Int(s
) Color ScrollbarFace
, ScrollbarBack
Call StringPrint
("HorizontalScrollbar2", i
, WindowHeight
- 1, "^")
Color ScrollbarBase
, BackgroundColor
For i
= (1 + TopIndent
) To (WindowHeight
- 2) Call StringPrint
("VerticalScrollbar#", WindowWidth
, i
, Chr$(177)) p = LinearCount&(ID1, NthP&(ID1, ChainLimit + 1))
q = LinearCount&(NthL&(ID1, ChainLimit + 1), NthP&(ID1, ChainLimit + 1))
r = 1
s = r * (WindowHeight - TopIndent - 3)
i
= (1 + TopIndent
) + Int(s
) Color ScrollbarFace
, ScrollbarBack
Call StringPrint
("VerticalScrollbar#", WindowWidth
, i
, "<") VerticalScrollbar# = r
c = ""
If (TextFormatting
= 1) Then c
= "[Fmt] " + c
Case 0: c
= c
+ "[Square]" + " " Case 1: c
= c
+ "[Fluid]" + " " Case 2: c
= c
+ "[None]" + " " Color StatusBarColor
, BackgroundColor
Call StringPrint
("PrintStatusBars", WindowWidth
- Len(c
), TopIndent
, c
) c = ""
If (InsertKey
= 1) Then c
= "[Ins]" + c
Color StatusBarColor
, BackgroundColor
Call StringPrint
("PrintStatusBars", WindowWidth
- Len(c
), WindowHeight
, c
)
c = TheChain(ID1).Content
d = TheChain(ID2).Content
c0 = c
d0 = d
If (c
= LF
) Then c
= "@" ' Should never happen. If (d
= LF
) Then d
= "@" ' Should never happen. If (c
= Spacebar
) Then c
= "_" If (d
= Spacebar
) Then d
= "_" Color CursorStdFace
, Cursor1Back
Call StringPrint
("PrintCursorInfo", 1 + LeftIndent
, WindowHeight
, c
) 'IF (LinearCount&(StartIndex, ID2) > LinearCount&(StartIndex, ID1)) THEN
Color CursorStdFace
, Cursor2Back
Call StringPrint
("PrintCursorInfo", 2 + LeftIndent
+ Len(c
), WindowHeight
, d
) 'END IF
Color TitleColor
, BackgroundColor
Call StringPrint
("PrintCursorInfo", 1 + LeftIndent
, TopIndent
, "[qXed]" + Debug$
)
For i
= 1 To VisibleLines
c = LineAsMapped(i)
c = c + "_"
d
= Mid$(c
, HScroll
, TextWidth
)
k0 = 0
k00 = k0 + k - 1
Color TextFaceColor
, TextBackColor
Call StringPrint
("PrintMainText", k0
+ LeftIndent
+ 1, TopIndent
+ i
, Left$(d
, k
- 1)) Color TextHighFace
, TextHighBack
Call StringPrint
("PrintMainText", k0
+ k
- 1 + LeftIndent
+ 1, TopIndent
+ i
, Mid$(d
, k
, Len(Highlight
))) k0
= k0
+ k
- 1 + Len(Highlight
) Color TextFaceColor
, TextBackColor
Call StringPrint
("PrintMainText", k00
+ Len(Highlight
) + LeftIndent
+ 1, TopIndent
+ i
, d
) Color TextFaceColor
, TextBackColor
Call StringPrint
("PrintMainText", LeftIndent
+ 1, TopIndent
+ i
, d
)
If ((Cursor1.X
> 0 And Cursor1.X
< WindowWidth
) And ((Cursor1.Y
> 0) And (Cursor1.Y
< WindowHeight
))) Then c = TheChain(ID1).Content
If ((Cursor1.X
= Cursor2.X
) And (Cursor1.Y
= Cursor2.Y
)) Then Color CursorBlinkFace
, CursorMixedBack
Call StringPrint
("PrintCursor1", Cursor1.X
, Cursor1.Y
, c
) Color CursorBlinkFace
, Cursor1Back
Call StringPrint
("PrintCursor1", Cursor1.X
, Cursor1.Y
, c
)
If ((Cursor2.X
> 0 And Cursor2.X
< WindowWidth
) And ((Cursor2.Y
> 0) And (Cursor2.Y
< WindowHeight
))) Then p1 = LinearCount&(StartIndex, ID1)
p2 = LinearCount&(StartIndex, ID2)
pe = LinearCount&(StartIndex, EOC)
If p2
< pe
Then 'IF ((p2 > p1) AND (p2 < pe)) THEN c = TheChain(ID2).Content
Color CursorStdFace
, Cursor2Back
Call StringPrint
("PrintCursor2", Cursor2.X
, Cursor2.Y
, c
)
MH = 0
MW = 0
MT = 0
MW = MT
If (MH1
= -1) Then MH
= MouseButton1%
If (MH2
= -1) Then MH
= MouseButton2%
If (MH3
= -1) Then MH
= MouseButton3%
If (MW
= -1) Then MH
= MouseWheelUp%
If (MW
= 1) Then MH
= MouseWheelDown%
If (KH
= KeyboardEnter
) Or ((KH
>= 32) And (KH
<= 126)) Then Call KeyEnterAlphaNumer
(KH
) 'If (KH = KeyboardF7) Then Call KeyF7
If (KH
= KeyboardLeftArrow
) Then Call KeyLeftArrow
If (KH
= KeyboardRightArrow
) Then Call KeyRightArrow
' Exit sequence
TheReturn = 0
TheReturn = 1
Call CalibrateCursor
(ID1
) Call CalibrateCursor
(ID2
)
' Cursor sync and autoscrolling.
Do While (Cursor1.Y
> TopIndent
+ TextHeight
- 1) StartIndex
= NthP&
(StartIndex
, Len(LineAsMapped
(1)) + 1) Call CalibrateCursor
(ID1
) Call CalibrateCursor
(ID2
) If (TextWrapping
= 2) Then ''' Do While (Cursor1.X
> LeftIndent
+ TextWidth
- 0) HScroll = HScroll + 1
Cursor1.X = Cursor1.X - 1
MH = 0
KH = 0
StateChange% = TheReturn
If ((mx
> LeftIndent
) And (mx
< TextWidth
+ LeftIndent
+ 1) And (my
> TopIndent
) And (my
< TopIndent
+ TextHeight
)) Then If (my
= WindowHeight
- 1) Then MouseButton1% = 1
' This sub does things wrong.
If ((my
> TopIndent
) And (my
< (TopIndent
+ TextHeight
))) Then i = NthL&(ID1, ChainLimit + 1)
j = NthP&(ID1, ChainLimit + 1)
i = i ' clicked at top
i = j ' clicked at bottom
t = LinearCount&(i, j)
f = (my - TopIndent + 1) / (WindowHeight - TopIndent)
r = k / t
i = TheChain(i).Pointer
'i = BackBreak&(i)
StartIndex = i
ID1 = i
If ((mx
> LeftIndent
) And (mx
< (LeftIndent
+ 1 + TextWidth
))) Then j = ID1
i = NthP&(StartIndex, FindID%(LeftIndent + 1, Cursor1.Y))
t
= Len(LineAsMapped
(Cursor1.Y
- TopIndent
)) f = (mx - LeftIndent) / (WindowWidth - LeftIndent)
r = k / t
i = TheChain(i).Pointer
ID1 = i
k = LinearCount&(StartIndex, i) - LinearCount&(StartIndex, j)
If (TextWrapping
= 2) Then HScroll
= HScroll
+ k
If (HScroll
< 1) Then HScroll
= 1
Cursor1.X = mx
k
= LeftIndent
+ Len(LineAsMapped
(my
- TopIndent
)) - (HScroll
- 1) If (Len(LineAsMapped
(my
- TopIndent
)) > TextWidth
) Then HScroll
= 1 + Len(LineAsMapped
(my
- TopIndent
)) - (Cursor1.X
- LeftIndent
) HScroll = 1
Cursor1.X
= LeftIndent
+ Len(LineAsMapped
(my
- TopIndent
)) Cursor1.X = k
Cursor1.Y = my
' Move Cursor2.
If (mx
> LeftIndent
) And (mx
< TextWidth
+ LeftIndent
+ 1) And (my
> TopIndent
) And (my
< TopIndent
+ TextHeight
+ 1) Then Cursor2.X = mx
k
= LeftIndent
+ Len(LineAsMapped
(my
- TopIndent
)) - (HScroll
- 1) Cursor2.X = k
Cursor2.Y = my
MouseButton2% = 1
MouseButton3% = 1
MouseWheelUp% = 1
MouseWheelDown% = 1
q = TheChain(ID1).Lagger
p = TheChain(ID1).Pointer
' Do nothing.
If ((TextWrapping
= 2) And (Cursor1.X
- LeftIndent
= 1)) Then HScroll = HScroll - 1
Call CalibrateCursor
(ID1
) qq = TheChain(q).Lagger
TheChain(ID1).Lagger = qq
TheChain(q).Identity = 0
If (StartIndex
= q
) Then StartIndex
= BackBreak&
(StartIndex
) TheChain(qq).Pointer = ID1
StartIndex = ID1
ID2 = StartIndex
If (LinearCount
(StartIndex
, ID2
) = LinearCount&
(StartIndex
, EOC
)) Then i = -1
i = LinearCount&(StartIndex, ID2) - LinearCount&(StartIndex, ID1)
q = TheChain(ID1).Lagger
p = TheChain(ID1).Pointer
' Never delete the only character.
TheChain(ID1).Content = " "
If (StartIndex
= ID1
) Then StartIndex
= p
TheChain(p).Lagger = q
TheChain(ID1).Identity = 0
TheChain(q).Pointer = p
ID1 = p
StartIndex = p
TheChain(p).Lagger = q
TheChain(ID1).Identity = 0
ID1 = p
If (StartIndex
= ID1
) Then StartIndex
= q
TheChain(ID1).Identity = 0
TheChain(q).Pointer = p
ID1 = q
q = TheChain(ID1).Lagger
p = TheChain(ID1).Pointer
q2 = TheChain(ID2).Lagger
p2 = TheChain(ID2).Pointer
If (StartIndex
= ID1
) Then StartIndex
= p2
Call UnlinkRange
(ID1
, ID2
) ID1 = TheChain(q).Pointer
StartIndex = p2
TheChain(p2).Lagger = q
ID1 = p2
If (StartIndex
= ID1
) Then StartIndex
= q
Call UnlinkRange
(ID1
, q2
) TheChain(ID2).Identity = 0
TheChain(q).Pointer = p2
ID1 = q
StartIndex = ID1 '''
TheChain(ID2).Identity = 0
TheChain(ID1).Content = " "
TheChain(ID1).Lagger = BOC
TheChain(ID1).Pointer = EOC
ID2 = StartIndex
q = TheChain(a).Lagger
u = a
TheChain(u).Identity = 0
p = TheChain(u).Pointer
TheChain(p).Lagger = q
If (q
<> BOC
) Then TheChain
(q
).Pointer
= p
ID2 = ID1
ID2 = StartIndex
z = BackBreak2&(ID1)
a = Projection$(z, TheChain(ID1).Lagger)
a = pipecom_lite$(a)
z = InsertString&(CR + "(" + a + ")" + CR + ">", ID1)
z = InsertString&(CR + "(" + b + ")" + CR + "]", ID1)
z = InsertString&(CR + "(" + "Error" + ")" + CR + "]", ID1)
ID2 = StartIndex
ID2 = StartIndex
ID2 = StartIndex
'''
If ((k
= KeyboardEnter
) And (TextWrapping
= 2)) Then HScroll
= 1 If ((k
= KeyboardEnter
) And (Cursor1.Y
= TextHeight
)) Then
h0 = HScroll
HScroll = HScroll - 1
If (HScroll
< 1) Then HScroll
= 1
h0 = HScroll
HScroll = HScroll + 1
Color BackgroundColor
, BackgroundColor
Call StringPrint
("", k
, j
, " ") Color Cursor1Back
, Cursor1Back
Color Cursor1Back
, Cursor1Back
Color TextFaceColor
, BackgroundColor
Cursor1.X = LeftIndent + 1
Cursor2.X
= LeftIndent
+ Len(LineAsMapped
(Cursor1.Y
- TopIndent
)) Cursor2.Y = Cursor1.Y
a = NthL&(ID1, ChainLimit + 1)
b = NthP&(ID1, ChainLimit + 1)
c = Projection$(a, b) + CR
TheChain(k).Identity = 0
a = Assimilate&(c, BOC, EOC)
c = Projection$(NthL&(ID1, ChainLimit + 1), NthP&(ID1, ChainLimit + 1))
GOLSwitch = -GOLSwitch
ColorTheme = -ColorTheme
TextFormatting = -TextFormatting
TextWrapping = TextWrapping + 1
TextWrapping = 0
HScroll = 1
If (TextWrapping
= 2) Then HScroll
= 1 Cursor1.X = LeftIndent + 1
If (Cursor1.Y
> TopIndent
+ 1) Then Cursor1.Y = Cursor1.Y - 1
StartIndex = BackBreak&(StartIndex)
k
= LeftIndent
+ Len(LineAsMapped
(Cursor1.Y
- TopIndent
)) - (HScroll
- 1) If (Len(LineAsMapped
(Cursor1.Y
- TopIndent
)) > TextWidth
) Then HScroll
= 1 + Len(LineAsMapped
(Cursor1.Y
- TopIndent
)) - (Cursor1.X
- LeftIndent
) HScroll = 1
Cursor1.X
= LeftIndent
+ Len(LineAsMapped
(Cursor1.Y
- TopIndent
)) Cursor1.X = k
StartIndex = BackBreak&(StartIndex)
ID1 = NthL&(ID1, 2)
If (Cursor1.X
= LeftIndent
+ 1) Then HScroll = HScroll - 1
j = Cursor1.Y - TopIndent - 1
k
= Len(LineAsMapped
(j
)) - TextWidth
+ 1 HScroll = k
If ((Cursor1.X
- LeftIndent
= 1) And Cursor1.Y
- TopIndent
= 1) Then StartIndex = BackBreak&(StartIndex)
ID1 = NthP&(ID1, 2)
i = Cursor1.X - LeftIndent
j
= Len(LineAsMapped
(Cursor1.Y
- TopIndent
)) - HScroll
+ 1 HScroll = HScroll + 1
k = Cursor1.Y - TopIndent + 1
If ((k
<= TextHeight
) And (VisibleLines
> 1)) Then HScroll
= 1 If ((i
>= j
) And (Cursor1.Y
- TopIndent
= VisibleLines
)) Then If (VisibleLines
> 1) Then StartIndex
= NthP&
(StartIndex
, Len(LineAsMapped
(1)) + 1)
Cursor1.X
= LeftIndent
+ Len(LineAsMapped
(Cursor1.Y
- TopIndent
)) ID1 = TheChain(ID1).Pointer
k
= Len(LineAsMapped
(Cursor1.Y
- TopIndent
)) - TextWidth
+ 1 HScroll = k
Call CalibrateCursor
(ID1
)
z
= InsertString&
(Chr$(KeyboardTab
), ID1
)
If (Cursor1.Y
= TopIndent
+ VisibleLines
) Then StartIndex
= NthP&
(StartIndex
, Len(LineAsMapped
(1)) + 1) Cursor1.Y = Cursor1.Y + 1
k
= LeftIndent
+ Len(LineAsMapped
(Cursor1.Y
- TopIndent
)) - (HScroll
- 1) If (Len(LineAsMapped
(Cursor1.Y
- TopIndent
)) > TextWidth
) Then HScroll
= 1 + Len(LineAsMapped
(Cursor1.Y
- TopIndent
)) - (Cursor1.X
- LeftIndent
) HScroll = 1
Cursor1.X
= LeftIndent
+ Len(LineAsMapped
(Cursor1.Y
- TopIndent
)) Cursor1.X = k
StartIndex
= NthP&
(StartIndex
, Len(LineAsMapped
(1)) + 1)
InsertKey = -InsertKey
For j
= 1 To VisibleLines
c = LineAsMapped(j)
For i
= 1 To Len(c
) - 1 ' BR offset to exclude CR at line end. AuxGrid
(i
, j
, 1) = Mid$(c
, i
, 1)
c = ""
For j
= 1 To VisibleLines
c = c + AuxGrid(i, j, 1)
c = c + CR ' Undoes BR offset.
TheChain(k).Identity = 0
k = Assimilate&(c, BOC, EOC)
For j
= 1 To VisibleLines
c = AuxGrid(i, j, 1)
AuxGrid(i, j, 1) = c
AuxGrid(i, j, 2) = c
For j
= 2 To VisibleLines
- 2 ' BR offset. For i
= 2 To Len(LineAsMapped
(j
)) - 2 ' BR offset. c = AuxGrid(i, j, 1)
a1
= Val(AuxGrid
(i
- 1, j
+ 1, 1)) a2
= Val(AuxGrid
(i
, j
+ 1, 1)) a3
= Val(AuxGrid
(i
+ 1, j
+ 1, 1)) a4
= Val(AuxGrid
(i
- 1, j
, 1)) a6
= Val(AuxGrid
(i
+ 1, j
, 1)) a7
= Val(AuxGrid
(i
- 1, j
- 1, 1)) a8
= Val(AuxGrid
(i
, j
- 1, 1)) a9
= Val(AuxGrid
(i
+ 1, j
- 1, 1)) t = a1 + a2 + a3 + a4 + a6 + a7 + a8 + a9
AuxGrid(i, j, 2) = "0"
AuxGrid(i, j, 2) = "1"
AuxGrid(i, j, 2) = "1"
AuxGrid(i, j, 2) = "0"
If (t
= 3) Then AuxGrid
(i
, j
, 2) = "1" For j
= 1 To VisibleLines
c = AuxGrid(i, j, 2)
AuxGrid(i, j, 1) = c
AuxGrid(i, j, 2) = c
'''
stdout = "": stderr = ""
As _Unsigned Long dwX
, dwY
, dwXSize
, dwYSize
, dwXCountChars
, dwYCountChars
, dwFillAttribute
, dwFlags
As _Offset lpReserved2
, hStdInput
, hStdOutput
, hStdError
Const STARTF_USESTDHANDLES
= &H00000100 Const CREATE_NO_WINDOW
= &H8000000
Const INFINITE
= 4294967295 Const WAIT_FAILED
= &HFFFFFFFF
Dim As _Offset hStdOutPipeRead
, hStdOutPipeWrite
, hStdReadPipeError
, hStdOutPipeError
Dim As SECURITY_ATTRIBUTES sa: sa.nLength
= Len(sa
): sa.lpSecurityDescriptor
= 0: sa.bInheritHandle
= 1
pipecom = -1
pipecom = -1
si.dwFlags = STARTF_USESTDHANDLES
si.hStdError = hStdOutPipeError
si.hStdOutput = hStdOutPipeWrite
si.hStdInput = 0
Dim As PROCESS_INFORMATION procinfo
Dim As Long bInheritHandles: bInheritHandles
= 1 ok
= CreateProcess
(lpApplicationName
, _Offset(lpCommandLine
), lpProcessAttributes
, lpThreadAttributes
, bInheritHandles
, dwCreationFlags
, lpEnvironment
, lpCurrentDirectory
, _Offset(si
), _Offset(procinfo
))
pipecom = -1
HandleClose hStdOutPipeWrite
HandleClose hStdOutPipeError
buf
= Mid$(buf
, 1, dwRead
) stdout = stdout + buf
buf
= Mid$(buf
, 1, dwRead
) stderr = stderr + buf
If WaitForSingleObject
(procinfo.hProcess
, INFINITE
) <> WAIT_FAILED
Then If GetExitCodeProcess
(procinfo.hProcess
, _Offset(exit_code
)) Then ex_stat = 1
HandleClose hStdOutPipeRead
HandleClose hStdReadPipeError
pipecom = exit_code
pipecom = -1
RemoveChr13:
stream = popen(cmd + " 2>pipestderr", "r")
If fgets
(buffer
, 4096, stream
) <> "" And feof
(stream
) = 0 Then status = pclose(stream)
exit_code = WEXITSTATUS(status)
pipecom = exit_code
pipecom = -1
a = pipecom(cmd, stdout, stderr)
pipecom_lite = stderr
pipecom_lite = stdout