Skip to content

Commit

Permalink
ajout indentation et auto-indentation
Browse files Browse the repository at this point in the history
  • Loading branch information
laurentpetit committed Mar 19, 2010
1 parent d83823e commit bb1fd92
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 11 deletions.
4 changes: 2 additions & 2 deletions ccw.core/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Counterclockwise Clojure Plug-in
Bundle-SymbolicName: ccw.core;singleton:=true
Bundle-Version: 0.0.50.A010
Bundle-Version: 0.0.50.B010
Bundle-Localization: plugin
Bundle-Activator: ccw.CCWPlugin
Require-Bundle: org.eclipse.ui,
Expand All @@ -22,7 +22,7 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.core.expressions,
org.eclipse.ui.forms,
ccw.clojure;bundle-version="1.1.0",
paredit.clj;bundle-version="0.1.0",
paredit.clj;bundle-version="0.2.0",
ccw.clojurecontrib;bundle-version="1.1.0"
Export-Package: ccw,
ccw.actions,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -675,4 +675,9 @@ public final ISourceViewer sourceViewer() {
public void setStatusLineErrorMessage(String message) {
super.setStatusLineMessage(message);
}

@Override
protected boolean isTabsToSpacesConversionEnabled() {
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,7 @@ public IAutoEditStrategy[] getAutoEditStrategies(
ISourceViewer sourceViewer, final String contentType) {

return new IAutoEditStrategy[] {
new PareditAutoEditStrategy(editor, fPreferenceStore)
, new org.eclipse.jface.text.DefaultIndentLineAutoEditStrategy() };
new PareditAutoEditStrategy(editor, fPreferenceStore) };
}

}
18 changes: 12 additions & 6 deletions ccw.core/src/ccw/editors/antlrbased/PareditAutoEditStrategy.clj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
:init init
:state state))

#_(set! *warn-on-reflection* true)

(defn- -init
[editor preference-store] [[] (ref {:editor editor :prefs-store preference-store})])

Expand All @@ -23,7 +25,10 @@
")" :paredit-close-round
"]" :paredit-close-square
"}" :paredit-close-curly
"\"" :paredit-doublequote})
"\"" :paredit-doublequote
"\t" :paredit-indent-line
"\n" :paredit-newline
})

(defn- call-paredit [command document-text]
(cond
Expand All @@ -33,7 +38,7 @@
{:text (:text document-text)
:offset (:offset command)
:length 0})
(and (zero? (-> command :text .length))
(and (zero? (-> command #^String (:text) .length))
(= 1 (:length command)))
(let [paredit-command (if (= (:offset command) (:caret-offset document-text))
:paredit-forward-delete :paredit-backward-delete)]
Expand All @@ -48,11 +53,10 @@
(.getBoolean prefs-store ccw.preferences.PreferenceConstants/ACTIVATE_PAREDIT))

(defn -customizeDocumentCommand
[#^IAutoEditStrategy this, #^IDocument document, #^DocumentCommand command]
[#^ccw.editors.antlrbased.PareditAutoEditStrategy this, #^IDocument document, #^DocumentCommand command]
(when (and (paredit-enabled? (-> this .state deref :prefs-store))
(.doit command))

(let [signed-selection (bean (-> this .state deref :editor .getSignedSelection))
(let [signed-selection (bean (-> this .state deref #^ccw.editors.antlrbased.AntlrBasedClojureEditor (:editor) .getSignedSelection))
document-text {:text (.get document) :caret-offset (+ (:offset signed-selection) (:length signed-selection)) :selection-length (:length signed-selection)}
par-command {:text (.text command) :offset (.offset command) :length (.length command)}
result (call-paredit par-command document-text)]
Expand All @@ -61,7 +65,9 @@
(do
(set! (.offset command) (-> result :modifs first :offset))
(set! (.length command) (-> result :modifs first :length))
(set! (.text command) (-> result :modifs first :text)))
(set! (.text command) (-> result :modifs first :text))
(doseq [{:keys [offset length text]} (rest (-> result :modifs))]
(.addCommand command offset length text nil)))
(do
(set! (.offset command) (:offset result))
(set! (.length command) 0)
Expand Down
2 changes: 1 addition & 1 deletion ccw.feature/feature.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<feature
id="ccw.feature"
label="%featureName"
version="0.0.50.A010"
version="0.0.50.B010"
provider-name="%providerName"
plugin="ccw.branding">

Expand Down

0 comments on commit bb1fd92

Please sign in to comment.