maiha/crt.cr

Window#move does not change the window's position and returns -1

Closed this issue · 4 comments

I'm trying to draw a window above another window, but it remains at the starting position

Code:

win = Crt::Window.new(8, 16)
win.move(30, 30)
win.border
win.refresh

Result
image

maiha commented

I'm not well familiar with curses , but I think move is an operation about text.
Could you try x, y on Window ?

module Crt
  class Window
     def initialize(@row = -1, @col = -1, y = 0, x = 0)

Yup. If I'm changing x and y then it works nice.
The solution is inheritance then I guess? Something like this:

class SecondWindow < Crt::Window
  def initialize(@row = -1, @col = -1, y = 3, x = 3)
    Crt.init
    @row = Crt.y if @row < 0
    @col = Crt.x if @col < 0
    @winp = LibNcursesw.newwin(@row, @col, y, x)
  end
end

image

maiha commented

Running the crystal and c libraries works much the same. So it would be nice to find a sample of c that works for ncurses multiple windows first.

Then, I can help you with how to translate the c sample to the crystal, or how to write it in crt.cr.

Added the desired function. See #18