/* ------------------------------------------------------------ */ int CopyToClipboard(const wchar_t *Data) { Clipboard clip; if (!clip.Open()) return FALSE; BOOL ret = clip.Copy(Data); clip.Close(); return ret; }
void Grabber::CopyGrabbedArea(int Append, int VerticalBlock) { if (GArea.X1 < 0) return; int X1,Y1,X2,Y2; X1=Min(GArea.X1,GArea.X2); X2=Max(GArea.X1,GArea.X2); Y1=Min(GArea.Y1,GArea.Y2); Y2=Max(GArea.Y1,GArea.Y2); int GWidth=X2-X1+1,GHeight=Y2-Y1+1; int BufSize=(GWidth+3)*GHeight; FAR_CHAR_INFO* CharBuf=new FAR_CHAR_INFO[BufSize], *PtrCharBuf; wchar_t *CopyBuf=(wchar_t *)xf_malloc(BufSize*sizeof(wchar_t)), *PtrCopyBuf; WORD Chr; GetText(X1,Y1,X2,Y2,CharBuf,BufSize*sizeof(FAR_CHAR_INFO)); *CopyBuf=0; PtrCharBuf=CharBuf; PtrCopyBuf=CopyBuf; for (int I=0; I<GHeight; I++) { if (I>0) { *PtrCopyBuf++=L'\r'; *PtrCopyBuf++=L'\n'; *PtrCopyBuf=0; } for (int J=0; J<GWidth; J++, ++PtrCharBuf) { WORD Chr2 = PtrCharBuf->Char; Chr=PtrCharBuf->Char; if (Opt.CleanAscii) { switch (Chr2) { case L'.': Chr=L'.'; break; case 0x07: Chr=L'*'; break; case 0x10: Chr=L'>'; break; case 0x11: Chr=L'<'; break; case 0x18: case 0x19: Chr=L'|'; break; case 0x1E: case 0x1F: Chr=L'X'; break; case 0xFF: Chr=L' '; break; default: if (Chr2 < 0x20) Chr=L'.'; else if (Chr2 < 0x100) Chr=Chr2; break; } } if (Opt.NoGraphics && Chr2 >=0xB3 && Chr2 <= 0xDA) { switch (Chr2) { case 0xB3: case 0xBA: Chr=L'|'; break; case 0xC4: Chr=L'-'; break; case 0xCD: Chr=L'='; break; default: Chr=L'+'; break; } } *PtrCopyBuf++=Chr; *PtrCopyBuf=0; } for (int K=StrLength(CopyBuf)-1; K>=0 && CopyBuf[K]==L' '; K--) CopyBuf[K]=0; PtrCopyBuf=CopyBuf+StrLength(CopyBuf); } Clipboard clip; if (clip.Open()) { if (Append) { wchar_t *AppendBuf=clip.Paste(); if (AppendBuf) { int add=0; size_t DataSize=StrLength(AppendBuf); if (AppendBuf[DataSize-1]!=L'\n') { add=2; } AppendBuf=(wchar_t *)xf_realloc(AppendBuf,(DataSize+BufSize+add)*sizeof(wchar_t)); wmemcpy(AppendBuf+DataSize+add,CopyBuf,BufSize); if (add) wmemcpy(AppendBuf+DataSize,L"\r\n",2); xf_free(CopyBuf); CopyBuf=AppendBuf; } } if (VerticalBlock) clip.CopyFormat(FAR_VerticalBlock_Unicode,CopyBuf); else clip.Copy(CopyBuf); clip.Close(); } if (CopyBuf) xf_free(CopyBuf); delete[] CharBuf; }
Clipboard* Command::CopyClipboard () { Clipboard* cb = GetClipboard(); return (cb == nil) ? nil : cb->Copy(); }
// keys_edit: Keys for the 2d editor // ------------------------------ >> void keys_edit() { if (!map.opened) return; // Scroll up if (binds.pressed("view_up")) { yoff += ((MAJOR_UNIT / (int)zoom)) + 1; force_map_redraw(true, true); } // Scroll down if (binds.pressed("view_down")) { yoff -= ((MAJOR_UNIT / (int)zoom)) + 1; force_map_redraw(true, true); } // Scroll left if (binds.pressed("view_left")) { xoff += ((MAJOR_UNIT / (int)zoom)) + 1; force_map_redraw(true, true); } // Scroll right if (binds.pressed("view_right")) { xoff -= ((MAJOR_UNIT / (int)zoom)) + 1; force_map_redraw(true, true); } // Zoom in if (binds.pressed("view_zoomin")) view_zoom(true); // Zoom out if (binds.pressed("view_zoomout")) view_zoom(false); // Center view on mouse if (binds.pressed("view_mousecenter")) { xoff = -m_x(mouse.x) / MAJOR_UNIT; yoff = -m_y(mouse.y) / MAJOR_UNIT; force_map_redraw(true, true); } // Set offsets to 0, 0 if (binds.pressed("view_origin")) { xoff = yoff = 0; force_map_redraw(true, true); } // Vertices mode if (binds.pressed("mode_vertices")) change_edit_mode(0); // Linedefs mode if (binds.pressed("mode_linedefs")) change_edit_mode(1); // Sectors mode if (binds.pressed("mode_sectors")) change_edit_mode(2); // Things mode if (binds.pressed("mode_things")) change_edit_mode(3); // Change mode if (binds.pressed("mode_change")) cycle_edit_mode(); // Increase grid size if (binds.pressed("view_increasegrid")) { increase_grid(); force_map_redraw(false, true); } // Decrease grid size if (binds.pressed("view_decreasegrid")) { decrease_grid(); force_map_redraw(false, true); } // Clear selection if (binds.pressed("edit_clearselection")) { clear_selection(); force_map_redraw(true); } // Delete item if (binds.pressed("edit_deleteitem")) { if (edit_mode == 0) delete_vertex(); if (edit_mode == 1) delete_line(); if (edit_mode == 2) delete_sector(); if (edit_mode == 3) delete_thing(); force_map_redraw(true); } // Create item if (binds.pressed("edit_createitem")) { if (edit_mode == 0) { if (!selection()) create_vertex(); else create_lines(false); force_map_redraw(true); return; } if (edit_mode == 1) { if (selection()) create_sector(); force_map_redraw(true); return; } if (edit_mode == 3) { create_thing(); force_map_redraw(true); return; } binds.clear("edit_createitem"); } // Sector height quick changes (8 units) if (binds.pressed("sector_upfloor8")) { if (edit_mode == 2) sector_changeheight(true, 8); } if (binds.pressed("sector_downfloor8")) { if (edit_mode == 2) sector_changeheight(true, -8); } if (binds.pressed("sector_upceil8")) { if (edit_mode == 2) sector_changeheight(false, 8); } if (binds.pressed("sector_downceil8")) { if (edit_mode == 2) sector_changeheight(false, -8); } if (binds.pressed("sector_upboth8")) { if (edit_mode == 2) { sector_changeheight(true, 8); sector_changeheight(false, 8); } } if (binds.pressed("sector_downboth8")) { if (edit_mode == 2) { sector_changeheight(true, -8); sector_changeheight(false, -8); } } // Sector height quick changes (1 unit) if (binds.pressed("sector_upfloor")) { if (edit_mode == 2) sector_changeheight(true, 1); } if (binds.pressed("sector_downfloor")) { if (edit_mode == 2) sector_changeheight(true, -1); } if (binds.pressed("sector_upceil")) { if (edit_mode == 2) sector_changeheight(false, 1); } if (binds.pressed("sector_downceil")) { if (edit_mode == 2) sector_changeheight(false, -1); } if (binds.pressed("sector_upboth")) { if (edit_mode == 2) { sector_changeheight(true, 1); sector_changeheight(false, 1); } } if (binds.pressed("sector_downboth")) { if (edit_mode == 2) { sector_changeheight(true, -1); sector_changeheight(false, -1); } } // Flip line if (binds.pressed("line_flip")) { if (edit_mode == 1) line_flip(true, false); force_map_redraw(true); } // Swap line sides if (binds.pressed("line_swapsides")) { if (edit_mode == 1) line_flip(false, true); force_map_redraw(true); } // Flip both line direction and sides if (binds.pressed("line_flipboth")) { if (edit_mode == 1) line_flip(true, true); force_map_redraw(true); } // Begin line draw if (binds.pressed("line_begindraw")) { if (!line_draw) line_draw = true; binds.clear("line_begindraw"); } // Begin rectangle draw if (binds.pressed("line_begindraw_rect")) { if (!line_draw) { line_draw = true; sel_box.set(mouse.x, mouse.y, mouse.x, mouse.y); } binds.clear("line_begindraw_rect"); } // Undo if (binds.pressed("edit_undo")) { undo(); clear_selection(); hilight_item = -1; force_map_redraw(true, true); //map_changelevel(3); map.change_level(MC_NODE_REBUILD); binds.clear("edit_undo"); } // Edit item if (binds.pressed("edit_edititem")) { edit_item(); binds.clear("edit_edititem"); } // Merge sectors if (binds.pressed("sector_merge")) { sector_merge(false); binds.clear("sector_merge"); } // Join sectors if (binds.pressed("sector_join")) { sector_merge(true); binds.clear("sector_join"); } if (binds.pressed("view_3dmode")) { binds.clear("view_3dmode"); binds.clear("3d_exit"); start_3d_mode(); } if (binds.pressed("open_console")) { binds.clear("open_console"); popup_console(); } if (binds.pressed("copy")) { binds.clear("copy"); clipboard.Copy(); } if (binds.pressed("paste")) { binds.clear("paste"); paste_mode = true; clear_selection(); } if (binds.pressed("cancel_paste")) { binds.clear("cancel_paste"); paste_mode = false; force_map_redraw(true, false); } }
void DrawImportPasteCmd::Execute () { if(!_executed) { Clipboard* cb = GetClipboard(); Iterator it; cb->First(it); GraphicComp* gcomp = cb->GetComp(it); cb->Next(it); if(cb->Done(it) && gcomp->IsA(DRAW_IDRAW_COMP) || gcomp->IsA(FRAME_IDRAW_COMP)) { gcomp->First(it); /* move to background frame */ DrawEditor* ed = (DrawEditor*)GetEditor(); FrameNumberState* fnumstate = ed->framenumstate(); int origfnum = fnumstate->framenumber(); int currfnum = 0; Append(new MoveFrameCmd(ed, -origfnum, true /* allowbg */)); /* paste contents of background frame */ FrameComp* fcomp = (FrameComp*) (gcomp->GetComp(it)->IsA(FRAME_COMP) ? gcomp->GetComp(it) : nil); if (fcomp) { while(!gcomp->Done(it)) { gcomp->Remove(it); Clipboard* newcb = new Clipboard(); Iterator jt; fcomp->First(jt); while(!fcomp->Done(jt)) { newcb->Append(fcomp->GetComp(jt)); fcomp->Remove(jt); } Append(new PasteCmd(ed, newcb)); delete fcomp; /* while more frames move to next frame and paste (create new frame if necessary) */ if(!gcomp->Done(it)) { currfnum++; fcomp = (FrameComp*) (gcomp->GetComp(it)->IsA(FRAME_COMP) ? gcomp->GetComp(it) : nil); if(currfnum>=ed->NumFrames()) Append(new CreateMoveFrameCmd(ed)); else Append(new MoveFrameCmd(ed, 1, true /* allowbg */)); } } } /* move to original frame */ Append(new MoveFrameCmd(ed, origfnum-currfnum, true /* allowbg */)); } else { Append(new PasteCmd(GetEditor(), cb->Copy())); Iterator i; for (cb->First(i); !cb->Done(i); cb->Next(i)) { GraphicComp* gcomp = cb->GetComp(i); if (gcomp->IsA(EDGE_COMP)) { EdgeComp* comp = (EdgeComp*)gcomp; NodeComp* start = node(cb, comp->GetStartNode()); NodeComp* end = node(cb, comp->GetEndNode()); EdgeConnectCmd* cmd = new EdgeConnectCmd(GetEditor(), comp, start, end); Append(cmd); } } } } MacroCmd::Execute(); _executed = 1; }