RText: differenze tra le versioni
Contenuto cancellato Contenuto aggiunto
Aggiunto l'esempio di una macro JavaScript che tenta l'apertura di un file. |
Aggiunto l'esempio di una macro Groovy che tenta l'apertura di un file. |
||
Riga 110:
} finally {
textArea.endAtomicEdit();
}
</source>
Lo stesso esempio programmato in linguaggio [[Groovy]]:
<source lang="javascript">
import java.awt.*
import javax.swing.*
import org.fife.rtext.*
textArea.beginAtomicEdit()
try {
def fileName = textArea.selectedText
if (fileName==null || fileName.length()==0) {
JOptionPane.showMessageDialog(rtext,
"""Couldn't open file: No selection.
A file name must be selected in the active editor to open a file.""",
"Error", JOptionPane.ERROR_MESSAGE)
}
else {
def isUrl = fileName.startsWith("http://")
def file = new File(fileName)
if (!file.isAbsolute()) {
def parentDir = new File(textArea.fileFullPath).parentFile
file = new File(parentDir, fileName)
}
// Easter egg - if this is a URL, open it in a browser
if (isUrl) {
Desktop.desktop.browse(new URL(fileName).toURI())
}
else if (file.isFile()) {
rtext.openFile(file.absolutePath)
}
else if (file.isDirectory()) {
def chooser = rtext.fileChooser
chooser.currentDirectory = file
rtext.getAction(RTextActionInfo.OPEN_ACTION).actionPerformed(null)
}
else {
JOptionPane.showMessageDialog(rtext,
"File does not exist:\n" + file.absolutePath, "Error",
JOptionPane.ERROR_MESSAGE)
}
}
} finally {
textArea.endAtomicEdit()
}
</source>
Riga 132 ⟶ 183:
* Collegamenti ipertestuali cliccabili (se il motore analitico del linguaggio lo consente).<ref name=j-rsyntaxtextareaapidocumentation />
Nella barra di stato della finestra principale è presente l'indicatore della quantità di memoria
== Linguaggi supportati ==
|