Changeset 28
- Timestamp:
- 10/02/02 18:16:19 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/j/src/org/armedbear/j/ShellCommand.java
r2 r28 3 3 * 4 4 * Copyright (C) 2000-2002 Peter Graves 5 * $Id: ShellCommand.java,v 1. 1.1.1 2002-09-24 16:08:40piso Exp $5 * $Id: ShellCommand.java,v 1.2 2002-10-02 18:16:19 piso Exp $ 6 6 * 7 7 * This program is free software; you can redistribute it and/or … … 140 140 } 141 141 } 142 143 public static void shellCommand() 144 { 145 if (Platform.isPlatformWindows() && !Platform.isPlatformWindows5()) 146 return; 147 final Editor editor = Editor.currentEditor(); 148 InputDialog d = new InputDialog(editor, "Command:", "Shell Command", null); 149 d.setHistory(new History("shellCommand.command")); 150 editor.centerDialog(d); 151 d.show(); 152 String command = d.getInput(); 153 if (command == null) 154 return; 155 command = command.trim(); 156 if (command.length() == 0) 157 return; 158 shellCommand(editor, command); 159 } 160 161 public static void shellCommand(String command) 162 { 163 if (Platform.isPlatformWindows() && !Platform.isPlatformWindows5()) 164 return; 165 shellCommand(Editor.currentEditor(), command); 166 } 167 168 private static void shellCommand(Editor editor, String command) 169 { 170 final File dir = editor.getCurrentDirectory(); 171 if (dir == null || !dir.isDirectory()) 172 return; 173 String cmdline = "(\\cd " + dir.canonicalPath() + " && " + command + ")"; 174 ShellCommand shellCommand = new ShellCommand(cmdline); 175 shellCommand.run(); 176 String output = shellCommand.getOutput(); 177 if (output != null && output.length() > 0) { 178 OutputBuffer buf = OutputBuffer.getOutputBuffer(output); 179 if (buf != null) { 180 buf.setTitle(command); 181 editor.makeNext(buf); 182 editor.activateInOtherWindow(buf); 183 } 184 } 185 } 142 186 }
Note: See TracChangeset
for help on using the changeset viewer.