Pasting code into Matrix Brandy

Is it possible to paste code from the clipboard directly into Matrix Brandy's immediate mode? I tried typing Ctrl+V, but that seems to have no effect, nor is there an Edit.. Paste menu option like there is in BeebEm. I also tried right-clicking (often that produces a Edit Context Menu in Windows) but nothing.

Comments

  • In Linux you can paste into the controlling terminal (the one you ran Brandy from). Last time I tried this in Windows, it didn't work. Brandy itself has no interaction with the clipboard. Right-clicking will just send a right-click event via SDL into the MOUSE X,Y,B[,C] command.

    But it's a thought on future functionality, I would probably implement it like a *CBEXEC command (like *EXEC, but sourcing from the clipboard instead of a file).
  • Richard_Russell
    edited November 2023
    Soruk wrote: »
    In Linux you can paste into the controlling terminal (the one you ran Brandy from).
    Ah, I was running the GUI version (so no 'terminal' as such), perhaps if I was to run the console version (is that sbrandy?) I could do that - although the program I wanted to paste uses graphics.
    But it's a thought on future functionality, I would probably implement it like a *CBEXEC command (like *EXEC, but sourcing from the clipboard instead of a file).
    What's your objection to Ctrl+V? That works in BB4W, BBCSDL and BBCTTY.

    Whilst on that topic what 'control codes' does Matrix Brandy currently accept in immediate mode? I would have expected Ctrl+N (VDU 14, enter paged mode) to work at the very least, but on a quick test it doesn't. I tried typing LIST Ctrl+N <enter> but it doesn't pause the listing on each screen as it would on a BBC Micro (and I assume RISC OS).
  • Soruk wrote: »
    In Linux you can paste into the controlling terminal (the one you ran Brandy from).
    Ah, I was running the GUI version (so no 'terminal' as such), perhaps if I was to run the console version (is that sbrandy?) I could do that - although the program I wanted to paste uses graphics.
    It should work (aside from the graphics. In Linux if you run the graphical Brandy from a terminal window, typing/pasting/middle-clicking in the terminal window causes the input to go to the Brandy window.
    But it's a thought on future functionality, I would probably implement it like a *CBEXEC command (like *EXEC, but sourcing from the clipboard instead of a file).
    What's your objection to Ctrl+V? That works in BB4W, BBCSDL and BBCTTY.
    That would break any program looking for CTRL-V by checking if GET=22. In some systems SHIFT-Insert seems to be a synonym of CTRL-V. and probably safer as the BBC didn't have an Insert key.
    Whilst on that topic what 'control codes' does Matrix Brandy currently accept in immediate mode? I would have expected Ctrl+N (VDU 14, enter paged mode) to work at the very least, but on a quick test it doesn't. I tried typing LIST Ctrl+N <enter> but it doesn't pause the listing on each screen as it would on a BBC Micro (and I assume RISC OS).
    In the case of CTRL-N, upstream Brandy used that and CTRL-P for line editing, same as you can do with the cursor keys - possibly useful to vi users? Way back when (October 2018), I implemented *FX44 (deprecated - from later tonight's nightly build use *FX163,4,y) to switch it between the default mode (1) or send the control codes (0), with the default being 1, same as upstream behaviour. I've checked in a tiny change that defaults this to 0, so it defaults to BBC/RISC OS behaviour.
    (Reason for deprecation: I shouldn't really trample on other OSBYTE numbers, even if they're implemented by an application ROM - 163 is for application support and nothing is allocated for X<128.)
  • Richard_Russell
    edited November 2023
    Soruk wrote: »
    That would break any program looking for CTRL-V by checking if GET=22.
    I don't see why. Consider Ctrl+U, which has meant clear line in INPUT or Immediate Mode right back to the BBC Micro (it works in Brandy too); that doesn't "break" a program looking for Ctrl+U by checking if GET=21!

    So if Ctrl+U has acted as a line-editing code 'forever' without impacting on GET, I can't see any reason why Ctrl+V shouldn't act as 'paste' without impacting on GET. There's no difference in principle, is there?
  • The difference I see is that CTRL-V to paste text, should GET return 22 or the first of the characters in the clipboard?

    Additionally, it appears there's a catch, I woul;d need to write (or borrow an existing GPL library) to read the clipboard as SDL 1.2 has no knowledge. I did find this https://playcontrol.net/ewing/jibberjabber/SDL_ClipboardPrototype.html but that needs more investigation to see if it's suitable.
  • Soruk wrote: »
    The difference I see is that CTRL-V to paste text, should GET return 22 or the first of the characters in the clipboard?
    In my BASICs 'paste' is not intended for that use. Rather it is a (kind of) line-editing operation intended only for use in INPUT or Immediate Mode. Hence Ctrl+V is handled, like Ctrl+U, in the equivalent routine to OSWORD 0, not by GET.

    It's true that the behaviour of 'paste' differs between my BASICs written in assembler code (BB4W and the 32-bit x86 editions of BBCSDL) and those written in C (the rest). But that's an accident of history.
    Additionally, it appears there's a catch, I woul;d need to write (or borrow an existing GPL library) to read the clipboard as SDL 1.2 has no knowledge.
    Isn't porting Matrix Brandy to SDL2 still on the cards? That ought to be easy so long as you use Surfaces rather than Textures (there's even an automatic translator, I believe).
    I did find this https://playcontrol.net/ewing/jibberjabber/SDL_ClipboardPrototype.html but that needs more investigation to see if it's suitable.
    Rather than use some untried third-party library why not copy the clipboard code from SDL2: principally in SDL_waylandclipboard.c, SDL_x11clipboard.c, SDL_windowsclipboard.c (and SDL_os2video.c if you want Mac support)?
Sign In or Register to comment.