1. Steve Losh
  2. lanterna

Commits

mar...@mars  committed 5d29282

Removing all references to java.util.Queue since this is a Java 5 interface

  • Participants
  • Parent commits 0177350
  • Branches jre142-branch

Comments (0)

Files changed (3)

File src/org/lantern/gui/GUIScreen.java

View file
  • Ignore whitespace
 import org.lantern.gui.theme.Theme;
 import java.util.LinkedList;
 import java.util.List;
-import java.util.Queue;
 import org.lantern.LanternException;
 import org.lantern.gui.listener.WindowAdapter;
 import org.lantern.input.Key;
 {
     private final Screen screen;
     private final LinkedList windowStack;
-    private final Queue actionToRunInEventThread;
+    private final LinkedList actionToRunInEventThread;
     private String title;
     private boolean showMemoryUsage;
     private Theme guiTheme;

File src/org/lantern/input/InputDecoder.java

View file
  • Ignore whitespace
 import java.io.IOException;
 import java.io.Reader;
 import java.util.ArrayList;
-import java.util.Collection;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
-import java.util.Queue;
 import java.util.Set;
 import org.lantern.LanternException;
 import org.lantern.terminal.TerminalPosition;
 public class InputDecoder
 {
     private final Reader source;
-    private final Queue inputBuffer;
-    private final Queue leftOverQueue;
+    private final LinkedList inputBuffer;
+    private final LinkedList leftOverQueue;
     private final Set bytePatterns;
     private final List currentMatching;
     private TerminalPosition lastReportedTerminalPosition;

File src/org/lantern/terminal/SwingTerminal.java

View file
  • Ignore whitespace
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.HashSet;
+import java.util.LinkedList;
 import java.util.List;
-import java.util.Queue;
 import java.util.Set;
-import java.util.concurrent.ConcurrentLinkedQueue;
 import javax.swing.JComponent;
 import javax.swing.JFrame;
 import javax.swing.SwingUtilities;
     private Color currentBackgroundColor;
     private boolean currentlyBold;
     private TerminalCharacter [][]characterMap;
-    private Queue keyQueue;
+    private LinkedList keyQueue;
     private final Object resizeMutex;
 
     public SwingTerminal()
         this.currentForegroundColor = Color.WHITE;
         this.currentBackgroundColor = Color.BLACK;
         this.currentlyBold = false;
-        this.keyQueue = new ConcurrentLinkedQueue();
+        this.keyQueue = new LinkedList();
         this.resizeMutex = new Object();
         clearScreen();
     }
 
     public Key readInput() throws LanternException
     {
-        return (Key)keyQueue.poll();
+        synchronized(keyQueue) {
+            return (Key)keyQueue.poll();
+        }
     }
 
     private void refreshScreen()
         {
             if(typedIgnore.contains(new Character(e.getKeyChar())))
                 return;
-            else
-                keyQueue.add(new Key(e.getKeyChar()));
+            else {
+                synchronized(keyQueue) {
+                    keyQueue.add(new Key(e.getKeyChar()));
+                }
+            }
         }
 
         public void keyPressed(KeyEvent e)
         {
-            if(e.getKeyCode() == KeyEvent.VK_ENTER)
-                keyQueue.add(new Key(Key.Kind.Enter));
-            else if(e.getKeyCode() == KeyEvent.VK_ESCAPE)
-                keyQueue.add(new Key(Key.Kind.Escape));
-            else if(e.getKeyCode() == KeyEvent.VK_BACK_SPACE)
-                keyQueue.add(new Key(Key.Kind.Backspace));
-            else if(e.getKeyCode() == KeyEvent.VK_LEFT)
-                keyQueue.add(new Key(Key.Kind.ArrowLeft));
-            else if(e.getKeyCode() == KeyEvent.VK_RIGHT)
-                keyQueue.add(new Key(Key.Kind.ArrowRight));
-            else if(e.getKeyCode() == KeyEvent.VK_UP)
-                keyQueue.add(new Key(Key.Kind.ArrowUp));
-            else if(e.getKeyCode() == KeyEvent.VK_DOWN)
-                keyQueue.add(new Key(Key.Kind.ArrowDown));
-            else if(e.getKeyCode() == KeyEvent.VK_INSERT)
-                keyQueue.add(new Key(Key.Kind.Insert));
-            else if(e.getKeyCode() == KeyEvent.VK_DELETE)
-                keyQueue.add(new Key(Key.Kind.Delete));
-            else if(e.getKeyCode() == KeyEvent.VK_HOME)
-                keyQueue.add(new Key(Key.Kind.Home));
-            else if(e.getKeyCode() == KeyEvent.VK_END)
-                keyQueue.add(new Key(Key.Kind.End));
-            else if(e.getKeyCode() == KeyEvent.VK_PAGE_UP)
-                keyQueue.add(new Key(Key.Kind.PageUp));
-            else if(e.getKeyCode() == KeyEvent.VK_PAGE_DOWN)
-                keyQueue.add(new Key(Key.Kind.PageDown));
-            else if(e.getKeyCode() == KeyEvent.VK_TAB) {
-                if(e.isShiftDown())
-                    keyQueue.add(new Key(Key.Kind.ReverseTab));
-                else
-                    keyQueue.add(new Key(Key.Kind.Tab));
+            synchronized(keyQueue) {
+                if(e.getKeyCode() == KeyEvent.VK_ENTER)
+                    keyQueue.add(new Key(Key.Kind.Enter));
+                else if(e.getKeyCode() == KeyEvent.VK_ESCAPE)
+                    keyQueue.add(new Key(Key.Kind.Escape));
+                else if(e.getKeyCode() == KeyEvent.VK_BACK_SPACE)
+                    keyQueue.add(new Key(Key.Kind.Backspace));
+                else if(e.getKeyCode() == KeyEvent.VK_LEFT)
+                    keyQueue.add(new Key(Key.Kind.ArrowLeft));
+                else if(e.getKeyCode() == KeyEvent.VK_RIGHT)
+                    keyQueue.add(new Key(Key.Kind.ArrowRight));
+                else if(e.getKeyCode() == KeyEvent.VK_UP)
+                    keyQueue.add(new Key(Key.Kind.ArrowUp));
+                else if(e.getKeyCode() == KeyEvent.VK_DOWN)
+                    keyQueue.add(new Key(Key.Kind.ArrowDown));
+                else if(e.getKeyCode() == KeyEvent.VK_INSERT)
+                    keyQueue.add(new Key(Key.Kind.Insert));
+                else if(e.getKeyCode() == KeyEvent.VK_DELETE)
+                    keyQueue.add(new Key(Key.Kind.Delete));
+                else if(e.getKeyCode() == KeyEvent.VK_HOME)
+                    keyQueue.add(new Key(Key.Kind.Home));
+                else if(e.getKeyCode() == KeyEvent.VK_END)
+                    keyQueue.add(new Key(Key.Kind.End));
+                else if(e.getKeyCode() == KeyEvent.VK_PAGE_UP)
+                    keyQueue.add(new Key(Key.Kind.PageUp));
+                else if(e.getKeyCode() == KeyEvent.VK_PAGE_DOWN)
+                    keyQueue.add(new Key(Key.Kind.PageDown));
+                else if(e.getKeyCode() == KeyEvent.VK_TAB) {
+                    if(e.isShiftDown())
+                        keyQueue.add(new Key(Key.Kind.ReverseTab));
+                    else
+                        keyQueue.add(new Key(Key.Kind.Tab));
+                }
             }
         }
     }