Beispiel #1
0
String Pasteboard::plainText(Frame* frame)
{
    if (::IsClipboardFormatAvailable(CF_UNICODETEXT) && ::OpenClipboard(m_owner)) {
        HANDLE cbData = ::GetClipboardData(CF_UNICODETEXT);
        if (cbData) {
            UChar* buffer = static_cast<UChar*>(GlobalLock(cbData));
            String fromClipboard(buffer);
            GlobalUnlock(cbData);
            ::CloseClipboard();
            return fromClipboard;
        }
        ::CloseClipboard();
    }

    if (::IsClipboardFormatAvailable(CF_TEXT) && ::OpenClipboard(m_owner)) {
        HANDLE cbData = ::GetClipboardData(CF_TEXT);
        if (cbData) {
            char* buffer = static_cast<char*>(GlobalLock(cbData));
            String fromClipboard(buffer);
            GlobalUnlock(cbData);
            ::CloseClipboard();
            return fromClipboard;
        }
        ::CloseClipboard();
    }

    return String();
}
Beispiel #2
0
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
void cpaste()                              /* Paste: called either from te.c */
{                                          /*                   or from le.c */
  if (!cpopen || cpempt) {                 /* so have to work in any LE mode */
    if (cb_new_data) fromClipboard();
  }
  else   clearClipboard(); //<- clear system Clipboard to avoid inconsistency
  if (cpempt) exc(E_NOOP); //   (when 1st paste resets cpopen, and second one
  int oldTx = Lwnd? Lx:Tx; //       gets data from Clipboard instead of LCtxt)
  cptinit(true);
  cpclose(); TxTop(LCtxt); if (qTxBottom(LCtxt)) return;
//
// In entering-argument mode, paste only the content of first line (disabling
// full-line paste) and silently ignore the rest; the same when block selected
// (only when it is 1-character wide, "tall cursor" mode)
//
       if (leARGmode) pasteFromLCtxt(false);
  else if (BlockMark) {
    if (BlockTx != Tx) exc(E_BLOCKOUT);
    else {
      static comdesc cpPaste = { LE_PASTE, pasteFromClbuf, 0 };
      int len = TxRead(LCtxt, clbuf);
      if (len == 0) return;
      if (clbuf[0] == CpSCH_NEW_LINE) cclen = aftotc(clbuf+1, len-1, ccbuf);
      else                            cclen = aftotc(clbuf,   len,   ccbuf);
      tallblockop(&cpPaste);
  } }
  else {
    pasteFromLCtxt(true);     // First stored line may be pasted either as line
    while(!qTxBottom(LCtxt)){ // or as characters, exit LE mode for the rest of
      if (Lwnd) ExitLEmode(); // save buffer (if paste isn't finished) and move
      Tx = oldTx;     Ty++;   // cursor to saved position one line below, rinse
      pasteFromLCtxt(true);   // and repeat pasting.
} } }
Beispiel #3
0
static void copyFromClipboard(Sprite* sprite)
{
	if(sprite->editPalette)
		pasteColor(sprite);

	s32 size = sprite->size * sprite->size * TIC_PALETTE_BPP / BITS_IN_BYTE;
	u8* buffer = malloc(size);

	if(buffer)
	{
		if(fromClipboard(buffer, size, true, false))
		{
			tic_rect rect = getSpriteRect(sprite);
			s32 r = rect.x + rect.w;
			s32 b = rect.y + rect.h;

			for(s32 y = rect.y, i = 0; y < b; y++)
				for(s32 x = rect.x; x < r; x++)
					setSheetPixel(sprite, x, y, tic_tool_peek4(buffer, i++));

			history_add(sprite->history);
		}

		free(buffer);

	}
}
Beispiel #4
0
static void pasteColor(Sprite* sprite)
{
	fromClipboard(getBankPalette()->data, sizeof(tic_palette), false, true);
	fromClipboard(&getBankPalette()->colors[sprite->color], sizeof(tic_rgb), false, true);
}
Beispiel #5
0
void clipFromCB() { fromClipboard(); cpaste(); }