Esempio n. 1
0
int
CIMIClassicView::onCandidateSelectRequest(int index)
{
    unsigned changeMasks = 0;

    if (!m_pIC->isEmpty())
        _makeSelection(index, changeMasks);

    updateWindows(changeMasks);
    return 0;
}
Esempio n. 2
0
void OpTuile::setChildAtPos(const unsigned int& ind, Tuile* child) {
    while(m_children.size()<=ind) {
        m_children.push_back(NULL);
    }
    m_children[ind]=child;
    if(child->getParent()) {
        child->getParent()->removeChild(child);
    }
    child->setParent(this);
    updateProcChildren();
    updateWindows();
}
Esempio n. 3
0
void Nexus::onWindowStateChanged(Qt::WindowStates state)
{
    minimizeAction->setEnabled(QApplication::activeWindow() != nullptr);

    if (QApplication::activeWindow() != nullptr && sender() == QApplication::activeWindow())
    {
        if (state & Qt::WindowFullScreen)
            minimizeAction->setEnabled(false);

        if (state & Qt::WindowFullScreen)
            fullscreenAction->setText(tr("Exit Fullscreen"));
        else
            fullscreenAction->setText(tr("Enter Fullscreen"));

        updateWindows();
    }

    updateWindowsStates();
}
void keyboard(unsigned char key, int a, int b)
{
  switch (key)
  {
    case('a'):
    case('A'):
      color1 = (color1 < 8)? color1 + 1 : color1;
    break;
    
    case('q'):
    case('Q'):
      color1 = (color1 > 0)? color1 - 1 : color1;
    break;
    
    case('w'):
    case('W'):
      color2 = (color2 < 8)? color2 + 1 : color2;
    break;
    
    case('s'):
    case('S'):
      color2 = (color2 > 0)? color2 - 1 : color2;
    break;
    
    case(' '):
    case('.'):
    case('>'):
      addPar();
    break;
    
    case(','):
    case('<'):
      addPar(-1);
    break;
    
    case 27:			// Escape key
      exit(0);
    break;
  }
  updateWindows();
}
Esempio n. 5
0
int
CIMIClassicView::onCandidatePageRequest(int pgno, bool relative)
{
    unsigned changeMasks = 0;
    int      ncandi, lastpgidx;

    if (!m_pIC->isEmpty()) {
        changeMasks |= KEYEVENT_USED;
        int sz = m_candiList.size() + ((m_tailSentence.size() > 0)?1:0);
        if (sz > 0) {
           lastpgidx = (sz-1)/m_candiWindowSize * m_candiWindowSize;
           if (relative == true) {
                ncandi = m_candiPageFirst + pgno*m_candiWindowSize;
                if (ncandi >= sz)
                   ncandi = lastpgidx;
                if (ncandi < 0)
                    ncandi =0;
                if (ncandi != m_candiPageFirst) {
                    m_candiPageFirst = ncandi;
                    changeMasks |= CANDIDATE_MASK;
                }
            } else {
                if (pgno == -1) { //last page
                    ncandi = lastpgidx;
                } else {
                    ncandi = pgno * m_candiWindowSize;
                    if (ncandi > lastpgidx)
                        ncandi = lastpgidx;
                }
                if (ncandi != m_candiPageFirst) {
                    m_candiPageFirst = ncandi;
                    changeMasks |= CANDIDATE_MASK;
                }
            }
        }
    }

    updateWindows(changeMasks);
    return 0;
}
Esempio n. 6
0
int main(int argc, char* argv[])
{
    //The current working directory:
    Directory* dir = NULL;

    //Checks if too many arguments have been given:
    if(argc > 2)
    {
        std::cerr << "Please pass a single, valid directory\n";
        return -1;
    }
    //Otherwise, sees if a directory has been given,
    //and if so, attempt to open it:
    else if(argc == 2)
    {
        //Attempt to open
        try
        {
            dir = new Directory(argv[1]);
        }
        //Give an error message and quit if it fails:
        catch(int e)
        {
            std::cerr << "Cannot open '" << argv[1] << "': ";
            switch(e)
            {
            case EACCES:
                std::cerr << "Permission denied.";
                break;
            case ENOENT:
                std::cerr << "No such directory.";
                break;
            case ENOTDIR:
                std::cerr << "Not a directory.";
                break;
            }
            std::cerr << std::endl;
            return -1;
        }
    }
    //Otherwise, there are no arguments given, so use
    //the user's current working directory:
    else
    {
        //Get the current working directory:
        char* cwd = getcwd(NULL, 0);

        //Attempt to open it:
        try
        {
            dir = new Directory(cwd);
        }
        //Give an error message and quit if it fails:
        catch(int e)
        {
            std::cerr << "Cannot open '" << cwd << "': ";
            switch(e)
            {
            case EACCES:
                std::cerr << "Permission denied.";
                break;
            case ENOENT:
                std::cerr << "No such directory.";
                break;
            case ENOTDIR:
                std::cerr << "Not a directory.";
                break;
            }
            std::cerr << std::endl;
            return -1;
        }
    }
    //Attempt to read the directory's contents:
    try
    {
        dir->read();
    }
    //Give an error message and quit if it fails:
    catch(int e)
    {
        std::cerr << "Cannot open '" << dir->getPath() << "': ";
        switch(errno)
        {
        case EACCES:
            std::cerr << "Permission denied.";
            break;
        case ENOENT:
            std::cerr << "No such directory.";
            break;
        case ENOTDIR:
            std::cerr << "Not a directory.";
            break;
        }
        std::cerr << std::endl;
        return -1;
    }

    if(dir->getName() == "../")
        dir->cleanPath();

    //Initialise ncurses:
    initscr();

    //The colour pairs:
    init_pair(2, COLOR_WHITE, COLOR_RED);
    //Enable keypad mode (allows use of the up and down arrows):
    keypad(stdscr, true);

    //Start using colour:
    start_color();

    //Update the screen:
    refresh();

    //Hides the cursor, set 'noecho()':
    curs_set(0);
    noecho();

    int input = 0;
    std::string path = "";
    unsigned int selection = 0;
    DiskItem* clipboard = NULL;

    //While the user has not quit:
    while((char(input) != 'q') && (char(input) != 'Q'))
    {
        //Redraw the windows and help:
        updateWindows();
        drawHelp();

        //If necessary, resizes the directory path:
        path = "";
        if(dir->getPath().length() >= screenX)
            path = fitToSize(dir->getPath(), (screenX - 2));
        else
            path = dir->getPath();

        //The X position needed to print the path in the centre:
        int pos = ((screenX - path.length()) / 2);
        //Write the user's current directory:
        mvprintw(0, pos, "%s", path.c_str());

        //Get the files and sort the contents:
        std::vector <DiskItem*> items = dir->getFiles();

        //Checks if the contents of the directory will fit in the window:
        if((fileview.height - 2) > (items.size() - dir->getDotfiles()))
        {
            //Print the contents, except the dotfiles, to the window:
            for(unsigned int i = dir->getDotfiles(); i < items.size(); i++)
            {
                //If we're printing the current selection, highlight it:
                if(selection == (i - dir->getDotfiles()))
                {
                    //Print the name:
                    mvwprintw(fileview.window,((i - dir->getDotfiles()) + 1), 1, "%s", items[i]->getName().c_str());

                    //Move to the beginning of the line, and highlight the line up to but excluding the window border:
                    mvwchgat(fileview.window, ((i - dir->getDotfiles()) + 1), 1, (fileview.width - 2), A_NORMAL, 1, NULL);
                }
                else
                    //Print the name:
                    mvwprintw(fileview.window, ((i - dir->getDotfiles()) + 1), 1, "%s", items[i]->getName().c_str());
            }
        }
        //Otherwise, we can only print part of the directory's contents:
        else
        {
            //If the selection is less than the height, display the first few items:
            if(selection < (fileview.height - 2))
            {
                for(unsigned int i = dir->getDotfiles(); i < ((fileview.height - 2) + dir->getDotfiles()); i++)
                {
                    //If we're printing the current selection, highlight it:
                    if(selection == (i - dir->getDotfiles()))
                    {
                        //Print the name:
                        mvwprintw(fileview.window,((i - dir->getDotfiles()) + 1), 1, "%s", items[i]->getName().c_str());

                        //Move to the beginning of the line, and highlight the line up to but excluding the window border:
                        mvwchgat(fileview.window, ((i - dir->getDotfiles()) + 1), 1, (fileview.width - 2), A_NORMAL, 1, NULL);
                    }
                    else
                        //Print the name:
                        mvwprintw(fileview.window, ((i - dir->getDotfiles()) + 1), 1, "%s", items[i]->getName().c_str());
                }
            }
            //Otherwise, display the selection as the last item:
            else
            {
                for(unsigned int i = (dir->getDotfiles() + ((selection + 1) - (fileview.height - 2))); i < ((selection + 1) + dir->getDotfiles()); i++)
                {
                    unsigned int y = i - ((selection - (fileview.height - 2)) + dir->getDotfiles());

                    //If we're printing the current selection, highlight it:
                    if(selection == (i - dir->getDotfiles()))
                    {
                        //Print the name:
                        mvwprintw(fileview.window, y, 1, "%s", items[i]->getName().c_str());

                        //Move to the beginning of the line, and highlight the line up to but excluding the window border:
                        mvwchgat(fileview.window, y, 1, (fileview.width - 2), A_NORMAL, 1, NULL);
                    }
                    else
                        //Print the name:
                        mvwprintw(fileview.window, y, 1, "%s", items[i]->getName().c_str());
                }
            }
        }

        //Print the selected file's metadata to the 'fileinfo' window:
        printMetaData(items[selection + dir->getDotfiles()]);

        //Print the contents of the clipboard to the 'extrainfo' window:
        printClipboard(clipboard);

        //Refresh the screen and windows:
        refresh();
        wrefresh(fileview.window);
        wrefresh(fileinfo.window);
        wrefresh(extrainfo.window);

        //Gets the input:
        input = getch();

        //Moves the selection up or down if those keys were pressed:
        if((input == KEY_UP) || (char(input) == 'k') || (char(input) == 'K'))
            if(selection > 0) selection--;
        if((input == KEY_DOWN) || (char(input) == 'j') || (char(input) == 'J'))
            if(selection < ((items.size() - dir->getDotfiles()) - 1)) selection++;

        //If the user has pressed Enter:
        if(char(input) == '\n')
        {
            //Attempts to cast the current selection to a Directory*:
            Directory* selected = dynamic_cast <Directory*>(items[selection + dir->getDotfiles()]);

            //If the user has selected a directory:
            if(selected != NULL)
            {
                //Keep the old directory so we can delete it:
                Directory* oldDir = dir;

                //Makes a copy of the directory we want to move to:
                try
                {
                    dir = new Directory(selected);
                    dir->read();

                    delete oldDir;
                    selection = 0;

                    clear();
                }
                //If an error occurs, inform the user with a message box:
                catch(int e)
                {
                    std::string error = "Cannot open '" + dir->getPath() + "' ";
                    switch(errno)
                    {
                    case EACCES:
                        error += "Permission denied.";
                        break;
                    case ENOENT:
                        error += "No such directory.";
                        break;
                    case ENOTDIR:
                        error += "Not a directory.";
                        break;
                    }
                    messageBox(error);
                }
            }
        }
        //Otherwise, if the user has pressed 'd' for delete:
        else if((char(input) == 'd') || (char(input) == 'D'))
        {
            DiskItem* selected = items[selection + dir->getDotfiles()];
            //Attempt to delete the selected item:
            if(selected->deletef())
            {
                delete selected;
                dir->getFiles().erase(dir->getFiles().begin() + (selection + dir->getDotfiles()));

                //If we deleted the last item, then 'selection + dir->getDotfiles()' will
                //go out of bounds on the 'item' array, so decrement selection:
                if((selection + dir->getDotfiles()) == dir->getFiles().size())
                    selection--;
            }
            //If an error occurs, inform the user with a message box:
            else
            {
                std::string error = "Could not delete '" + selected->getPath() + "'";
                messageBox(error);
            }
        }
        //Otherwise, if the user has pressed 'c' for copy:
        else if((char(input) == 'C') || (char(input) == 'c'))
        {
            if(items[selection + dir->getDotfiles()]->getName() != "../")
            {
                //Checks if we are trying to copy a directory or a file:
                clipboard = dynamic_cast <Directory*>(items[selection + dir->getDotfiles()]);

                if(clipboard == NULL)
                {
                    //We are copying a file:
                    clipboard = new File(dynamic_cast <File*>(items[selection + dir->getDotfiles()]));
                }
                else
                {
                    //We are copying a directory:
                    clipboard = new Directory(dynamic_cast <Directory*>(items[selection + dir->getDotfiles()]));
                }
            }
        }
        //Otherwise, if the user has pressed 'x' for cut:
        else if((char(input) == 'X') || (char(input) == 'x'))
        {
            if(items[selection + dir->getDotfiles()]->getName() != "../")
            {
                //Checks if we are trying to cut a directory or a file:
                clipboard = dynamic_cast <Directory*>(items[selection + dir->getDotfiles()]);

                if(clipboard == NULL)
                {
                    //We are cutting a file:
                    clipboard = new File(dynamic_cast <File*>(items[selection + dir->getDotfiles()]));
                }
                else
                {
                    //We are cutting a directory:
                    clipboard = new Directory(dynamic_cast <Directory*>(items[selection + dir->getDotfiles()]));
                }
                clipboard->cut();
            }
        }
        //Otherwise, if the user has pressed 'p' for paste:
        else if((char(input) == 'P') || (char(input) == 'p'))
        {
            if(clipboard != NULL)
            {
                //Attempt to paste the item in the clipboard:
                if(! clipboard->paste(dir->getPath()))
                {
                    //If an error occurs, inform the user with a message box:
                    std::string error = "Could not paste '" + clipboard->getName() + "'";
                    messageBox(error);
                }
                else
                {
                    //If it works fine, add the new item to the directory's list of items:
                    DiskItem* item = clipboard;
                    dir->getFiles().push_back(item);
                    std::sort(dir->getFiles().begin(), dir->getFiles().end(), byName);

                    //Empty the clipboard:
                    clipboard = NULL;
                }
            }
        }
        //Otherwise, if the user presses 'r' for rename:
        else if((char(input) == 'R') || (char(input) == 'r'))
        {
            //Get the new name, and attempt to rename the selected item:
            std::string newName = inputBox();
            if(newName != "")
            {
                //Check if we are renaming a directory:
                if(dynamic_cast <Directory*>(items[selection + dir->getDotfiles()]) != NULL)
                    newName += '/';

                if(! items[selection + dir->getDotfiles()]->rename(newName.c_str()))
                {
                    //If an error occurs, inform the user with a message box:
                    std::string error = "Cannot rename '" + items[selection + dir->getDotfiles()]->getName() + "'";
                    messageBox(error);
                }
            }
        }
    }

    //Delete the directory object:
    delete dir;

    //Close ncurses:
    endwin();
    return 0;
}
Esempio n. 7
0
bool
CIMIClassicView::onKeyEvent(const CKeyEvent& key)
{
    unsigned changeMasks = 0;

    unsigned keycode = key.code;
    unsigned keyvalue = key.value;
    unsigned modifiers = key.modifiers;
    
#ifdef DEBUG
    printf("Classic View got a key (0x%x-0x%x-0x%x)...", 
           keycode, keyvalue, modifiers);
    if (((modifiers & IM_CTRL_MASK) != 0) && (keyvalue == 'P' || keyvalue=='p'))
        m_pIC->printLattice();
#endif

    if (m_pHotkeyProfile && m_pHotkeyProfile->isModeSwitchKey(key)) {
        setStatusAttrValue(CIMIWinHandler::STATUS_ID_CN, (!m_bCN)?1:0);
        if (!m_pIC->isEmpty ()) {
            changeMasks |= CANDIDATE_MASK | PREEDIT_MASK;
            clearIC ();
        }
        
    } else if (m_pHotkeyProfile && m_pHotkeyProfile->isPunctSwitchKey(key)) {
        // On CTRL+. switch Full/Half punc
        changeMasks |= KEYEVENT_USED;
        setStatusAttrValue(CIMIWinHandler::STATUS_ID_FULLPUNC, (!m_bFullPunct)?1:0);
        
    } else if (m_pHotkeyProfile && m_pHotkeyProfile->isSymbolSwitchKey(key)) {
        // On SHIFT+SPACE switch Full/Half symbol
        changeMasks |= KEYEVENT_USED;
        setStatusAttrValue(CIMIWinHandler::STATUS_ID_FULLSYMBOL, (!m_bFullSymbol)?1:0);
        
    } else if (modifiers == IM_CTRL_MASK && keycode == IM_VK_LEFT)  { // move left
        if (!m_pIC->isEmpty ()) {
            changeMasks |= KEYEVENT_USED;
            _moveLeft (changeMasks);
        }
        
    } else if (modifiers == IM_CTRL_MASK && keycode == IM_VK_RIGHT) { // move right
        if (!m_pIC->isEmpty ()) {
            changeMasks |= KEYEVENT_USED;
            _moveRight (changeMasks);
        }
    } else if ( ((modifiers == 0 && keycode == IM_VK_PAGE_UP) ||
                 (m_pHotkeyProfile && m_pHotkeyProfile->isPageUpKey (key))) &&
                !m_pIC->isEmpty() ) {
        changeMasks |= KEYEVENT_USED;
        int sz = m_candiList.size() + ((m_tailSentence.size() > 0)?1:0);
        if (sz > 0 && m_candiPageFirst > 0) {
            m_candiPageFirst -= m_candiWindowSize;
            if (m_candiPageFirst < 0) m_candiPageFirst = 0;
            changeMasks |= CANDIDATE_MASK;
        }
    } else if ( ((modifiers == 0 && keycode == IM_VK_PAGE_DOWN) ||
                 (m_pHotkeyProfile && m_pHotkeyProfile->isPageDownKey (key))) &&
                !m_pIC->isEmpty() ) {
        changeMasks |= KEYEVENT_USED;
        int sz = m_candiList.size() + ((m_tailSentence.size() > 0)?1:0);
        if (sz > 0 && m_candiPageFirst + m_candiWindowSize < sz) {
            m_candiPageFirst += m_candiWindowSize;
            changeMasks |= CANDIDATE_MASK;
        }
    }
    else if (modifiers == IM_CTRL_MASK && 
             (keyvalue >= '0' && keyvalue <= '9') &&
             (m_candiWindowSize >= 10 || keyvalue < ('1' + m_candiWindowSize)) &&
             !m_pIC->isEmpty ()) {
        changeMasks |= KEYEVENT_USED;
        unsigned sel = (keyvalue == '0'? 9: keyvalue-'1');        
        _deleteCandidate (sel, changeMasks);
        goto PROCESSED;

    } else if ((modifiers & (IM_CTRL_MASK | IM_ALT_MASK | IM_RELEASE_MASK)) == 0) {
        if ((keyvalue >= '0' && keyvalue <= '9') &&
                   (m_candiWindowSize >= 10 || keyvalue < ('1' + m_candiWindowSize))) { // try to make selection
            if (!m_pIC->isEmpty ()) {
                changeMasks |= KEYEVENT_USED;
                unsigned sel = (keyvalue == '0'? 9: keyvalue-'1');
                _makeSelection (sel, changeMasks);
            } else {
                m_numeric_mode = true;
            }

            goto PROCESSED;
        } 
        
        if (keyvalue == '.' && m_numeric_mode) {
            m_numeric_mode = false;
            goto PROCESSED;

        }
        
        m_numeric_mode = false;

        if (islower(keyvalue)) {
            changeMasks |= KEYEVENT_USED;
            _insert (keyvalue, changeMasks);

        } else if (keyvalue > 0x20 && keyvalue < 0x7f) {
            changeMasks |= KEYEVENT_USED;
            if (m_pIC->isEmpty ()) {
                _insert (keyvalue, changeMasks);
                _doCommit ();
                clearIC ();
            } else {
                _insert (keyvalue, changeMasks);
            }
            
        } else if (keycode == IM_VK_BACK_SPACE || keycode == IM_VK_DELETE) {
            if (!m_pIC->isEmpty ()) {
                changeMasks |= KEYEVENT_USED;
                _erase (keycode == IM_VK_BACK_SPACE, changeMasks);
            }

        } else if (keycode == IM_VK_SPACE) {
            if (!m_pIC->isEmpty ()) {
                changeMasks |= KEYEVENT_USED;
                _makeSelection (0, changeMasks);
            }

        } else if (keycode == IM_VK_ENTER) {
            if (!m_pIC->isEmpty ()) {
                changeMasks |= KEYEVENT_USED | CANDIDATE_MASK | PREEDIT_MASK;
                _doCommit (false);
                clearIC ();
            }

        } else if (keycode == IM_VK_ESCAPE) {
            if (!m_pIC->isEmpty ()) {
                changeMasks |= KEYEVENT_USED | CANDIDATE_MASK | PREEDIT_MASK;
                clearIC ();
            }

        } else if (keycode == IM_VK_LEFT) { // move left syllable
            if (!m_pIC->isEmpty ()) {
                changeMasks |= KEYEVENT_USED;
                _moveLeftSyllable (changeMasks);
            }

        } else if (keycode == IM_VK_RIGHT) { // move right syllable
            if (!m_pIC->isEmpty ()) {
                changeMasks |= KEYEVENT_USED;
                _moveRightSyllable (changeMasks);
            }

        } else if (keycode == IM_VK_HOME) { // move home
            if (!m_pIC->isEmpty ()) {
                changeMasks |= KEYEVENT_USED;
                _moveHome (changeMasks);
            }

        } else if (keycode == IM_VK_END) { // move end
            if (!m_pIC->isEmpty ()) {
                changeMasks |= KEYEVENT_USED;
                _moveEnd (changeMasks);
            }
        }
    } else {
        goto RETURN;

    } 

PROCESSED:;
    m_pHotkeyProfile->rememberLastKey(key);

RETURN:;

#ifdef DEBUG
    printf("   |-->(Mask=0x%x)\n", changeMasks);
#endif

    updateWindows (changeMasks);
    return changeMasks & KEYEVENT_USED;
}
Esempio n. 8
0
bool
CIMIXhView::onKeyEvent(const CKeyEvent& key)
{
    unsigned changeMasks = 0;

    unsigned keycode = key.code;
    unsigned keyvalue = key.value;
    unsigned modifiers = key.modifiers;

	bool isKeyStroke = false;
#ifdef DEBUG
    printf("Xh View got a key (0x%x-0x%x-0x%x)...\n",
           keycode, keyvalue, modifiers);
    if (((modifiers & IM_CTRL_MASK) != 0) &&
        (keyvalue == 'P' || keyvalue == 'p'))
        m_pIC->printLattice();
#endif

    if (m_pHotkeyProfile && m_pHotkeyProfile->isModeSwitchKey(key)) {
        setStatusAttrValue(CIMIWinHandler::STATUS_ID_CN, (!m_bCN) ? 1 : 0);
        if (!m_pIC->isEmpty()) {
            changeMasks |= CANDIDATE_MASK | PREEDIT_MASK;
            clearIC();
        }
    } else if (m_pHotkeyProfile && m_pHotkeyProfile->isPunctSwitchKey(key)) {
        // On CTRL+. switch Full/Half punc
        changeMasks |= KEYEVENT_USED;
        setStatusAttrValue(CIMIWinHandler::STATUS_ID_FULLPUNC,
                           (!m_bFullPunct) ? 1 : 0);
    } else if (m_pHotkeyProfile && m_pHotkeyProfile->isSymbolSwitchKey(key)) {
        // On SHIFT+SPACE switch Full/Half symbol
        changeMasks |= KEYEVENT_USED;
        setStatusAttrValue(CIMIWinHandler::STATUS_ID_FULLSYMBOL,
                           (!m_bFullSymbol) ? 1 : 0);
    } else if (modifiers == IM_CTRL_MASK && keycode == IM_VK_LEFT) {
        // move left
        if (!m_pIC->isEmpty()) {
            changeMasks |= KEYEVENT_USED;
            _moveLeft(changeMasks);
        }
    } else if (modifiers == IM_CTRL_MASK && keycode == IM_VK_RIGHT) {
        // move right
        if (!m_pIC->isEmpty()) {
            changeMasks |= KEYEVENT_USED;
            _moveRight(changeMasks);
        }
    } else if (((modifiers == 0 && keycode == IM_VK_PAGE_UP)
                || (m_pHotkeyProfile && m_pHotkeyProfile->isPageUpKey(key)))
               && !m_pIC->isEmpty()) {
        changeMasks |= KEYEVENT_USED;
        if (m_candiPageFirst > 0) {
            m_candiPageFirst -= m_candiWindowSize;
            if (m_candiPageFirst < 0) m_candiPageFirst = 0;
            changeMasks |= CANDIDATE_MASK;
        }
    } else if (((modifiers == 0 && keycode == IM_VK_PAGE_DOWN)
                || (m_pHotkeyProfile && m_pHotkeyProfile->isPageDownKey(key)))
               && !m_pIC->isEmpty()) {
        changeMasks |= KEYEVENT_USED;
        if (m_candiPageFirst + m_candiWindowSize < candidateListSize()) {
            m_candiPageFirst += m_candiWindowSize;
            changeMasks |= CANDIDATE_MASK;
        }
    } else if (m_pHotkeyProfile
              && m_pHotkeyProfile->isCandiDeleteKey(key, m_candiWindowSize)
              && !m_pIC->isEmpty()) {
        changeMasks |= KEYEVENT_USED;
        unsigned sel = (keyvalue == '0' ? 9 : keyvalue - '1');
        deleteCandidate(sel, changeMasks);
        goto PROCESSED;
    } else if ((modifiers &
                (IM_CTRL_MASK | IM_ALT_MASK | IM_SUPER_MASK |
                 IM_RELEASE_MASK)) == 0) {
        if (isKeyValueSelectNumber(keyvalue)) {
            // try to make selection
            if (!m_pIC->isEmpty()) {
                changeMasks |= KEYEVENT_USED;
                unsigned sel = getSelectionNumber(keyvalue);
                makeSelection(sel, changeMasks);
            } else if (m_smartPunct) {
                m_pIC->omitNextPunct();
            }

			// using the same keys between selections
			isKeyStroke = true;
            goto PROCESSED;
        }

        if (keyvalue >= '1' && keyvalue <= '5') {
            changeMasks |= KEYEVENT_USED;
            _insert(keyvalue, changeMasks);
			
			isKeyStroke = true;
        } else if (keyvalue > 0x60 && keyvalue < 0x7b) {
            /* islower(keyvalue) */
            changeMasks |= KEYEVENT_USED;
            _insert(keyvalue, changeMasks);

			isKeyStroke = true;
        } else if (keyvalue > 0x20 && keyvalue < 0x7f) {
            /* isprint(keyvalue) && !isspace(keyvalue) */
            changeMasks |= KEYEVENT_USED;
            if (m_pIC->isEmpty()) {
                _insert(keyvalue, changeMasks);
                _doCommit();
                clearIC();
            } else {
                _insert(keyvalue, changeMasks);
            }

			isKeyStroke = true;
        } else if (keycode == IM_VK_BACK_SPACE || keycode == IM_VK_DELETE) {
            if (!m_pIC->isEmpty()) {
                changeMasks |= KEYEVENT_USED;
                _erase(keycode == IM_VK_BACK_SPACE, changeMasks);
            }

			isKeyStroke = true;
        } else if (keycode == IM_VK_SPACE) {
            if (!m_pIC->isEmpty()) {
                changeMasks |= KEYEVENT_USED;
                makeSelection(0, changeMasks);
            } else {
                wstring wstr = (CFullCharManager::fullPuncOp())(keyvalue);
                if (wstr.size()) {
                    _commitString(wstr);
                    changeMasks |= KEYEVENT_USED;
                }
            }
        } else if (keycode == IM_VK_ENTER) {
            if (!m_pIC->isEmpty()) {
                changeMasks |= KEYEVENT_USED | CANDIDATE_MASK | PREEDIT_MASK;
                _doCommit(false);
                clearIC();
            }
        } else if (keycode == IM_VK_ESCAPE) {
            if (!m_pIC->isEmpty()) {
                changeMasks |= KEYEVENT_USED | CANDIDATE_MASK | PREEDIT_MASK;
                clearIC();
            }
        } else if (keycode == IM_VK_LEFT) { // move left syllable
            if (!m_pIC->isEmpty()) {
                changeMasks |= KEYEVENT_USED;
                _moveLeftSyllable(changeMasks);
            }
        } else if (keycode == IM_VK_RIGHT) { // move right syllable
            if (!m_pIC->isEmpty()) {
                changeMasks |= KEYEVENT_USED;
                _moveRightSyllable(changeMasks);
            }
        } else if (keycode == IM_VK_HOME) { // move home
            if (!m_pIC->isEmpty()) {
                changeMasks |= KEYEVENT_USED;
                _moveHome(changeMasks);
            }
        } else if (keycode == IM_VK_END) { // move end
            if (!m_pIC->isEmpty()) {
                changeMasks |= KEYEVENT_USED;
                _moveEnd(changeMasks);
            }
        }
    } else {
        goto RETURN;
    }

PROCESSED:;
    m_pHotkeyProfile->rememberLastKey(key);

RETURN:;

	if (isKeyStroke) {
		setOpMode(XHVOM_INPUT);
	} else {
		setOpMode(XHVOM_SELECT);
	}

#ifdef DEBUG
    printf("   |-->(Mask=0x%x)\n", changeMasks);
#endif

    updateWindows(changeMasks);
    return changeMasks & KEYEVENT_USED;
}
void addPar(int no = 1)
{
  clicks += no;
  IncFactor = PI/(clicks/2.0);
  updateWindows();
}