diff --git a/src/nls/root/strings.js b/src/nls/root/strings.js index 41cd9cd6512..c4a9d4867d2 100644 --- a/src/nls/root/strings.js +++ b/src/nls/root/strings.js @@ -120,6 +120,11 @@ define({ "BUTTON_REPLACE_ALL" : "All\u2026", "BUTTON_STOP" : "Stop", "BUTTON_REPLACE" : "Replace", + + "BUTTON_NEXT" : "\u25B6", + "BUTTON_PREV" : "\u25C0", + "BUTTON_NEXT_HINT" : "Next Match", + "BUTTON_PREV_HINT" : "Previous Match", "OPEN_FILE" : "Open File", "SAVE_FILE_AS" : "Save File", diff --git a/src/search/FindReplace.js b/src/search/FindReplace.js index 9f6e3975997..2a0dc94958f 100644 --- a/src/search/FindReplace.js +++ b/src/search/FindReplace.js @@ -182,8 +182,16 @@ define(function (require, exports, module) { } var queryDialog = Strings.CMD_FIND + - ":
"; + ": " + + "" + + "" + + ""; /** * If no search pending, opens the search dialog. If search is already open, moves to @@ -203,6 +211,15 @@ define(function (require, exports, module) { // occurrence. var searchStartPos = cm.getCursor(true); + //Helper method to enable next / prev navigation in Find modal bar. + function enableFindNavigator(show) { + if (show) { + $(".modal-bar .navigator").css("display", "inline-block"); + } else { + $(".modal-bar .navigator").css("display", "none"); + } + } + // Called each time the search query changes while being typed. Jumps to the first matching // result, starting from the original cursor position function findFirst(query) { @@ -215,6 +232,7 @@ define(function (require, exports, module) { if (!state.query) { // Search field is empty - no results $("#find-counter").text(""); + enableFindNavigator(false); cm.setCursor(searchStartPos); if (modalBar) { getDialogTextField().removeClass("no-results"); @@ -222,6 +240,9 @@ define(function (require, exports, module) { return; } + //Flag that controls the navigation controls. + var enableNavigator = false; + // Highlight all matches // (Except on huge documents, where this is too expensive) if (cm.getValue().length < 500000) { @@ -243,19 +264,24 @@ define(function (require, exports, module) { cursor = getSearchCursor(cm, state.query, {line: cursor.to().line + 1, ch: 0}); } } - + if (resultCount === 0) { $("#find-counter").text(Strings.FIND_NO_RESULTS); } else if (resultCount === 1) { - $("#find-counter").text(Strings.FIND_RESULT_COUNT_SINGLE); + $("#find-counter").text(Strings.FIND_RESULT_COUNT_SINGLE); } else { $("#find-counter").text(StringUtils.format(Strings.FIND_RESULT_COUNT, resultCount)); + enableNavigator = true; } } else { $("#find-counter").text(""); + enableNavigator = true; } + //Enable Next/Prev navigator buttons if necessary + enableFindNavigator(enableNavigator); + state.posFrom = state.posTo = searchStartPos; var foundAny = findNext(editor, rev); @@ -291,6 +317,14 @@ define(function (require, exports, module) { $(cm.getWrapperElement()).removeClass("find-highlighting"); }); + modalBar.getRoot().on("click", function (e) { + if (e.target.id === "find-next") { + _findNext(); + } else if (e.target.id === "find-prev") { + _findPrevious(); + } + }); + var $input = getDialogTextField(); $input.on("input", function () { findFirst($input.val()); diff --git a/src/styles/brackets.less b/src/styles/brackets.less index b38e9dd477b..638012d8160 100644 --- a/src/styles/brackets.less +++ b/src/styles/brackets.less @@ -886,6 +886,13 @@ a, img { } } +.modal-bar .navigator { + display: none; + button { + margin: 2px 1px 3px; + } +} + // Search result highlighting - CodeMirror highlighting is pretty constrained. Highlights are // blended on TOP of the selection color. The "current" search result is indicated by selection, // so we want the selection visible underneath the highlight. To do this, the highlight must be @@ -904,6 +911,7 @@ a, img { } #find-counter { font-weight: @font-weight-semibold; + padding: 0 5px; }