LoginSignup
8
1

More than 5 years have passed since last update.

Nim 0.16.0がリリースされました

Posted at

1/8にNimの新しいバージョン(0.16.0)がリリースされたようです。

リリースノートを見ながら、Library Additionsを見ていると、
terminalというモジュールに何個かメソッドが追加されたとの事。

Added hideCursor, showCursor, terminalWidth, terminalWidthIoctl and terminalSize to the terminal (doc) module.

terminalモジュールってもしかして、ターミナルのカーソル位置や背景色や前景色なんかを設定できるのかなと思ったらアタリでした。terminal.nimの末尾にあったテストコードをちょっといじってみました。

サンプル

import os,terminal

# STDOUTに出力
write(stdout, "never mind")
# カーソルを消去
stdout.hideCursor()
# スクリーンクリア
stdout.eraseScreen()
# カーソル位置を1,1へ移動
stdout.setCursorPos(1,1)
# スタイル付き描画(ブリンクするはずですが、Linuxではただテキストが表示されているだけでした)
stdout.styledWriteLine("styled text ", {styleBright, styleBlink, styleUnderscore})
# 背景色をシアンに設定
stdout.setBackGroundColor(bgCyan, true)
# 前景色を青に設定
stdout.setForeGroundColor(fgBlue)
# カーソル位置を10,10へ移動
stdout.setCursorPos(10,10)
# テキスト出力
stdout.writeLine("ordinary text")
# ちょっと待つ
sleep(1000*10)

実行結果

Screenshot from 2017-01-10 23-38-52.png

8
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
1