StringObj ws_get_cutbuffer(DisplayObj d, int n) { if ( n == 0 ) return get_clipboard_data(d, NAME_text); /* DEFAULT? */ Cprintf("Cannot access cut-buffers other than 0\n"); fail; }
static QByteArray readClipboardBuff(const char *type) { char *pbuffer; if (is_clipboard_format_present(type) == 0) { int size = get_clipboard_data(type, &pbuffer); if (size != -1 && pbuffer) { const QByteArray result = QByteArray(pbuffer, size); free(pbuffer); return result; } } return QByteArray(); }
// Get the prevent sleep state std::string ClipboardNDK::getText() { char* pbuffer=0; int ret=get_clipboard_data("text/plain", &pbuffer); if (ret>0){ //return the clip board string. std::string data(pbuffer); free(pbuffer); return data; }else{ //something bad happened,return empty string. free(pbuffer); return ""; } }
void QBBClipboard::readClipboardBuff(const char *type) { char *pbuffer; if (is_clipboard_format_present(type) == 0) { get_clipboard_data(type, &pbuffer); if (pbuffer) { QString qtype = type; #if defined(QBBCLIPBOARD_DEBUG) qDebug() << "QBB: clipboard has " << qtype; #endif mMimeData->setData(qtype, pbuffer); delete pbuffer; } } }
int not_main(int argc, char **argv) { LPWSTR data; _wfopen_s(&flog, L"console.log", L"w"); if(data = get_clipboard_data()) { fprintf(flog, "%S\r\n", data); } else { fprintf(flog, "Error. I don't know, dude.\r\n"); } fclose(flog); return 0; }
Any ws_get_selection(DisplayObj d, Name which, Name target) { return get_clipboard_data(d, target); }
bool CLineInput::Manipulate(IInput::CEvent e, char *pStr, int StrMaxSize, int *pStrLenPtr, int *pCursorPosPtr) { int CursorPos = *pCursorPosPtr; int Len = *pStrLenPtr; bool Changes = false; if(CursorPos > Len) CursorPos = Len; int Code = e.m_Unicode; int k = e.m_Key; // 127 is produced on Mac OS X and corresponds to the delete key if (!(Code >= 0 && Code < 32) && Code != 127) { char Tmp[8]; int CharSize = str_utf8_encode(Tmp, Code); if (Len < StrMaxSize - CharSize && CursorPos < StrMaxSize - CharSize) { mem_move(pStr + CursorPos + CharSize, pStr + CursorPos, Len-CursorPos+1); // +1 == null term for(int i = 0; i < CharSize; i++) pStr[CursorPos+i] = Tmp[i]; CursorPos += CharSize; Len += CharSize; Changes = true; } } if(e.m_Flags&IInput::FLAG_PRESS) { // backspace, ctrl+backspace, ctrl+w if ((k == KEY_BACKSPACE || (k == KEY_w && e.GetKeyMods()&(KEYMOD_LCTRL|KEYMOD_RCTRL))) && CursorPos > 0) { int NewCursorPos; if(e.GetKeyMods()&(KEYMOD_LCTRL|KEYMOD_RCTRL)) NewCursorPos = str_skip_word_backward(pStr, CursorPos); else NewCursorPos = str_utf8_rewind(pStr, CursorPos); int CharSize = CursorPos-NewCursorPos; mem_move(pStr+NewCursorPos, pStr+CursorPos, Len - NewCursorPos - CharSize + 1); // +1 == null term CursorPos = NewCursorPos; Len -= CharSize; Changes = true; } // ctrl+u else if(k == KEY_u && e.GetKeyMods()&(KEYMOD_LCTRL|KEYMOD_RCTRL)) { mem_move(pStr, pStr+CursorPos, Len - CursorPos + 1); // +1 == null term Len -= CursorPos; CursorPos = 0; Changes = true; } else if (k == KEY_DELETE && CursorPos < Len) { int p = str_utf8_forward(pStr, CursorPos); int CharSize = p-CursorPos; mem_move(pStr + CursorPos, pStr + CursorPos + CharSize, Len - CursorPos - CharSize + 1); // +1 == null term Len -= CharSize; Changes = true; } else if (k == KEY_LEFT && CursorPos > 0) { if(e.GetKeyMods()&(KEYMOD_LCTRL|KEYMOD_RCTRL)) CursorPos = str_skip_word_backward(pStr, CursorPos); else CursorPos = str_utf8_rewind(pStr, CursorPos); } else if (k == KEY_RIGHT && CursorPos < Len) { if(e.GetKeyMods()&(KEYMOD_LCTRL|KEYMOD_RCTRL)) CursorPos = str_skip_word_forward(pStr, CursorPos); else CursorPos = str_utf8_forward(pStr, CursorPos); } else if (k == KEY_HOME) CursorPos = 0; else if (k == KEY_END) CursorPos = Len; // ctrl+v -- paste else if(k == KEY_v && e.GetKeyMods()&(KEYMOD_LCTRL|KEYMOD_RCTRL)) { char aBuf[MAX_SIZE]; str_copy(aBuf, pStr + CursorPos, sizeof(aBuf)); int size = get_clipboard_data(pStr + CursorPos, MAX_SIZE - CursorPos); if(size >= 0 && size < MAX_SIZE - CursorPos) // success { CursorPos += size; Len += size; str_copy(pStr + CursorPos, aBuf, MAX_SIZE - CursorPos); } Changes = true; } } *pCursorPosPtr = CursorPos; *pStrLenPtr = Len; return Changes; }