[Bf-funboard] Copy/Paste/Cut hotkeys, problems, use in textfields/numfields, pasting 3d text

Luke Wenke bf-funboard@blender.org
Fri, 10 Oct 2003 16:35:11 +1000


> But then you would also need to implement an OS X variant that uses
> the, obvious to any Mac user, Command-C/X/V combination.

In Blender's text editor, there have been commands for copy/paste/cut for a
long time, so they are probably also in OSX. These only copy/paste/cut
functions work within the blender text editor though, and not between
blender and other programs. (Except for in Windows, though you use different
hotkeys) As far as the Mac goes, maybe command-c/x/v is used in the blender
editor now. Those same hotkeys would be reused.

> Now if Blender would be integrated with the OS more (as far as the UI
> goes) such changes would make sense. But as it is Blender neither has
> the "look'n'feel" of any OS I know an can thus freely use different
> conventions for the copying, imo.
But the hotkeys for copying/pasting/cutting text within blender's text
editor are *already* ctrl-c/v/x (or probably command-c/v/x on the Mac)

BTW, this is how you could handle different OS's.
CopySelectedText() {
  Copy text to Blender text memory.
  CopyTextToOSClipboard(text)
}

CopyTextToOSClipboard(text) {
  #IFDEF OS_WIN32:
     windows code
  #ENDIF

  #IFDEF OS_OSX:
     osx code
  #ENDIF

  #IFDEF OS_LINUX:
     linux code
  #ENDIF
}
Those are just ideas though. I don't have any idea what Blender's code looks
like. Note that all of the OS's don't need to be implimented (there could
just be a "to do" comment) - the Windows one could just be done for now
(since it is already kind of implemented, except for some problems like the
hotkeys and copy/pasting problems).

> That's a common Unix/Win/Mac newline character problem I guess, but for
> that and all the copy/paste and similiar problems one would either have
> to upgrade GHOST a bit or maybe step back and integrate Blender with
> the OS without the GHOST layer. And I don't think anyone is keen on
> doing that :o)

I don't know anything about GHOST... but anyway, there could be two
functions involved:

CopyTextToOSClipboard(text) (mentioned earlier) and
GetTextFromOSClipboard().

This is part of the CopyTextToOSClipboard(text) function:
  #IFDEF OS_WIN32:
    for (int i=0; i <= strlen(text); i++) {
      if (text[i] == one of those square characters) {
        text[i] = corrected newline character;
      }
    }
    CopyToWindowsClipboard(text, "string type");
  #ENDIF
That code might have problems with it or something, but you get the idea.

This is from GetTextFromOSClipboard():
  #IFDEF OS_WIN32:
    text = CopyFromWindowsClipboard("string type");
    if (text == nothing) return;
    for (int i=0; i <= strlen(text); i++) {
      if (text[i] == one of those characters that cause python errors) {
        delete the character and shuffle the rest of the characters along.
      }
    }
  #ENDIF

- Luke.