From 9c686676c3919add3edb5dff3423fc763599460f Mon Sep 17 00:00:00 2001 From: Jeffrey Phillips Freeman <the@jeffreyfreeman.me> Date: Tue, 28 Apr 2020 17:11:27 +0200 Subject: [PATCH] A hacky fix to the resizeterm bug. --- lib/aethyr/core/connection/server.rb | 13 ++++++++++++- lib/aethyr/core/render/display.rb | 8 ++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/lib/aethyr/core/connection/server.rb b/lib/aethyr/core/connection/server.rb index e0e2451..bb6db53 100644 --- a/lib/aethyr/core/connection/server.rb +++ b/lib/aethyr/core/connection/server.rb @@ -58,7 +58,6 @@ module Aethyr players = Set.new() loop do - did_something = false # handle the listener #ready, _, _ = IO.select([listener]) socket, addr_info = listener.accept_nonblock(exception: false) @@ -75,6 +74,18 @@ module Aethyr end end + # TODO this is a hack to fix a bug from calling resizeterm + #check if global refresh is needed + need_refresh = false + players.each do |player| + need_refresh = true if player.display.global_refresh + end + if need_refresh + players.each do |player| + player.display.layout + end + end + end clean_up_children diff --git a/lib/aethyr/core/render/display.rb b/lib/aethyr/core/render/display.rb index fe0e944..fdf1508 100644 --- a/lib/aethyr/core/render/display.rb +++ b/lib/aethyr/core/render/display.rb @@ -83,6 +83,7 @@ class Display end def layout(layout: @layout_type) + set_term puts "layout #{layout} set for resolution #{@width}x#{@height}" @layout_type = layout if @layout_type == :wide && @height >= 60 && @width >= 300 @@ -128,9 +129,16 @@ class Display @width = resolution[0] @height = resolution[1] Ncurses.resizeterm(@height, @width) + @global_refresh = true layout end + def global_refresh + retval = @global_refresh + @global_refresh = false + return retval + end + def echo? @echo end -- GitLab