# Path: pyilper/pilcharconv.py
# def icharconv(i, charset):
#    return convert_to_unicode[charset][i]
# 
# CHARSET_HP71=0
# 
# CHARSET_HP75=2
# 
# CHARSET_HP41=1
# 
# Path: pyilper/pilcore.py
# UPDATE_TIMER=25                 # Poll timer (ms) for terminal output queue
# 
# CURSOR_BLINK=500                # 500 ms cursor blink rate
# 
# TERMINAL_MINIMUM_ROWS=24        # can't get beyond that
# 
# FONT="Monospace"
# 
# AUTOSCROLL_RATE=100             # 500 ms cursor blink rate
# 
# def isMACOS():
#    return platform.system()=="Darwin"
# 
# KEYBOARD_DELAY=500              # autorepeat delay to prevent too fast kbd input
# 
# Path: pyilper/shortcutconfig.py
# SHORTCUTCONFIG=  cls_shortcutconfig()
# 
# SHORTCUT_EXEC=1
# 
# SHORTCUT_EDIT=2
# 
# SHORTCUT_INSERT=3
# 
# Path: pyilper/pilconfig.py
# PILCONFIG=  cls_pilconfig()


import array
import queue
import threading
import time
from PyQt5 import QtCore, QtGui, QtWidgets
from .pilcharconv import icharconv, CHARSET_HP71, CHARSET_HP75, CHARSET_HP41
from .pilcore import UPDATE_TIMER, CURSOR_BLINK, TERMINAL_MINIMUM_ROWS,FONT, AUTOSCROLL_RATE, isMACOS, KEYBOARD_DELAY
from .shortcutconfig import SHORTCUTCONFIG, SHORTCUT_EXEC, SHORTCUT_EDIT, SHORTCUT_INSERT
from .pilconfig import PILCONFIG
from .pilkeymap import *
        # Modes
        self.insert = False
        self.movecursor=0
        self.showSelection=False

    def reset_screen(self):
        # Screen
        self.screen = array.array('i', [CHAR_ATTRIB_NONE | 0x20] * self.w * self.h)
        self.linelength= array.array('i', [0] * self.h)
        self.linewrapped= array.array('i',[False] * self.h)
        # Scroll parameters
        self.view_y0=0
        self.view_y1= self.view_h-1

        # Cursor position
        self.cx = 0
        self.cy = 0
        self.movecursor=0

        # Number of lines and scroll bar
        self.actual_h=0
        self.win.scrollbar.setMinimum(0)
        self.win.scrollbar.setMaximum(0)
        self.win.scrollbar.setSingleStep(1)
        self.win.scrollbar.setPageStep(self.view_h)
        self.saved_cursortype= CURSOR_OVERWRITE
#
#   enable: start update timer (one shot timer)
#
    def enable(self):

# Path: pyilper/pilcharconv.py
# def icharconv(i, charset):
#    return convert_to_unicode[charset][i]
# 
# CHARSET_HP71=0
# 
# CHARSET_HP75=2
# 
# CHARSET_HP41=1
# 
# Path: pyilper/pilcore.py
# UPDATE_TIMER=25                 # Poll timer (ms) for terminal output queue
# 
# CURSOR_BLINK=500                # 500 ms cursor blink rate
# 
# TERMINAL_MINIMUM_ROWS=24        # can't get beyond that
# 
# FONT="Monospace"
# 
# AUTOSCROLL_RATE=100             # 500 ms cursor blink rate
# 
# def isMACOS():
#    return platform.system()=="Darwin"
# 
# KEYBOARD_DELAY=500              # autorepeat delay to prevent too fast kbd input
# 
# Path: pyilper/shortcutconfig.py
# SHORTCUTCONFIG=  cls_shortcutconfig()
# 
# SHORTCUT_EXEC=1
# 
# SHORTCUT_EDIT=2
# 
# SHORTCUT_INSERT=3
# 
# Path: pyilper/pilconfig.py
# PILCONFIG=  cls_pilconfig()


# Path: pyilper/pilqterm.py
import array
import queue
import threading
import time
from PyQt5 import QtCore, QtGui, QtWidgets
from .pilcharconv import icharconv, CHARSET_HP71, CHARSET_HP75, CHARSET_HP41
from .pilcore import UPDATE_TIMER, CURSOR_BLINK, TERMINAL_MINIMUM_ROWS,FONT, AUTOSCROLL_RATE, isMACOS, KEYBOARD_DELAY
from .shortcutconfig import SHORTCUTCONFIG, SHORTCUT_EXEC, SHORTCUT_EDIT, SHORTCUT_INSERT
from .pilconfig import PILCONFIG
from .pilkeymap import *

        # Modes
        self.insert = False
        self.movecursor=0
        self.showSelection=False

    def reset_screen(self):
        # Screen
        self.screen = array.array('i', [CHAR_ATTRIB_NONE | 0x20] * self.w * self.h)
        self.linelength= array.array('i', [0] * self.h)
        self.linewrapped= array.array('i',[False] * self.h)
        # Scroll parameters
        self.view_y0=0
        self.view_y1= self.view_h-1

        # Cursor position
        self.cx = 0
        self.cy = 0
        self.movecursor=0

        # Number of lines and scroll bar
        self.actual_h=0
        self.win.scrollbar.setMinimum(0)
        self.win.scrollbar.setMaximum(0)
        self.win.scrollbar.setSingleStep(1)
        self.win.scrollbar.setPageStep(self.view_h)
        self.saved_cursortype= CURSOR_OVERWRITE
#
#   enable: start update timer (one shot timer)
#
    def enable(self):

       self.UpdateTimer.start(UPDATE_TIMER)