Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function CMDMenuState:drawInput()
- term.setCursorPos(3,5)
- term.write(string.rep(" ",tW-4))
- term.setCursorPos(3,5)
- term.write(self.inp:sub(self.inpScroll+1,self.inpScroll+dispSize))
- end
- if ev == "char" then
- self.inp = self.inp:sub(0,self.inpCX-3+self.inpScroll) .. p1 .. self.inp:sub(self.inpCX-2+self.inpScroll,#self.inp)
- self.inpCX = self.inpCX + 1
- if self.inpCX == tW-1 then
- self.inpCX = tW-2
- self.inpScroll = self.inpScroll + 1
- end
- self:drawInput()
- term.setCursorPos(self.inpCX,5)
- elseif ev == "key" then
- if p1 == keys.backspace and #self.inp > 0 then
- self.inp = self.inp:sub(0,self.inpCX-4+self.inpScroll)..self.inp:sub(self.inpCX-2+self.inpScroll,#self.inp)
- self.inpCX = self.inpCX - 1
- if self.inpCX == 2 then
- self.inpCX = 3
- self.inpScroll = self.inpScroll - 1
- end
- self:drawInput()
- term.setCursorPos(self.inpCX,5)
- elseif p1 == keys.enter then
- runCmd(self.inp)
- elseif p1 == keys.left then
- self.inpCX = self.inpCX - 1
- if self.inpCX == 2 then
- self.inpCX = 3
- if self.inpScroll > 0 then
- self.inpScroll = self.inpScroll-1
- self:drawInput()
- end
- end
- term.setCursorPos(self.inpCX,5)
- elseif p1 == keys.right and self.inpScroll + self.inpCX - 3 < #self.inp then
- self.inpCX = self.inpCX + 1
- if self.inpCX == tW - 1 then
- self.inpCX = tW - 2
- if #self.inp > self.inpScroll+dispSize then
- self.inpScroll = self.inpScroll + 1
- self:drawInput()
- end
- end
- term.setCursorPos(self.inpCX,5)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement