Skip to content
Back to formatted view

Raw Message

Message-ID: <CAPr7RtX2YLwDdfvCQzzZ9ncs8CvTM=JXxFPyyRMo2n8ei1ELBQ@mail.gmail.com>
Date: 2013-01-30T01:13:19Z
From: ivo welch
Subject: width of terminal resize to current dimensions on linux Gnome terminal

I just looked at the sample initialization script in the R docs.  it
suggests the first two lines of

  cols <- Sys.getenv("COLUMNS")
  if(nzchar(cols)) options(width = as.integer(cols))
  print(cols)

I run R 2.15.2 on a linux Gnome terminal 3.6.0 now.  alas, this
snippet always prints "" (I replaced my .Rprofile to contain this
snippet only).  in constrat, Sys.getenv("COLUMNS") after I see the ">"
prompt works fine.

on stackoverflow, there was an even nicer solution that suggested
dynamic window resizing would be possible:

.adjustWidth <- function(...){
  try( options(width=Sys.getenv("COLUMNS")), silent = TRUE)
  cat("[Reset Window Width]\n")
  TRUE
}
.adjustWidthCallBack <- addTaskCallback(.adjustWidth)

alas, this does not seem to be called by a linux window resize, but by
every command now.  is there a way to add a TaskCallback only when a
user resizes the window?

help appreciated...

/iaw

----
Ivo Welch (ivo.welch at gmail.com)