当前位置:u赢电竞手机版 > 操作系统 > groovyConsole — the Groovy Swing console操作系统

groovyConsole — the Groovy Swing console操作系统

文章作者:操作系统 上传时间:2019-05-14

简介:Throw this script into your xwindows menu & at the click of a button you can have a screenshot ready for the next screenshots post!

 

方法:Save this script in your path. I put mine in /usr/local/bin. Then you can add it your window manager menu.

1. Groovy : Groovy Console

The Groovy Swing Console allows a user to enter and run Groovy scripts. This page documents the features of this user interface.

#!/bin/bash

# Written for Dream In Code 05/30/2008
# By #2pencil

#1st, we check for the most important piece
_path=`which import`
if [ $? -eq 1 ]; then
  echo "import command does not exist, please install it to continue"
  exit
fi
#jump to the temp directory
cd /tmp
#check for & move the last screenshot...
#remember, screenshot2.png gets trashed at this point
if [ -f screenshot1.png ]; then
  mv screenshot1.png screenshot2.png 
fi
# this should always exist
# unless it's the 1st time running...
if [ -f screenshot.png ]; then
  mv screenshot.png screenshot1.png
fi
# Let it roll!
${_path} -window root screenshot.png
#该片段来自于http://outofmemory.cn

2. Basics

操作系统 1

  1. Groovy Console is launched via groovyConsole or groovyConsole.bat, both located in $GROOVY_HOME/bin

  2. The Console has an input area and an output area.

  3. You type a Groovy script in the input area.

  4. When you select Run from the Actions menu, the console compiles the script and runs it.

  5. Anything that would normally be printed on System.out is printed in the output area.

  6. If the script returns a non-null result, that result is printed.

  7. Features


3.1. Running Scripts

There are several shortcuts that you can use to run scripts or code snippets:

  • Ctrl Enter and Ctrl R are both shortcut keys for Run Script.

  • If you highlight just part of the text in the input area, then Groovy runs just that text.

  • The result of a script is the the value of the last expression executed.

  • You can turn the System.out capture on and off by selecting Capture System.out from the Actions menu

3.2. Editing Files

You can open any text file, edit it, run it (as a Groovy Script) and then save it again when you are finished.

  • Select File > Open (shortcut key ctrl O) to open a file

  • Select File > Save (shortcut key ctrl S) to save a file

  • Select File > New File (shortcut key ctrl Q) to start again with a blank input area

3.3. History and results

  • You can pop-up a gui inspector on the last (non-null) result by selecting Inspect Last from the Actions menu. The inspector is a convenient way to view lists and maps.

  • The console remembers the last ten script runs. You can scroll back and forth through the history by selecting Next and Previous from the Edit menu. Ctrl-N and ctrl-P are convenient shortcut keys.

  • The last (non-null) result is bound to a variable named _ (an underscore).

  • The last result (null and non-null) for every run in the history is bound into a list variable named *(two underscores). The result of the last run is*[-1], the result of the second to last run is __[-2] and so forth.

本文由u赢电竞手机版发布于操作系统,转载请注明出处:groovyConsole — the Groovy Swing console操作系统

关键词: shell 系统 Blog Tools Groovy Langu GrovvyConsol