public int getWordEnd(JTextComponent c, int offs) throws BadLocationException {
    	Document doc = c.getDocument();
    	//
    	String text=doc.getText(0,doc.getLength());
    	//
        int wordPosition = offs;
        boolean isEnd=false;
        while ((wordPosition>0)&&(!isEnd)) {
       		wordPosition--;
       		//
      		char pc=(wordPosition>0?text.charAt(wordPosition-1):'\n');
       		char cc=text.charAt(wordPosition);
       		boolean csc=isSeparatorChar(pc);
       		boolean psc=isSeparatorChar(cc);
       		//
       		isEnd=(!csc&&psc)||(csc&&psc&&(pc!=cc)||(csc&&!psc));
       		//
        } 
        //
    	return wordPosition;
    }