diff --git a/pd/nw/css/default.css b/pd/nw/css/default.css index 55193c58905602e14d8cc3a75ebd6bfbfc5e0b65..3bb087c628e5021acebc48dfa109c0a89d575ee0 100644 --- a/pd/nw/css/default.css +++ b/pd/nw/css/default.css @@ -38,6 +38,7 @@ margin: 8px; } +/* This needs to be renamed, since the "Find" bar is actually at the bottom */ #console_bottom { position: absolute; top: 50px; @@ -47,6 +48,14 @@ overflow-y: scroll; } +#console_find { + width: 100%; + height: 1em; + background: red; + position: fixed; + bottom: 0; +} + /* Pure Data Patch Window (aka canvas) */ /* patch font and background color. (Note: margin needs to stay at zero.) */ diff --git a/pd/nw/index.html b/pd/nw/index.html index a7dbcc0575b58e69486ceb94f4bba2aaa941925f..298ab02339358fe9ac553940c4baee9129e6a6ed 100644 --- a/pd/nw/index.html +++ b/pd/nw/index.html @@ -1,27 +1,44 @@ <!DOCTYPE html> <html> <head> - <link id="page_style" rel="stylesheet" type="text/css" href="css/default.css"> + <link id="page_style" rel="stylesheet" + type="text/css" href="css/default.css"> </head> <body id="console_body"> - <input style="display:none;" id="fileDialog" type="file" nwworkingdir multiple /> + <input style="display:none;" id="fileDialog" type="file" + nwworkingdir multiple /> <div id="console_controls" class="noselect"> <div id="control_frame"> - <label><input type="checkbox" id="dsp_control" name="dsp_control" value="on"/>Compute Audio</label> + <label><input type="checkbox" id="dsp_control" name="dsp_control" + value="on"/>Compute Audio + </label> </div> </div> - <script type="text/javascript" src="index.js"> - </script> + <script type="text/javascript" src="index.js"></script> <input style="display:none;" id="saveDialog" type="file" nwsaveas /> <div id = "console_bottom"> <div id = "printout"> - <pre id="p1" style="white-space: pre-wrap;">Welcome to Pd GUI using Node-Webkit + <pre id="p1" + style="white-space: pre-wrap;">Welcome to Pd GUI using Node-Webkit <script>document.write(process.versions['node-webkit'])</script><br/></pre> </div> </div> + <div id = "console_find" style="display:none;"> + <div> + <label><input type="text" + id="console_find_text" + name="console_find_text" + defaultValue="Search in Console" + style="width:10em;" + onfocus="console_find_input_focus(this)" + onblur="console_find_input_blur(this)"/>XXXXXX + </label> + </div> + </div> <script> - - + var t = document.getElementById('console_find_text'); + t.defaultValue = "Search in Console"; + console_find_input_blur(t); </script> </body> </html> diff --git a/pd/nw/index.js b/pd/nw/index.js index 46cd11aa6338826cea7991599c2b94b63a18f1e4..9cbd22de1487682fa517970279236e8f7c3617c0 100644 --- a/pd/nw/index.js +++ b/pd/nw/index.js @@ -55,6 +55,20 @@ pdgui.init_socket_events(); pdgui.set_new_window_fn(nw_create_window); pdgui.set_close_window_fn(nw_close_window); +// Greyed out text for the "Find" bar +function console_find_input_focus(e) { + if (e.value === e.defaultValue) { + e.value = ''; + e.style.color = "#000"; + } +} + +function console_find_input_blur(e) { + if (e.value === '' || e.value === e.defaultValue) { + e.value = e.defaultValue; + e.style.color = "#888"; + } +} function pdmenu_copy () { alert("Please implement pdmenu_copy"); @@ -290,6 +304,31 @@ function nw_create_pd_window_menus () { tooltip: l('menu.zoomout_tt') })); + editMenu.append(new nw.MenuItem({ + type: 'separator' + })); + + editMenu.append(new nw.MenuItem({ + label: l('menu.find'), + click: function () { + var find_bar = document.getElementById('console_find'), + text_container = document.getElementById('console_bottom'), + state = find_bar.style.getPropertyValue('display'); + if (state === 'none') { + text_container.style.setProperty('bottom', '1em'); + find_bar.style.setProperty('display', 'inline'); + find_bar.style.setProperty('height', '1em'); + text_container.scrollTop = text_container.scrollHeight; + } else { + text_container.style.setProperty('bottom', '0px'); + find_bar.style.setProperty('display', 'none'); + } + }, + key: 'f', + modifiers: "ctrl", + tooltip: l('menu.find_tt') + })); + editMenu.append(new nw.MenuItem({ label: l('menu.preferences'), click: pdgui.open_prefs, diff --git a/pd/nw/locales/en/translation.json b/pd/nw/locales/en/translation.json index 3df5dacbee42b2fc90d108d68cd1011e1903b16f..cf0808211b93af19e213328fffb3e35c0892f537 100644 --- a/pd/nw/locales/en/translation.json +++ b/pd/nw/locales/en/translation.json @@ -130,6 +130,8 @@ "zoomin_tt": "Make the patch visually larger", "zoomout": "Zoom Out", "zoomout_tt": "Make the patch visually smaller", + "find": "Find", + "find_tt": "Find text in the console output", "tidyup": "Tidy Up", "tidyup_tt": "Line up the selected objects in straight rows and columns", "tofront": "Bring to Front",