# 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 *
        self._screen = []             # frontend screen buffer
        self._cursor_col = 0          # cursor position
        self._cursor_row = 0          # dto.
        self._kbdfunc= None           # function that is called to send keyboard input
                                      # to the loop, set by setkbdfunc
        self._alt_sequence= False     # Variables for parsing ALT keyboard sequences
        self._alt_seq_length=0        #
        self._alt_seq_value=0         #
        self._alt_modifier= False     # Alt key pressed
        self._shift_modifier=False    # Shift key pressed
        self._ctrl_modifier=False     # Ctrl key pressed
        self._modifier_flags=0        # Modifier flags for look up
        self._cursortype= CURSOR_OFF  # cursor mode (off, overwrite, insert)
        self._cursor_char= 0x20       # character at cursor position
        self._cursor_attr=-1          # attribute at cursor position
        self._font=QtGui.QFont(FONT)  # monospaced font
        self._isVisible= False        # visible state
        self._press_pos= None         # mouse click position
        self._selectionText=""        # text of selection
        self._scrollUpAreaY=0         # display area that activates scroll up
        self._scrollDownAreaY=0       # display area that activates scroll down
        self._saved_pos=None          # saved last cursor move position
#
#       If this timer is active, autorpeat keyboard entries are ignored
#
        self._inhibitAutorepeatTimer= QtCore.QTimer()
        self._inhibitAutorepeatTimer.setInterval(KEYBOARD_DELAY)
        self._inhibitAutorepeatTimer.setSingleShot(True)
        self._autoscrollMode= AUTOSCROLL_OFF
        self._autoscrollTimer=QtCore.QTimer()

# 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 *

        self._screen = []             # frontend screen buffer
        self._cursor_col = 0          # cursor position
        self._cursor_row = 0          # dto.
        self._kbdfunc= None           # function that is called to send keyboard input
                                      # to the loop, set by setkbdfunc
        self._alt_sequence= False     # Variables for parsing ALT keyboard sequences
        self._alt_seq_length=0        #
        self._alt_seq_value=0         #
        self._alt_modifier= False     # Alt key pressed
        self._shift_modifier=False    # Shift key pressed
        self._ctrl_modifier=False     # Ctrl key pressed
        self._modifier_flags=0        # Modifier flags for look up
        self._cursortype= CURSOR_OFF  # cursor mode (off, overwrite, insert)
        self._cursor_char= 0x20       # character at cursor position
        self._cursor_attr=-1          # attribute at cursor position
        self._font=QtGui.QFont(FONT)  # monospaced font
        self._isVisible= False        # visible state
        self._press_pos= None         # mouse click position
        self._selectionText=""        # text of selection
        self._scrollUpAreaY=0         # display area that activates scroll up
        self._scrollDownAreaY=0       # display area that activates scroll down
        self._saved_pos=None          # saved last cursor move position
#
#       If this timer is active, autorpeat keyboard entries are ignored
#
        self._inhibitAutorepeatTimer= QtCore.QTimer()
        self._inhibitAutorepeatTimer.setInterval(KEYBOARD_DELAY)
        self._inhibitAutorepeatTimer.setSingleShot(True)
        self._autoscrollMode= AUTOSCROLL_OFF
        self._autoscrollTimer=QtCore.QTimer()

        self._autoscrollTimer.setInterval(AUTOSCROLL_RATE)