Package org.cfeclipse.cfml.views.snips

Examples of org.cfeclipse.cfml.views.snips.SnipKeyCombos


  //used from the toolbars
  public InsertSnippetAction(String triggerText, Shell shell){
   
   
   
    SnipKeyCombos keyCombos = new SnipKeyCombos();
    editor = (ITextEditor)Workbench.getInstance().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
    IDocument doc =  editor.getDocumentProvider().getDocument(editor.getEditorInput());
    ISelection sel = editor.getSelectionProvider().getSelection();
   
    String fileName = keyCombos.getKeyCombo(triggerText);
   
   
   
   
     SnipReader snipReader = new SnipReader();
      IFile activeFile = null;
      if (this.editor.getEditorInput() instanceof IFileEditorInput) {
         activeFile = ((IFileEditorInput) this.editor.getEditorInput()).getFile();
      }
   
       
     
       snipReader.read(keyCombos.getSnippetFolder() + fileName);
     
     
        start = SnipVarParser.parse(snipReader.getSnipStartBlock(),activeFile,shell);
          end = SnipVarParser.parse(snipReader.getSnipEndBlock(),activeFile,shell);
    
View Full Code Here


    if(editor != null && editor.isEditable())
    {
     
     
    
      SnipKeyCombos keyCombos = new SnipKeyCombos();
     
     
     
        String sequence = "";
      IDocument doc =  editor.getDocumentProvider().getDocument(editor.getEditorInput());
      ISelection sel = editor.getSelectionProvider().getSelection();
     
      int cursorOffset = ((ITextSelection)sel).getOffset();
      int lastSpaceOffset = -1;
      //int nextSpaceOffset = -1;
      FindReplaceDocumentAdapter finder = new FindReplaceDocumentAdapter(doc);
     
     
      try {
          IRegion lastSpace = finder.find(cursorOffset-1,"[^\\*0-9a-zA-Z_-]",false,false,false,true);
         
          if (lastSpace == null) {
              lastSpaceOffset = 0;
          }
          else {
              lastSpaceOffset = lastSpace.getOffset()+1;
          }
         
         // System.out.println("Last Space at" + lastSpaceOffset);
         // System.out.println("Cursot at" + cursorOffset);
         
          if (cursorOffset > lastSpaceOffset) {
              // ok, it could be valid, but we need to check what comes after the cursor.
              if (cursorOffset != doc.getLength()) {
                  System.out.println("yep");
                  IRegion nextSpace = finder.find(cursorOffset-1,"[^\\*0-9a-zA-Z_-]",true,false,false,true);
                  if (nextSpace != null
                          && nextSpace.getOffset() == cursorOffset) {
                      //System.out.println("Next space bit");
                      sequence = doc.get().substring(lastSpaceOffset,cursorOffset);
                  }
                 
              }
              else {
                  sequence = doc.get().substring(lastSpaceOffset,cursorOffset);
              }
          }
      }
      catch (Exception e) {
          e.printStackTrace();
      }
   
     
      if(sequence.length() == 0){
        System.out.println("no trigger text has been passed in");
       
      }
     
      if (sequence.length() > 0) {
         
          String[] stringArray = sequence.split("\\*");
          String trigger = stringArray[0];
          int loopcount = 1;
          if (stringArray.length > 1) {
              loopcount = Integer.parseInt(stringArray[1].trim());
          }
        
          //Here starts the actual triggering of a snippet using the trigger text
         
          String fileName = keyCombos.getKeyCombo(trigger);
        
         
         
          SnipReader snipReader = new SnipReader();
         
View Full Code Here

TOP

Related Classes of org.cfeclipse.cfml.views.snips.SnipKeyCombos

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.