Ejemplo n.º 1
0
int chkr_PDC_setclipboard(char *contents, long length)
{
   stubs_chkr_check_addr(contents, length, CHKR_RO, "contents");
   return(PDC_setclipboard(contents,length));
}
Ejemplo n.º 2
0
void clipboardTest(WINDOW *win)
{
    static const char *text =
        "This string placed in clipboard by PDCurses test program, testcurs.";
    char *ptr = NULL;
    long i, length = 0;

    mvaddstr(1, 1,
             "This test will display the contents of the system clipboard");

    Continue2();

    scrollok(stdscr, TRUE);
    i = PDC_getclipboard(&ptr, &length);

    switch(i)
    {
    case PDC_CLIP_ACCESS_ERROR:
        mvaddstr(3, 1, "There was an error accessing the clipboard");
        refresh();
        break;

    case PDC_CLIP_MEMORY_ERROR:
        mvaddstr(3, 1,
            "Unable to allocate memory for clipboard contents");
        break;

    case PDC_CLIP_EMPTY:
        mvaddstr(3, 1, "There was no text in the clipboard");
        break;

    default:
        wsetscrreg(stdscr, 0, LINES - 1);
        clear();
        mvaddstr(1, 1, "Clipboard contents...");
        mvprintw(2, 1, "%s\n", ptr);
    }

    Continue2();

    clear();
    mvaddstr(1, 1,
        "This test will place the following string in the system clipboard:");
    mvaddstr(2, 1, text);

    i = PDC_setclipboard(text, strlen(text));

    switch(i)
    {
    case PDC_CLIP_ACCESS_ERROR:
        mvaddstr(3, 1, "There was an error accessing the clipboard");
        break;

    case PDC_CLIP_MEMORY_ERROR:
        mvaddstr(3, 1, "Unable to allocate memory for clipboard contents");
        break;

    default:
        mvaddstr(3, 1, "The string was placed in the clipboard successfully");
    }

    Continue2();
}
Ejemplo n.º 3
0
void CTextEdit::update(int c)
{
	if(_visible)
	{
		bool alwaysFocused = false;
#ifdef NO_MOUSE
		alwaysfocused = true; // If we have no mouse, we can't focus widgets so let's have it always focused.
#endif

		if((_requireFocused ? focused() : true) && (_parent ? _parent->focused() || alwaysFocused : true))
		{
			switch(c)
			{
			case ERR:
				break;
#ifdef __PDCURSES__
			case 3: // copy
				{
					string clipboard = UTIL_Latin1ToUTF8(_text);
					PDC_setclipboard(clipboard.c_str(), clipboard.length());
					break;
				}
			case 22: // paste
				{
					char *clipboard = NULL;
					long length = 0;

					if(PDC_getclipboard(&clipboard, &length) == PDC_CLIP_SUCCESS)
					{
						_text += string(clipboard, length);
						PDC_freeclipboard(clipboard);
					}
					break;
				}
#endif
			case KEY_UP:
				if(!_history.empty())
				{
					if(_selectedHistory > 0)
						_text = _history[--_selectedHistory];
					else if(_selectedHistory == 0)
						_text = _history[0];
				}
				break;
			case KEY_DOWN:
				if(!_history.empty())
				{
					if(_selectedHistory < _history.size() - 1)
						_text = _history[++_selectedHistory];
					else if(_selectedHistory == _history.size() - 1)
						_text = _history[_history.size() - 1];
				}
				break;
			case 8:
			case 127:
			case KEY_BACKSPACE:
			case KEY_DC:
				if(!_text.empty())
					_text.erase(_text.end() - 1);
				break;
			case 27:
				_text.clear();
				break;
			case 10:
			case 13:
#ifdef WIN32
			case PADENTER:
#endif
				if(!_text.empty())
				{
					_history.push_back(_text);
					_selectedHistory = _history.size();
					forward( new CFwdData(_fwdTypeEnter, _text, 0 ));
					_text.clear();
				}
				break;
#ifdef WIN32
			case PADSLASH:
				_text += '/';
				break;
			case PADSTAR:
				_text += '*';
				break;
			case PADMINUS:
				_text += '-';
				break;
			case PADPLUS:
				_text += '+';
				break;
#endif
			default:
				if(c >= 32 && c <= 255)
					_text += c;
				break;
			}
		}

		if(c != ERR)
		{
			move_panel(_panel, _pos.y(), _pos.x());
			top_panel(_panel);
			wclear(_window);

			string temp = UTIL_Latin1ToUTF8(_text);

			// print text
			mvwaddstr(_window, 0, 0, temp.c_str());
		}
	}
}