Guest User

jumanj.c patch for JumNav v. 0.3

a guest
Aug 11th, 2010
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 2.54 KB | None | 0 0
  1. --- jumanji.c   2010-08-11 12:06:08.000000000 +0000
  2. +++ jumanji.c.new   2010-08-11 12:06:32.000000000 +0000
  3. @@ -1619,6 +1619,14 @@
  4.        Jumanji.Global.buffer = temp;
  5.        gtk_label_set_markup((GtkLabel*) Jumanji.Statusbar.buffer, Jumanji.Global.buffer->str);
  6.      }
  7. +    /* Make sure the follower script gets known of the buffer change */
  8. +    if(Jumanji.Global.mode == FOLLOW)
  9. +    {
  10. +       /* not sure if there will be side effects by the NULL value
  11. +   * but it will not be used in this case after all */
  12. +      Argument argument = {0, NULL};
  13. +      sc_follow_link(&argument);
  14. +    }
  15.    }
  16.  }
  17.  
  18. @@ -1713,20 +1721,62 @@
  19.      else
  20.        cmd = g_strdup("focus_next()");
  21.    }
  22. -  else if(Jumanji.Global.buffer && Jumanji.Global.buffer->len > 0)
  23. -    cmd = g_strconcat("update_hints(\"", Jumanji.Global.buffer->str, "\")", NULL);
  24. +  else if(Jumanji.Global.buffer)
  25. +  {
  26. +    if(Jumanji.Global.buffer->len > 0)
  27. +    {
  28. +      cmd = g_strconcat("update_hints(\"", Jumanji.Global.buffer->str, "\")", NULL);
  29. +    }
  30. +    else if(Jumanji.Global.buffer->len == 0)
  31. +    {
  32. +      /* probably not needed actually (see below), just for being sure */
  33. +      cmd = g_strconcat("update_hints(\"", "", "\")", NULL);
  34. +    }
  35. +  }
  36. +  else
  37. +  {
  38. +    /* jumanji removes the buffer if it gets cleared on a delete operation
  39. +     * (hopefully there are no nasty side effects) */
  40. +    cmd = g_strconcat("update_hints(\"", "", "\")", NULL);
  41. +  }
  42.  
  43.    run_script(cmd, &value, NULL);
  44.    g_free(cmd);
  45.  
  46.    if(value && strcmp(value, "undefined"))
  47.    {
  48. -    if(open_mode == -1)
  49. -      open_uri(GET_CURRENT_TAB(), value);
  50. +    /* Was there a buffer reset special command returned? */
  51. +    if(value[0] == '\\')
  52. +    {
  53. +      /* Clear and remove the global buffer if it exists. */
  54. +      if(Jumanji.Global.buffer)
  55. +      {
  56. +   g_string_free(Jumanji.Global.buffer, TRUE);
  57. +   Jumanji.Global.buffer = NULL;
  58. +   gtk_label_set_markup((GtkLabel*) Jumanji.Statusbar.buffer, "");
  59. +      }
  60. +      if(strlen(value) > 1)
  61. +      {
  62. +   /* Moreover: was there a mode change command returned? */
  63. +   if(value[1] == '\\')
  64. +   {
  65. +     /* clear modes */
  66. +     change_mode(NORMAL);
  67. +     gtk_widget_hide(GTK_WIDGET(Jumanji.UI.inputbar));
  68. +     webkit_web_view_unmark_text_matches(GET_CURRENT_TAB());
  69. +   }
  70. +      }
  71. +    }
  72.      else
  73. -      create_tab(value, TRUE);
  74. +    {
  75. +      /* There has been an address returned. Go there. */
  76. +      if(open_mode == -1)
  77. +   open_uri(GET_CURRENT_TAB(), value);
  78. +      else
  79. +   create_tab(value, TRUE);
  80.  
  81. -    sc_abort(NULL);
  82. +      sc_abort(NULL);
  83. +    }
  84.    }
  85.  }
Advertisement
Add Comment
Please, Sign In to add comment