Forum: Ruby Ruby curses: “Real” borders?

85991f138ede6236f35eb98da22b7b01?d=identicon&s=25 Marvin Gülker (quintus)
on 2013-09-05 15:46
(Received via mailing list)
Attachment: signature.asc (489 Bytes)
Hi there,

I’m just trying to get started with the curses library in Ruby’s
standard library. I wanted to draw a window using the “real” unicode
characters for this, i.e. ─ for horizontal and │ for vertical lines
(UTF-8 being pretty standard now, using - and | is not an option). So I
tried the obvious (the following is a self-contained example):

──────────────────────────────────────
# -*- coding: utf-8 -*-
require "curses"

include Curses

begin
  crmode

  str = "Hello world ☺"

  win = Window.new(lines, cols, 0, 0)
  win.box("─", "│")
  #win.box("-", "|")
  win.setpos( lines / 2, (cols / 2) - (str.chars.count / 2) )
  win.addstr str

  win.refresh
  win.getch
ensure
  close_screen
end
──────────────────────────────────────

This presents me a window with a border of blinking reverse-video “â”
characters instead of the expected continuous lines. Interestingly, the
unicode smiley (☺) in #addstr is displayed correctly, so I doubt it’s a
problem with curses itself.

So: How do I get continuous lines for window borders with curses?

Valete,
Marvin
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.