public static Task PreviousPlotAsync(this IRExpressionEvaluator evaluation, Guid deviceId) { Debug.Assert(deviceId != Guid.Empty); var script = $"rtvs:::graphics.ide.previousplot({deviceId.ToString().ToRStringLiteral()})\n"; return(evaluation.ExecuteAsync(script)); }
public static Task ResizePlotAsync(this IRExpressionEvaluator evaluation, Guid deviceId, int width, int height, int resolution) { Debug.Assert(deviceId != Guid.Empty); var script = Invariant($"rtvs:::graphics.ide.resize({deviceId.ToString().ToRStringLiteral()}, {width}, {height}, {resolution})\n"); return(evaluation.ExecuteAsync(script)); }
public static Task CopyPlotAsync(this IRExpressionEvaluator evaluation, Guid sourceDeviceId, Guid sourcePlotId, Guid targetDeviceId) { Debug.Assert(sourceDeviceId != Guid.Empty); Debug.Assert(sourcePlotId != Guid.Empty); Debug.Assert(targetDeviceId != Guid.Empty); var script = Invariant($"rtvs:::graphics.ide.copyplot({sourceDeviceId.ToString().ToRStringLiteral()}, {sourcePlotId.ToString().ToRStringLiteral()}, {targetDeviceId.ToString().ToRStringLiteral()})\n"); return evaluation.ExecuteAsync(script); }
public static Task SetCodePageAsync(this IRExpressionEvaluator evaluation, int codePage, CancellationToken cancellationToken = default(CancellationToken)) { if (codePage == 0) { codePage = NativeMethods.GetOEMCP(); } var script = Invariant($"Sys.setlocale('LC_CTYPE', '.{codePage}')"); return evaluation.ExecuteAsync(script, cancellationToken); }
public static Task ClearPlotHistoryAsync(this IRExpressionEvaluator evaluation, Guid deviceId) { Debug.Assert(deviceId != Guid.Empty); var script = Invariant($"rtvs:::graphics.ide.clearplots({deviceId.ToString().ToRStringLiteral()})\n"); return(evaluation.ExecuteAsync(script)); }
public static Task RemoveCurrentPlotAsync(this IRExpressionEvaluator evaluation, Guid deviceId, Guid plotId) { Debug.Assert(deviceId != Guid.Empty); Debug.Assert(plotId != Guid.Empty); var script = Invariant($"rtvs:::graphics.ide.removeplot({deviceId.ToString().ToRStringLiteral()}, {plotId.ToString().ToRStringLiteral()})\n"); return(evaluation.ExecuteAsync(script)); }
public static Task OverrideFunctionAsync(this IRExpressionEvaluator evaluation, string name, string ns) { name = name.ToRStringLiteral(); ns = ns.ToRStringLiteral(); var script = Invariant($"utils::assignInNamespace({name}, rtvs:::{name}, {ns})"); return(evaluation.ExecuteAsync(script)); }
public static Task SetVsGraphicsDeviceAsync(this IRExpressionEvaluator evaluation) { var script = @" attach(as.environment(list(ide = function() { rtvs:::graphics.ide.new() })), name='rtvs::graphics::ide') options(device='ide') grDevices::deviceIsInteractive('ide') "; return evaluation.ExecuteAsync(script); }
public static Task SetROptionsAsync(this IRExpressionEvaluator evaluation) { var script = @"options(help_type = 'html') options(browser = rtvs:::open_url) options(pager = rtvs:::show_file) "; return evaluation.ExecuteAsync(script); }
public static Task SetLocalLibsAsync(IRExpressionEvaluator eval, params string[] libPaths) { foreach (var libPath in libPaths.Where(libPath => !Directory.Exists(libPath))) { Directory.CreateDirectory(libPath); } var paths = string.Join(",", libPaths.Select(p => p.ToRPath().ToRStringLiteral())); var code = $".libPaths(c({paths}))"; return eval.ExecuteAsync(code); }
public static Task SetCodePageAsync(this IRExpressionEvaluator evaluation, int codePage) { if (codePage == 0) { codePage = NativeMethods.GetOEMCP(); } var script = Invariant($"Sys.setlocale('LC_CTYPE', '.{codePage}')"); return(evaluation.ExecuteAsync(script)); }
public static async Task SetCodePageAsync(this IRExpressionEvaluator evaluation, int codePage, CancellationToken cancellationToken = default(CancellationToken)) { var cp = $".{codePage}"; if (codePage == 0) { cp = await evaluation.IsRSessionPlatformWindowsAsync() ? ".437" : "en_US.UTF-8"; } var script = Invariant($"Sys.setlocale('LC_CTYPE', '{cp}')"); await evaluation.ExecuteAsync(script, cancellationToken); }
private static Task LoadRtvsPackage(IRExpressionEvaluator eval, string libPath) { return(eval.ExecuteAsync(Invariant($@" if (!base::isNamespaceLoaded('rtvs')) {{ base::loadNamespace('rtvs', lib.loc = {libPath.ToRStringLiteral()}) }} if (rtvs:::version != {rtvsPackageVersion}) {{ warning('This R session was created using an incompatible version of RTVS, and may misbehave or crash when used with this version. Click ""Reset"" to replace it with a new clean session.'); }} "))); }
public static Task SetCodePageAsync(this IRExpressionEvaluator evaluation, int codePage, CancellationToken cancellationToken = default(CancellationToken)) { if (codePage == 0) { // TODO: update this to get the codepage via platform agnostic service codePage = 437; } var script = Invariant($"Sys.setlocale('LC_CTYPE', '.{codePage}')"); return(evaluation.ExecuteAsync(script, cancellationToken)); }
public static Task SetLocalLibsAsync(IRExpressionEvaluator eval, params string[] libPaths) { foreach (var libPath in libPaths.Where(libPath => !Directory.Exists(libPath))) { Directory.CreateDirectory(libPath); } var paths = string.Join(",", libPaths.Select(p => p.ToRPath().ToRStringLiteral())); var code = $".libPaths(c({paths}))"; return(eval.ExecuteAsync(code)); }
public static async Task SetCodePageAsync(this IRExpressionEvaluator evaluation, int codePage, CancellationToken cancellationToken = default(CancellationToken)) { string cp = $".{codePage}"; if (codePage == 0) { var platformType = await evaluation.GetRSessionPlatformAsync(cancellationToken); cp = platformType.EqualsIgnoreCase("windows")? ".437": "en_US.UTF-8"; } var script = Invariant($"Sys.setlocale('LC_CTYPE', '{cp}')"); await evaluation.ExecuteAsync(script, cancellationToken); }
private async Task LoadRtvsPackage(IRExpressionEvaluator eval, bool isRemote) { // Load RTVS R package before doing anything in R since the calls // below calls may depend on functions exposed from the RTVS package var libPath = isRemote ? await GetRemoteRtvsPackagePath(eval) : Path.GetDirectoryName(typeof(RHost).GetTypeInfo().Assembly.GetAssemblyPath()); await eval.ExecuteAsync(Invariant($@" if (!base::isNamespaceLoaded('rtvs')) {{ base::loadNamespace('rtvs', lib.loc = {libPath.ToRStringLiteral()}) }} if (rtvs:::version != {rtvsPackageVersion}) {{ warning('This R session was created using an incompatible version of RTVS, and may misbehave or crash when used with this version. Click ""Reset"" to replace it with a new clean session.'); }} ")); }
public static async Task SetCodePageAsync(this IRExpressionEvaluator evaluation, int codePage, CancellationToken cancellationToken = default) { string cp = null; if (codePage == 0) { // Non-Windows defaults to UTF-8, on Windows leave default alone. if (!await evaluation.IsRSessionPlatformWindowsAsync(cancellationToken)) { cp = "en_US.UTF-8"; } } else { cp = Invariant($".{codePage}"); } if (!string.IsNullOrEmpty(cp)) { var script = Invariant($"Sys.setlocale('LC_CTYPE', '{cp}')"); await evaluation.ExecuteAsync(script, cancellationToken); } }
public static Task OptionsSetWidthAsync(this IRExpressionEvaluator evaluation, int width) { return(evaluation.ExecuteAsync(Invariant($"options(width=as.integer({width}))\n"))); }
public static Task RemoveCurrentPlotAsync(this IRExpressionEvaluator evaluation) { var script = "rtvs:::graphics.ide.removeplot()\n"; return(evaluation.ExecuteAsync(script)); }
public static Task ClearPlotHistoryAsync(this IRExpressionEvaluator evaluation) { var script = "rtvs:::graphics.ide.clearplots()\n"; return(evaluation.ExecuteAsync(script)); }
public static Task PreviousPlotAsync(this IRExpressionEvaluator evaluation) { var script = "rtvs:::graphics.ide.previousplot()\n"; return(evaluation.ExecuteAsync(script)); }
public static Task ResizePlotAsync(this IRExpressionEvaluator evaluation, int width, int height, int resolution) { var script = Invariant($"rtvs:::graphics.ide.resize({width}, {height}, {resolution})\n"); return(evaluation.ExecuteAsync(script)); }
/// <summary> /// Like <see cref="ExecuteAsync(IRExpressionEvaluator, FormattableString, REvaluationKind, CancellationToken)"/>, but uses /// <see cref="REvaluationKind.Mutating"/> for <c>kind</c> /// </summary> public static Task ExecuteAsync(this IRExpressionEvaluator evaluator, FormattableString expression, CancellationToken cancellationToken = default(CancellationToken)) => evaluator.ExecuteAsync(expression, REvaluationKind.Mutating, cancellationToken);
public static Task SetDefaultWorkingDirectoryAsync(this IRExpressionEvaluator evaluation) { return(evaluation.ExecuteAsync($"setwd('~')\n")); }
public static Task SetWorkingDirectoryAsync(this IRExpressionEvaluator evaluation, string path) { return(evaluation.ExecuteAsync($"setwd('{path.Replace('\\', '/')}')\n")); }
public static Task SetFunctionRedirectionAsync(this IRExpressionEvaluator evaluation) { var script = "rtvs:::redirect_functions()"; return(evaluation.ExecuteAsync(script)); }
public static Task SetLocalRepoAsync(IRExpressionEvaluator eval, string localRepoPath) { var code = $"options(repos=list(LOCAL=\"file:///{localRepoPath.ToRPath()}\"))"; return eval.ExecuteAsync(code); }
public static Task SetCranRepoAsync(IRExpressionEvaluator eval) { var code = @"options(repos=list(CRAN='http://cran.r-project.org'))"; return eval.ExecuteAsync(code); }
private static Task SuppressUI(IRExpressionEvaluator eval) { // # Suppress Windows UI // http://astrostatistics.psu.edu/datasets/R/html/utils/html/winMenus.html return(eval.ExecuteAsync(@"rtvs:::suppress_ui()")); }
public static Task LoadWorkspaceAsync(this IRExpressionEvaluator evaluation, string path) { return(evaluation.ExecuteAsync($"load('{path.Replace('\\', '/')}', .GlobalEnv)\n")); }
public static async Task SetVsCranSelectionAsync(this IRExpressionEvaluator evaluation, string mirrorUrl) { await evaluation.ExecuteAsync(Invariant($"rtvs:::set_mirror({mirrorUrl.ToRStringLiteral()})")); }
public static Task SaveWorkspaceAsync(this IRExpressionEvaluator evaluation, string path) { return(evaluation.ExecuteAsync($"save.image(file='{path.Replace('\\', '/')}')\n", REvaluationKind.Normal)); }