Skip to content

Commit

Permalink
word wrap-changes adobe#1
Browse files Browse the repository at this point in the history
  • Loading branch information
Darpan Pradhan authored and Darpan Pradhan committed Jan 3, 2013
1 parent 2e06e51 commit 9a30fb2
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions src/extensions/dev/WordWrap/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*jslint vars: true, plusplus: true, devel: true, nomen: true, regexp: true, indent: 4, maxerr: 50 */
/*global define, $, brackets, window */

define(function (require, exports, module) {
"use strict";

var CommandManager = brackets.getModule("command/CommandManager"),
Menus = brackets.getModule("command/Menus"),
EditorManager = brackets.getModule("editor/EditorManager"),
DocumentManager = brackets.getModule("document/DocumentManager"),
DocumentCommandHandlers = brackets.getModule("document/DocumentCommandHandlers");

var WORD_WRAP_COMMAND_ID = "view.wordwrap";

function checkUncheckWordWrapMenu() {
var wordWrapRef = CommandManager.get(WORD_WRAP_COMMAND_ID);
if (!wordWrapRef) {
return;
}
var toggleCheck = !wordWrapRef.getChecked();
wordWrapRef.setChecked(toggleCheck);

return toggleCheck;
}

function handleWordWrap() {
var isChecked = checkUncheckWordWrapMenu();

var listOfOpenDocuments = DocumentManager.getAllOpenDocuments();
DocumentManager.closeAll();
EditorManager.setWordWrapForEditor(isChecked);

var doc;
for (doc in listOfOpenDocuments) {
if (listOfOpenDocuments.hasOwnProperty(doc)) {
DocumentCommandHandlers.doOpen(listOfOpenDocuments[doc].file.fullPath);
DocumentManager.addToWorkingSet(listOfOpenDocuments[doc].file);
}
}
}

CommandManager.register("Word Wrap", WORD_WRAP_COMMAND_ID, handleWordWrap);

var menu = Menus.getMenu(Menus.AppMenuBar.VIEW_MENU);
menu.addMenuDivider();
menu.addMenuItem(WORD_WRAP_COMMAND_ID);
});

0 comments on commit 9a30fb2

Please sign in to comment.