Package org.rstudio.studio.client.workbench.views.source.editors.text.ace

Examples of org.rstudio.studio.client.workbench.views.source.editors.text.ace.Position


      return new MenuItem(text, false, new Command(){
         @Override
         public void execute()
         {
            editor_.collapseSelection(true);
            Position pos = editor_.getCursorPosition();
           
            StringBuilder indent = new StringBuilder();
            if (prefs_.useSpacesForTab().getValue())
            {
               int spaces = prefs_.numSpacesForTab().getValue();
               for (int i=0; i<spaces; i++)
                  indent.append(' ');
            }
            else
            {
               indent.append('\t');
            }
          
            String item = indent.toString() + "\\item";
            String itemElement = item + (isDescription ? "[]" : " ");
           
            String code = "\\begin{" + type + "}\n";
            code += itemElement;
            code += "\n\\end{" + type + "}\n";
           
           
            editor_.insertCode(code, false);
            editor_.focus();
           
            editor_.setCursorPosition(Position.create(pos.getRow() + 1,
                                                      item.length() + 1));
         }
        
      });
   }
View Full Code Here


      if (chunk == null)
         return null;

      assert chunk.isChunk();

      Position start = Position.create(chunk.getPreamble().getRow() + 1, 0);
      Position end = Position.create(chunk.getEnd().getRow(), 0);
      if (start.getRow() != end.getRow())
      {
         end = Position.create(end.getRow()-1,
                               docDisplay_.getLine(end.getRow()-1).length());
      }
      return Range.fromPoints(start, end);
   }
View Full Code Here

   public Scope[] getPreviousSweaveChunks()
   {
      ScopeList scopeList = new ScopeList(docDisplay_);
      scopeList.selectAll(ScopeList.CHUNK);
      final Position selectionStart = docDisplay_.getSelectionStart();
      scopeList.selectAll(new ScopePredicate() {

         @Override
         public boolean test(Scope scope)
         {
View Full Code Here

  
   public Scope getNextSweaveChunk()
   {
      ScopeList scopeList = new ScopeList(docDisplay_);
      scopeList.selectAll(ScopeList.CHUNK);
      final Position selectionEnd = docDisplay_.getSelectionEnd();
      return scopeList.findFirst(new ScopePredicate()
      {
         @Override
         public boolean test(Scope scope)
         {
View Full Code Here

      boolean wrap = display_.getWrapSearch().getValue();
    
      // if we are searching in a selection then create a custom position
      // (based on the current selection) and range (based on the originally
      // saved selection range)
      Position position = null;
      Range range = null;
      if (display_.getInSelection().getValue() && (targetSelection_ != null))
      {      
         range = targetSelection_.getRange();
        
         if (findType == FindType.Forward)
         {
            Position selectionEnd = editor_.getSelectionEnd();
            if (selectionEnd.isBefore(range.getEnd()))
               position = selectionEnd;
         }
         else
         {
            Position selectionStart = editor_.getSelectionStart();
            if (selectionStart.isAfter(range.getStart()))
               position = selectionStart;
         }
      }
     
      // if this is an incremental search and we don't have a previous
View Full Code Here

      // Try to get the function call string -- either there's
      // an associated closing paren we can use, or we should just go up
      // to the current cursor position
     
      // default case: use start cursor
      Position endPos = startCursor.currentPosition();
      endPos.setColumn(endPos.getColumn() + startCursor.currentValue().length());
     
      // try to look forward for closing paren
      if (endOfDecl.currentValue() == "(")
      {
         TokenCursor closingParenCursor = endOfDecl.cloneCursor();
         if (closingParenCursor.fwdToMatchingToken())
         {
            endPos = closingParenCursor.currentPosition();
            endPos.setColumn(endPos.getColumn() + 1);
         }
      }
     
      // We can now set the function call string
      context.setFunctionCallString(
View Full Code Here

      return addHandler(handler, BreakpointMoveEvent.TYPE);
   }
  
   public void toggleBreakpointAtCursor()
   {
      Position pos = editor_.getSession().getSelection().getCursor();
      toggleBreakpointAtPosition(Position.create(pos.getRow(), 0));
   }
View Full Code Here

     
      // see if we need to move any breakpoints around in response to
      // this change to the document's text
      String action = changeEvent.getAction();
      Range range = changeEvent.getRange();
      Position start = range.getStart();
      Position end = range.getEnd();
     
      // if the edit was all on one line or the action didn't change text
      // in a way that could change lines, we can't have moved anything
      if (start.getRow() == end.getRow() ||
          (!action.equals("insertText") &&
           !action.equals("insertLines") &&
           !action.equals("removeText") &&
           !action.equals("removeLines")))
      {
         return;
      }
     
      int shiftedBy = 0;
      int shiftStartRow = 0;
     
      // compute how many rows to shift
      if (action == "insertText" ||
          action == "insertLines")
      {
         shiftedBy = end.getRow() - start.getRow();
      }
      else
      {
         shiftedBy = start.getRow() - end.getRow();
      }
     
      // compute where to start shifting
      shiftStartRow = start.getRow() +
            ((action == "insertText" && start.getColumn() > 0) ?
                  1 : 0);
     
      // make a pass through the breakpoints and move them as appropriate:
      // remove all the breakpoints after the row where the change
      // happened, and add them back at their new position if they were
      // not part of a deleted range.
      ArrayList<Breakpoint> movedBreakpoints = new ArrayList<Breakpoint>();
    
      for (int idx = 0; idx < breakpoints_.size(); idx++)
      {
         Breakpoint breakpoint = breakpoints_.get(idx);
         int breakpointRow = rowFromLine(breakpoint.getEditorLineNumber());
         if (breakpointRow >= shiftStartRow)
         {
            // remove the breakpoint from its old position
            movedBreakpoints.add(breakpoint);
            removeBreakpointMarker(breakpoint);
         }
      }
      for (Breakpoint breakpoint: movedBreakpoints)
      {
         // calculate the new position of the breakpoint
         int oldBreakpointPosition =
               rowFromLine(breakpoint.getEditorLineNumber());
         int newBreakpointPosition =
               oldBreakpointPosition + shiftedBy;
        
         // add a breakpoint in this new position only if it wasn't
         // in a deleted range, and if we don't already have a
         // breakpoint there
         if (oldBreakpointPosition >= end.getRow() &&
             !(oldBreakpointPosition == end.getRow() && shiftedBy < 0) &&
             getBreakpointIdxByLine(lineFromRow(newBreakpointPosition)) < 0)
         {
            breakpoint.moveToLineNumber(lineFromRow(newBreakpointPosition));
            placeBreakpointMarker(breakpoint);
            fireEvent(new BreakpointMoveEvent(breakpoint.getBreakpointId()));
View Full Code Here

         {
            // move the breakpoint down to the first line that has a
            // non-whitespace, non-comment token
            if (editor_.getSession().getMode().getCodeModel() != null)
            {
               Position tokenPos = editor_.getSession().getMode().getCodeModel()
                  .findNextSignificantToken(pos);
               if (tokenPos != null)
               {
                  lineNumber = lineFromRow(tokenPos.getRow());
                  if (getBreakpointIdxByLine(lineNumber) >= 0)
                  {
                     return;
                  }
               }
View Full Code Here

TOP

Related Classes of org.rstudio.studio.client.workbench.views.source.editors.text.ace.Position

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.