Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added term windows and multiscreen support to keyboard lib #1539

Merged
merged 1 commit into from Dec 24, 2015

Conversation

mpmxyz
Copy link
Contributor

@mpmxyz mpmxyz commented Nov 28, 2015

A crude but working test program:
wget 'https://raw.githubusercontent.com/mpmxyz/ocprograms/dev/home/bin/split.lua'
Some programs have to be modified to support term windows properly. (e.g. to use term.getGlobalArea instead of gpu.getResolution)
I'd do that in a next step.

You can change the focus between term windows by using Ctrl [+ Shift] + Tab
Screenshots of the change:
https://raw.githubusercontent.com/mpmxyz/ocprograms/dev/pics/multiscreen1.png
https://raw.githubusercontent.com/mpmxyz/ocprograms/dev/pics/multiscreen2.png

API changes

  • keyboard
    • changed
      • isAltDown, isControlDown, isKeyDown, isShiftDown
        • added optional 'address' parameter to specify the keyboard being used
        • defaults to the address of the primary keyboard
  • term
    • added
      • term.newWindow([x:number, y:number, width:number, height:number, gpu:table]) -> window:table
        • creates a new term window object
        • x, y, width and height define the position and size of the window
          • negative values indicate a position relative to the lower right part of the screen
            • x = -10 -> Window begins 10 characters from the right border of the screen.
            • height = -2 -> Window extends to the second last line of the screen.
          • default: 1, 1, -1, -1
        • gpu == nil -> always use primary gpu
      • term.setWindow(window:table) -> oldWindow:table
        • sets the window used by the current process
        • e.g. term.read is now redirected to this object
      • term.getWindow() -> window:table
      • The following functions are available in both the library and in the window object. ("win:func()" vs. "term.func()")
        • setArea(x:number, y:number, width:number, height:number) -> oldX:number, oldY:number, oldWidth:number, oldHeight:number
        • getArea() -> x:number, y:number, width:number, height:number
        • setGPU([gpu:table]) -> oldGPU:table
        • getGPU() -> gpuBeingSet:table, gpuBeingUsed:table
          • gpuBeingUsed = gpuBeingSet or component.gpu
        • getGlobalArea() -> x:number, y:number, width:number, height:number
        • toGlobal(x:number, y:number) -> x:number, y:number
          • transforms window coordinates to screen coordinates
        • toLocal(x:number, y:number) -> x:number, y:number
          • transforms screen coordinates to window coordinates
        • focus()
          • changes the focus to this window
          • Focus changes are only applied after the next "term_focus" signal which is queued after a change.
        • unfocus()
          • removes the focus on this window and changes it to the next known one
          • Focus changes are only applied after the next "term_focus" signal which is queued after a change.
        • focusNext()
          • changes the focus to the next window.
          • Focus changes are only applied after the next "term_focus" signal which is queued after a change.
        • focusPrevious()
          • changes the focus to the previous window
          • Focus changes are only applied after the next "term_focus" signal which is queued after a change.
        • hasFocus() -> isInFocus:boolean, screenAddress:string, keyboardAddress:string
          • returns true if this window is in focus
          • additionally returns the screen and window addresses that are used for event processing

@fnuecke fnuecke added this to the v1.6.0 milestone Nov 28, 2015
@fnuecke
Copy link
Member

fnuecke commented Nov 28, 2015

Sounds great! Will give it a spin in a bit. Thanks again.

@mpmxyz
Copy link
Contributor Author

mpmxyz commented Nov 28, 2015

Since I'm already working on it, I found a part in event.lua that I don't understand:

  local deadline = seconds and
                   (computer.uptime() + seconds) or
                   (filter and math.huge or 0)

Why is the default deadline 0 if you haven't got a filter?
I assume that this is not intended because calling event.pull() without arguments causes it to only return nil when a timer ticks.
Small Update: edit.lua is taking a bit more time than anticipated because I'm also implementing proper wide character support.

@mpmxyz
Copy link
Contributor Author

mpmxyz commented Dec 4, 2015

I updated all programs that are included in OpenOS and added wide character support to edit.lua.
After I fixed an annoying out of memory error I also squashed all commits.

@fnuecke
Copy link
Member

fnuecke commented Dec 20, 2015

Just to let you know, haven't forgotten about this, just haven't come around to test it yet, sorry!

…ing though)

Also added wide character support to edit.lua
@mpmxyz
Copy link
Contributor Author

mpmxyz commented Dec 24, 2015

No problem. I've implemented a small workaround for #1545.

@fnuecke fnuecke merged commit 29c49e0 into MightyPirates:master-MC1.7.10 Dec 24, 2015
@fnuecke
Copy link
Member

fnuecke commented Dec 24, 2015

All right, looks good from what I've tested (just had to fix the workaround). Thanks again!
Pinging @payonel since this may impact some things in your coreutils rewrite.

@payonel
Copy link
Member

payonel commented Dec 24, 2015

@mpmxyz this work is pretty cool. The features you've built here don't conflict with anything I'm doing (phew!) but definitely I'll have to merge some of my code. My concern is that I would struggle to test my merge sufficiently; you know your code intent better than I would. We should work together on this. Could I merge this with one of my branches and then PR to your repo and then you retest your features?

@mpmxyz
Copy link
Contributor Author

mpmxyz commented Dec 25, 2015

That would be okay. I'd just have to improve my "git fu". ;-)

@mpmxyz
Copy link
Contributor Author

mpmxyz commented Jan 28, 2016

I've been busy for some time. But initial tests look good. I also found out that I forgot to upload a file to try my example program.

wget 'https://raw.githubusercontent.com/mpmxyz/ocprograms/dev/home/bin/split.lua'
wget 'https://raw.githubusercontent.com/mpmxyz/ocprograms/dev/home/bin/newwin.lua'
split
Expect to see two shells per screen after that. You can change the focus by using Ctrl [+ Shift] + Tab or by using your mouse.
Remember: split.lua is just a hack to demonstrate what is possible with "multitasking"! I'm still waiting for a "real" implementation. (It's going to be a big rewrite to the event/signal system.)

@payonel
Copy link
Member

payonel commented Jan 31, 2016

@mpmxyz I'd like to alter term a bit - dialog at length in this github comment section might get clunky, and your github email isn't real. Can you join #oc so we can chat?

@mpmxyz
Copy link
Contributor Author

mpmxyz commented Jan 31, 2016

I'm on #oc now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants