Example #1
0
 public double getMaxSuggestionsHeight() {
   double ret = (app.getHeight() / 2);
   if (component != null) {
     ret =
         Math.max(
             29,
             Math.min(
                 ret,
                 app.getHeight()
                     + ((AppW) app).getAbsTop()
                     - component.getAbsoluteTop()
                     - component.toWidget().getOffsetHeight()
                     - ((AppW) app).getAppletFrame().getKeyboardHeight()));
   }
   return ret;
 }
Example #2
0
  public AutoCompleteDictionary getDictionary() {
    if (this.dict == null) {

      this.dict = component.isForCAS() ? app.getCommandDictionaryCAS() : app.getCommandDictionary();
    }
    return dict;
  }
Example #3
0
  /**
   * As adding focus handlers to JavaScript code would be too complex, let's do it even before they
   * actually get focus, i.e. make a method that triggers focus, and then override it if necessary
   *
   * @param b focus (false: blur)
   */
  public void setFocus(boolean b) {
    MathQuillHelper.focusEquationMathQuillGGB(component.getLaTeXElement(), b);

    // as the focus operation sometimes also scrolls
    // if (b)
    // geogebra.html5.main.DrawEquationWeb.scrollCursorIntoView(this,
    // seMayLatex);
    // put to focus handler
  }
Example #4
0
  /*
   * Take a list of commands and return all possible syntaxes for these
   * commands
   */
  private List<String> getSyntaxes(List<String> commands) {
    if (commands == null) {
      return null;
    }
    ArrayList<String> syntaxes = new ArrayList<String>();
    for (String cmd : commands) {

      String cmdInt = app.getInternalCommand(cmd);
      Localization loc = app.getLocalization();
      String syntaxString;
      if (component.isForCAS()) {
        syntaxString = app.getLocalization().getCommandSyntaxCAS(cmdInt);
      } else {
        syntaxString =
            app.getExam() == null
                ? loc.getCommandSyntax(cmdInt)
                : app.getExam().getSyntax(cmdInt, loc, app.getSettings());
      }
      if (syntaxString != null) {
        if (syntaxString.endsWith(
            component.isForCAS() ? Localization.syntaxCAS : Localization.syntaxStr)) {

          // command not found, check for macros
          Macro macro = component.isForCAS() ? null : app.getKernel().getMacro(cmd);
          if (macro != null) {
            syntaxes.add(macro.toString());
          } else {
            // syntaxes.add(cmdInt + "[]");
            Log.debug("Can't find syntax for: " + cmd);
          }

          continue;
        }
        for (String syntax : syntaxString.split("\\n")) {
          syntaxes.add(syntax);
        }
      }
    }
    return syntaxes;
  }
Example #5
0
 public void setText(String s, boolean shallfocus) {
   String slatex = historyMap.get(s);
   if (slatex == null) {
     slatex = s;
   }
   Log.debug("HIST READ" + slatex + "," + s);
   if (slatex != null) {
     slatex =
         slatex
             .replace("\\$", "\\dollar ")
             .replace("$", "\\dollar ")
             .replace("(", "\\left(")
             .replace(")", "\\right)")
             .replace("\\left\\left(", "\\left(")
             .replace("\\right\\right)", "\\right)");
   }
   MathQuillHelper.updateEditingMathQuillGGB(component.getLaTeXElement(), slatex, shallfocus);
 }
Example #6
0
  public void autocomplete(String sugg, boolean replace) {
    // For now, we can assume that sugg is in LaTeX format,
    // and if it will be wrong, we can revise it later
    // at the moment we shall focus on replacing the current
    // word in MathQuillGGB with it...

    // Although MathQuillGGB could compute the current word,
    // it might not be the same as the following, as
    // maybe it can be done easily for English characters
    // but current word shall be internationalized to e.g.
    // Hungarian, or even Arabic, Korean, etc. which are
    // known by GeoGebra but unknown by MathQuillGGB...
    updateCurrentWord(false);
    String currentWord = curWord.toString();

    // So we also provide currentWord as a heuristic or helper:
    MathQuillHelper.writeLatexInPlaceOfCurrentWord(
        null, component.getLaTeXElement(), sugg, replace ? currentWord : "", true);

    // not to forget making the popup disappear after success!
    sug.hideSuggestions();
  }
Example #7
0
 protected void updateSuggestions(Response res) {
   sug.updateHeight();
   component.updatePosition(sug);
   sug.accessShowSuggestions(res, popup, sugCallback);
 }
Example #8
0
 public String getText() {
   return component.getText();
 }
Example #9
0
 public int getCaretPosition() {
   return MathQuillHelper.getCaretPosInEditedValue(component.getLaTeXElement());
 }
Example #10
0
 /**
  * Updates curWord to word at current caret position. curWordStart, curWordEnd are set to this
  * word's start and end position Code copied from AutoCompleteTextFieldW
  */
 public void updateCurrentWord(boolean searchRight) {
   InputHelper.updateCurrentWord(
       searchRight, this.curWord, component.getText(), getCaretPosition(), false);
 }