如何访问 RStudio 中的脚本/源历史记录? [英] How to access the script/source history in RStudio?

查看:175
本文介绍了如何访问 RStudio 中的脚本/源历史记录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想访问在 RStudio 的源面板中输入的历史记录.

我对我们学习和输入代码的方式很感兴趣.我想分析的三件事是:i) 一个人打字的方式,ii) 不同人打字的方式,iii) 初学者改进打字的方式.

以这种方式第一次尝试获取命令的历史记录是非常令人满意的,但我想达到更细的粒度,从而以某种方式一行中访问连续的更改.>

所以,明确地说,我既不是在寻找命令的历史,也不是在寻找.R 文件的不同版本之间的差异.

我想访问的是当您递归按下Ctrl+Z 时,源面板的连续更改是可见的.我不知道我所描述的是否有更准确的词,但我再次感兴趣的是如何在源面板中添加/移动/删除/更正/改进代码位,但不必传递到控制台因而从指挥历史中消失了.

这必须在某个地方/以某种方式由 RStudio 保存,因为后者可以访问.这可能以一种非常隐藏/私有/内存/进程/...的方式保存,我对 GUI 的工作原理有一个非常模糊的想法.我不知道它是否易于访问,然后以编程方式进行分析,通常是否可以从中保存文件.时间戳将是最重要的,但我会很高兴没有.

您知道如何访问此历史记录吗?

解决方案

RStudio 的源代码面板本质上是 Ace 编辑器的视图.因此,您需要访问编辑器会话的 editSession 并使用 getDocument 或 getWordRange 以及 editSession 的 undoManager 实例的撤消.

我认为您不会在 RStudio 中执行此操作而不对 RStudio 代码进行黑客攻击,除非 RStudio Addin api 用于在未来传递编辑器事件.

在进行更改时编写会话记录器可能会更容易,而不是试图弄乱撤消历史记录.我想您可以编写一个调用 javascript 的插件,以使用 Ace 编辑器的事件(即 onChange)通过现有的 RStudio 端口进行通信.

I would like to access the history of what have been typed in the source panel in RStudio.

I'm interested in the way we learn and type code. Three things I would like to analyse are: i) the way a single person type code, ii) how different persons type code, iii) the way a beginner improve typing.

Grabbing the history of commands is quite satisfying as first attempt in this way but I would like to reach a finer granularity and thus access the successive changes, within a single line in a way.

So, to be clear, I'm neither looking for the history of commands or for a diff between different versions of and .R file.

What I would like to access is really the successive alterations to the source panel that are visible when you recursively press Ctrl+Z. I do not know if there is a more accurate word for what I describe, but again what I'm interested in is how bits of code are added/moved/deleted/corrected/improved in the source panel but not necessary passed to the Console and thus absent from the history of command.

This must be somewhere/somehow saved by RStudio as it is accessible by the later. This may be saved in a quite hidden/private/memory/process/... way and I have a very vague idea of how a GUI works. I do not know it if would be easily accessible, then programmaticaly analyzed, typically if we could save a file from it. Timestamps would be the cherry on top but I would be happy without.

Do you have idea how to access this history?

解决方案

RStudio's source panel is essentially a view to an Ace Editor. As such you'd need to access the editor session's editSession and use getDocument or getWordRange along with the undo of the editSession's undoManager instance.

I don't think you'll be doing that from within RStudio without hacking on the RStudio code unless the RStudio Addin api is made to pass-thru editor events in the future.

It might be easier to write a session recorder as changes are made rather than try to mess with the undo history. I imagine you could write an Addin that calls a javascript to communicate over the existing RStudio port using the Ace Editor's events (ie. onChange).

这篇关于如何访问 RStudio 中的脚本/源历史记录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆