Changeset 405
- Timestamp:
- 09/27/08 19:38:33 (3 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
jasko.tim.lisp/src/jasko/tim/lisp/inspector/InspectorGadget.java
r33 r405 1 1 package jasko.tim.lisp.inspector; 2 2 3 import org.eclipse.swt.SWT; 4 import org.eclipse.swt.events.SelectionEvent; 5 import org.eclipse.swt.events.SelectionListener; 3 6 import org.eclipse.swt.widgets.Composite; 7 import org.eclipse.swt.widgets.Menu; 8 import org.eclipse.swt.widgets.MenuItem; 4 9 5 10 import jasko.tim.lisp.LispPlugin; … … 19 24 } 20 25 26 protected void showInspectableMenu(final InspectableRegion region) { 27 Menu menu = new Menu (this.getControl()); 28 MenuItem inspect = new MenuItem(menu, SWT.PUSH); 29 inspect.setText("Inspect"); 30 inspect.addSelectionListener(new SelectionListener () { 31 public void widgetDefaultSelected(SelectionEvent e) { 32 33 } 34 public void widgetSelected(SelectionEvent e) { 35 sendInspect(region.id); 36 } 37 }); 38 menu.setVisible(true); 39 } 40 21 41 } jasko.tim.lisp/src/jasko/tim/lisp/views/ReplView.java
r402 r405 881 881 } 882 882 883 public void appendToInputArea(String text) { 884 in.getTextWidget().append(text); 885 } 886 887 public void insertInInputArea(String text) { 888 StyledText st = in.getTextWidget(); 889 st.insert(text); 890 } 891 883 892 884 893 /** jasko.tim.lisp/src/jasko/tim/lisp/views/repl/ReplHistory.java
r279 r405 9 9 import jasko.tim.lisp.inspector.InspectorRunnable; 10 10 import jasko.tim.lisp.preferences.PreferenceConstants; 11 import jasko.tim.lisp.views.ReplView; 11 12 12 13 import org.eclipse.jface.preference.IPreferenceStore; … … 18 19 import org.eclipse.swt.SWT; 19 20 import org.eclipse.swt.custom.StyleRange; 21 import org.eclipse.swt.dnd.*; 20 22 import org.eclipse.swt.events.*; 21 23 import org.eclipse.swt.graphics.*; … … 32 34 private Color inputFore; 33 35 private Color commentFore; 34 36 35 37 private boolean applyInspectableStyles; 36 38 private boolean underlineInspectables; … … 258 260 public void mouseUp(MouseEvent e) { 259 261 Point p = new Point(e.x, e.y); 260 int offset;261 try {262 offset = getTextWidget().getOffsetAtLocation(p);263 } catch (IllegalArgumentException ex) {264 return;265 }262 int offset; 263 try { 264 offset = getTextWidget().getOffsetAtLocation(p); 265 } catch (IllegalArgumentException ex) { 266 return; 267 } 266 268 InspectableRegion region = getRegion(offset); 267 if (region != null) sendInspect(region.id); 269 if (region != null) { 270 if (e.button == 1) { // left click 271 sendInspect(region.id); 272 } else if (e.button == 3) { // right click 273 showInspectableMenu(region); 274 } 275 } 276 } 277 278 protected void showInspectableMenu(final InspectableRegion region) { 279 Menu menu = new Menu (this.getControl()); 280 MenuItem inspect = new MenuItem(menu, SWT.PUSH); 281 inspect.setText("Inspect"); 282 inspect.addSelectionListener(new SelectionListener () { 283 public void widgetDefaultSelected(SelectionEvent e) { 284 285 } 286 public void widgetSelected(SelectionEvent e) { 287 sendInspect(region.id); 288 } 289 }); 290 MenuItem copyRepl = new MenuItem(menu, SWT.PUSH); 291 copyRepl.setText("Copy to REPL"); 292 copyRepl.addSelectionListener(new SelectionListener () { 293 public void widgetDefaultSelected(SelectionEvent e) { 294 295 } 296 public void widgetSelected(SelectionEvent e) { 297 ReplView.getInstance().insertInInputArea("#.(swank:get-repl-result #10r" + region.id + ")"); 298 } 299 }); 300 MenuItem copy = new MenuItem(menu, SWT.PUSH); 301 copy.setText("Copy to clipboard"); 302 copy.addSelectionListener(new SelectionListener () { 303 public void widgetDefaultSelected(SelectionEvent e) { 304 305 } 306 public void widgetSelected(SelectionEvent e) { 307 String data = "#.(swank:get-repl-result #10r" + region.id + ")"; 308 309 Clipboard cb = new Clipboard(getControl().getDisplay()); 310 TextTransfer textTransfer = TextTransfer.getInstance(); 311 cb.setContents(new Object[] { data }, 312 new Transfer[] { textTransfer }); 313 cb.dispose(); 314 } 315 }); 316 //menu.setLocation(p); 317 menu.setVisible(true); 268 318 } 269 319 … … 280 330 public void mouseDown(MouseEvent e) {} 281 331 282 pr ivateclass InspectableRegion extends Region {332 protected class InspectableRegion extends Region { 283 333 public final String id; 284 334
