src/Tools/jEdit/src/keymap_merge.scala
changeset 63750 9c8a366778e1
parent 63748 ebcc70c120a9
child 63753 c57db6b2befc
equal deleted inserted replaced
63749:4fe8cfaeb1fc 63750:9c8a366778e1
    51       Library.space_explode(',', jEdit.getProperty(prop_ignore, ""))
    51       Library.space_explode(',', jEdit.getProperty(prop_ignore, ""))
    52 
    52 
    53     def is_ignored(keymap_name: String): Boolean =
    53     def is_ignored(keymap_name: String): Boolean =
    54       ignored_keymaps().contains(keymap_name)
    54       ignored_keymaps().contains(keymap_name)
    55 
    55 
    56     def ignore(keymap_name: String, b: Boolean)
    56     def ignore(keymap_name: String)
    57     {
    57     {
    58       val keymaps1 =
    58       val keymaps1 = Library.insert(keymap_name)(ignored_keymaps()).sorted
    59         if (b) Library.insert(keymap_name)(ignored_keymaps()).sorted
       
    60         else Library.remove(keymap_name)(ignored_keymaps())
       
    61 
       
    62       if (keymaps1.isEmpty) jEdit.resetProperty(prop_ignore)
    59       if (keymaps1.isEmpty) jEdit.resetProperty(prop_ignore)
    63       else jEdit.setProperty(prop_ignore, keymaps1.mkString(","))
    60       else jEdit.setProperty(prop_ignore, keymaps1.mkString(","))
    64     }
    61     }
    65 
    62 
    66     def set(keymap: Keymap): Unit = keymap.setShortcut(property, binding)
    63     def set(keymap: Keymap): Unit = keymap.setShortcut(property, binding)
   141         val b = is_selected(row)
   138         val b = is_selected(row)
   142         if (b) {
   139         if (b) {
   143           entry.tail.foreach(i => entries(i).shortcut.reset(keymap))
   140           entry.tail.foreach(i => entries(i).shortcut.reset(keymap))
   144           entry.shortcut.set(keymap)
   141           entry.shortcut.set(keymap)
   145         }
   142         }
   146         entry.shortcut.ignore(keymap_name, !b)
   143         else
       
   144           entry.shortcut.ignore(keymap_name)
   147       }
   145       }
   148     }
   146     }
   149 
   147 
   150     override def getColumnCount: Int = 2
   148     override def getColumnCount: Int = 2
   151 
   149 
   227       keymap_manager.getKeymap(keymap_name) match {
   225       keymap_manager.getKeymap(keymap_name) match {
   228         case null => keymap_manager.getKeymap(KeymapManager.DEFAULT_KEYMAP_NAME)
   226         case null => keymap_manager.getKeymap(KeymapManager.DEFAULT_KEYMAP_NAME)
   229         case keymap => keymap
   227         case keymap => keymap
   230       }
   228       }
   231 
   229 
   232     var save = false
       
   233 
       
   234     val all_shortcut_conflicts = get_shortcut_conflicts(keymap_name, keymap)
   230     val all_shortcut_conflicts = get_shortcut_conflicts(keymap_name, keymap)
   235     val no_shortcut_conflicts = for ((s, cs) <- all_shortcut_conflicts if cs.isEmpty) yield s
   231     val no_shortcut_conflicts = for ((s, cs) <- all_shortcut_conflicts if cs.isEmpty) yield s
   236     val shortcut_conflicts = all_shortcut_conflicts.filter(_._2.nonEmpty)
   232     val shortcut_conflicts = all_shortcut_conflicts.filter(_._2.nonEmpty)
   237 
   233 
   238     val table_entries =
   234     val table_entries =
   253           "The following Isabelle keymap changes are in conflict with",
   249           "The following Isabelle keymap changes are in conflict with",
   254           "the current jEdit keymap " + quote(keymap_name) + ".",
   250           "the current jEdit keymap " + quote(keymap_name) + ".",
   255           new Table(table_model),
   251           new Table(table_model),
   256           "Selected shortcuts will be applied, unselected changes will be ignored.",
   252           "Selected shortcuts will be applied, unselected changes will be ignored.",
   257           "Results are made persistent in $JEDIT_SETTINGS/properties.") == 0)
   253           "Results are made persistent in $JEDIT_SETTINGS/properties.") == 0)
   258     {
   254     { table_model.apply(keymap_name, keymap) }
   259       table_model.apply(keymap_name, keymap)
   255 
   260       save = true
   256     no_shortcut_conflicts.foreach(_.set(keymap))
   261     }
   257 
   262 
   258     keymap.save()
   263     if (no_shortcut_conflicts.nonEmpty) {
   259     keymap_manager.reload()
   264       no_shortcut_conflicts.foreach(_.set(keymap))
   260     jEdit.saveSettings()
   265       save = true
       
   266     }
       
   267 
       
   268     if (save) {
       
   269       keymap_manager.reload()
       
   270       jEdit.saveSettings()
       
   271     }
       
   272   }
   261   }
   273 }
   262 }