示例#1
0
  // Displays the users currently online in the usersOnlineWindow JTextArea
  private void showUsersOnline() throws JSONException {

    // F**k det här under. Det f*****g sög att skriva. JSONArrays är retarderade.

    for (int i = 0; i < ((JSONArray) obj.get("listOfUsernames")).length(); i++) {
      if (!((JSONArray) obj.get("listOfUsernames")).isNull(i)) {
        if (!doesArrayContain(
            arrayOfAddedUsernames, ((JSONArray) obj.get("listOfUsernames")).getString(i))) {
          usersOnlineWindow.append("\n" + ((JSONArray) obj.get("listOfUsernames")).getString(i));
          pushValueToArray(
              arrayOfAddedUsernames, ((JSONArray) obj.get("listOfUsernames")).getString(i));
        }
      }
    }

    if (!obj.getString("disconnectedUser").equals("")) {
      int offset = usersOnlineWindow.getText().indexOf(obj.getString("disconnectedUser"));

      if (offset != -1) {
        try {
          int line = usersOnlineWindow.getLineOfOffset(offset);
          int start = usersOnlineWindow.getLineStartOffset(line);
          int end = usersOnlineWindow.getLineEndOffset(line);

          usersOnlineWindow.replaceRange("", start, end);
        } catch (BadLocationException e) {
          e.printStackTrace();
        }
      }
      obj.put("disconnectedUser", "");
    }
  }
 /**
  * Will select the Mars Messages tab error message that matches the given specifications, if it is
  * found. Matching is done by constructing a string using the parameter values and searching the
  * text area for the last occurrance of that string.
  *
  * @param fileName A String containing the file path name.
  * @param line Line number for error message
  * @param column Column number for error message
  */
 public void selectErrorMessage(String fileName, int line, int column) {
   String errorReportSubstring =
       new java.io.File(fileName).getName()
           + ErrorList.LINE_PREFIX
           + line
           + ErrorList.POSITION_PREFIX
           + column;
   int textPosition = assemble.getText().lastIndexOf(errorReportSubstring);
   if (textPosition >= 0) {
     int textLine = 0;
     int lineStart = 0;
     int lineEnd = 0;
     try {
       textLine = assemble.getLineOfOffset(textPosition);
       lineStart = assemble.getLineStartOffset(textLine);
       lineEnd = assemble.getLineEndOffset(textLine);
       assemble.setSelectionColor(Color.YELLOW);
       assemble.select(lineStart, lineEnd);
       assemble.getCaret().setSelectionVisible(true);
       assemble.repaint();
     } catch (BadLocationException ble) {
       // If there is a problem, simply skip the selection
     }
   }
 }
示例#3
0
  void doCaretUpdate(int dot, int mark) {
    if (dot == mark) {
      mainFrame.cutItem.setEnabled(false);
      mainFrame.copyItem.setEnabled(false);
      mainFrame.deleteItem.setEnabled(false);
    } else {
      mainFrame.cutItem.setEnabled(true);
      mainFrame.copyItem.setEnabled(true);
      mainFrame.deleteItem.setEnabled(true);
    }

    int length = sourceArea.getText().length();
    if (length == 0 || abs(mark - dot) == length) {
      mainFrame.selectAllItem.setEnabled(false);
    } else {
      mainFrame.selectAllItem.setEnabled(true);
    }

    try {
      if (length == 0) {
        mainFrame.selectLineItem.setEnabled(false);
      } else {
        int lineNum = sourceArea.getLineOfOffset(dot);
        int startLine = sourceArea.getLineStartOffset(lineNum);
        int endLine = sourceArea.getLineEndOffset(lineNum);
        if (endLine - startLine <= 1) {
          mainFrame.selectLineItem.setEnabled(false);
        } else {
          mainFrame.selectLineItem.setEnabled(true);
        }
      }
    } catch (BadLocationException ex) {
      ex.printStackTrace();
    }

    try {
      int line = sourceArea.getLineOfOffset(dot);
      lineText.setText(Integer.toString(line + 1));
      int column = dot - sourceArea.getLineStartOffset(line);
      columnText.setText(Integer.toString(column + 1));
    } catch (BadLocationException ex) {
      ex.printStackTrace();
    }
  }
示例#4
0
  private void toggleBreakpoint() {
    try {
      int lineno = sourceTextarea.getLineOfOffset(sourceTextarea.getCaretPosition()) + 1;
      Character asmaddr = asmMap.src2bin(lineno);
      if (srcBreakpoints.contains(lineno)) {
        srcBreakpoints.remove(lineno);
        if (asmaddr != null) debugger.setBreakpoint(asmaddr, false);
      } else {
        srcBreakpoints.add(lineno);
        if (asmaddr != null) debugger.setBreakpoint(asmaddr, true);
      }

      sourceRowHeader.breakpointChanged(lineno);
    } catch (BadLocationException e1) {
      e1.printStackTrace();
    }
  }