Show More
@@ -321,7 +321,7 b' div.text_cell_render {' | |||||
321 | .ansigrey {color: grey;} |
|
321 | .ansigrey {color: grey;} | |
322 | .ansibold {font-weight: bold;} |
|
322 | .ansibold {font-weight: bold;} | |
323 |
|
323 | |||
324 | .completions { |
|
324 | .completions , .tooltip{ | |
325 | position: absolute; |
|
325 | position: absolute; | |
326 | z-index: 10; |
|
326 | z-index: 10; | |
327 | overflow: auto; |
|
327 | overflow: auto; | |
@@ -337,6 +337,36 b' div.text_cell_render {' | |||||
337 | font-family: monospace; |
|
337 | font-family: monospace; | |
338 | } |
|
338 | } | |
339 |
|
339 | |||
|
340 | @-moz-keyframes fadeIn { | |||
|
341 | from {opacity:0;} | |||
|
342 | to {opacity:1;} | |||
|
343 | } | |||
|
344 | ||||
|
345 | @-webkit-keyframes fadeIn { | |||
|
346 | from {opacity:0;} | |||
|
347 | to {opacity:1;} | |||
|
348 | } | |||
|
349 | ||||
|
350 | @keyframes fadeIn { | |||
|
351 | from {opacity:0;} | |||
|
352 | to {opacity:1;} | |||
|
353 | } | |||
|
354 | ||||
|
355 | ||||
|
356 | .tooltip{ | |||
|
357 | border-radius: 0px 10px 10px 10px; | |||
|
358 | box-shadow: 3px 3px 5px #999; | |||
|
359 | -webkit-animation: fadeIn 200ms; | |||
|
360 | -moz-animation: fadeIn 200ms; | |||
|
361 | animation: fadeIn 200ms; | |||
|
362 | vertical-align: middle; | |||
|
363 | background: #FDFDD8; | |||
|
364 | outline: none; | |||
|
365 | padding: 3px; | |||
|
366 | margin: 0px; | |||
|
367 | font-family: monospace; | |||
|
368 | } | |||
|
369 | ||||
340 | @media print { |
|
370 | @media print { | |
341 | body { overflow: visible !important; } |
|
371 | body { overflow: visible !important; } | |
342 | .ui-widget-content { border: 0px; } |
|
372 | .ui-widget-content { border: 0px; } |
@@ -53,9 +53,29 b' var IPython = (function (IPython) {' | |||||
53 | // handlers and is used to provide custom key handling. Its return |
|
53 | // handlers and is used to provide custom key handling. Its return | |
54 | // value is used to determine if CodeMirror should ignore the event: |
|
54 | // value is used to determine if CodeMirror should ignore the event: | |
55 | // true = ignore, false = don't ignore. |
|
55 | // true = ignore, false = don't ignore. | |
|
56 | ||||
|
57 | // whatever key is pressed, first, cancel the tooltip request before | |||
|
58 | // they are sent, and remove tooltip if any | |||
|
59 | if(event.type === 'keydown' && this.tooltip_timeout != null){ | |||
|
60 | CodeCell.prototype.remove_and_cancell_tooltip(this.tooltip_timeout); | |||
|
61 | this.tooltip_timeout=null; | |||
|
62 | } | |||
56 | if (event.keyCode === 13 && (event.shiftKey || event.ctrlKey)) { |
|
63 | if (event.keyCode === 13 && (event.shiftKey || event.ctrlKey)) { | |
57 | // Always ignore shift-enter in CodeMirror as we handle it. |
|
64 | // Always ignore shift-enter in CodeMirror as we handle it. | |
58 | return true; |
|
65 | return true; | |
|
66 | }else if (event.keyCode === 53 && event.type === 'keydown') { | |||
|
67 | var cursor = editor.getCursor(); | |||
|
68 | var pre_cursor = editor.getRange({line:cursor.line,ch:0},cursor).trim(); | |||
|
69 | if (pre_cursor === "") { | |||
|
70 | // don't do anything if line beggin with '(' | |||
|
71 | } else { | |||
|
72 | var that = this; | |||
|
73 | // Will set a timer to request tooltip in 1200ms | |||
|
74 | this.tooltip_timeout = setTimeout(function(){ | |||
|
75 | IPython.notebook.request_tool_tip(that, pre_cursor) | |||
|
76 | },1200); | |||
|
77 | } | |||
|
78 | ||||
59 | } else if (event.keyCode === 9 && event.type == 'keydown') { |
|
79 | } else if (event.keyCode === 9 && event.type == 'keydown') { | |
60 | // Tab completion. |
|
80 | // Tab completion. | |
61 | var cur = editor.getCursor(); |
|
81 | var cur = editor.getCursor(); | |
@@ -108,6 +128,39 b' var IPython = (function (IPython) {' | |||||
108 | }; |
|
128 | }; | |
109 | }; |
|
129 | }; | |
110 |
|
130 | |||
|
131 | CodeCell.prototype.remove_and_cancell_tooltip = function(timeout) | |||
|
132 | { | |||
|
133 | // note that we don't handle closing directly inside the calltip | |||
|
134 | // as in the completer, because it is not focusable, so won't | |||
|
135 | // get the event. | |||
|
136 | clearTimeout(timeout); | |||
|
137 | $('#tooltip').remove(); | |||
|
138 | } | |||
|
139 | ||||
|
140 | CodeCell.prototype.finish_tooltip = function (defstring,docstring) { | |||
|
141 | shortened = function(string){ | |||
|
142 | if(string.length > 200){ | |||
|
143 | return string.trim().substring(0,197)+'...'; | |||
|
144 | } else { return string.trim() } | |||
|
145 | } | |||
|
146 | ||||
|
147 | var that = this; | |||
|
148 | var tooltip = $('<div/>').attr('id', 'tooltip').addClass('tooltip'); | |||
|
149 | if(defstring){ | |||
|
150 | defstring_html= $('<pre/>').html(utils.fixConsole(defstring)); | |||
|
151 | tooltip.append(defstring_html); | |||
|
152 | } | |||
|
153 | tooltip.append($('<pre/>').html(utils.fixConsole(shortened(docstring)))); | |||
|
154 | var pos = this.code_mirror.cursorCoords(); | |||
|
155 | tooltip.css('left',pos.x+'px'); | |||
|
156 | tooltip.css('top',pos.yBot+'px'); | |||
|
157 | $('body').append(tooltip); | |||
|
158 | ||||
|
159 | // issues with cross-closing if multiple tooltip in less than 5sec | |||
|
160 | // keep it comented for now | |||
|
161 | // setTimeout(CodeCell.prototype.remove_and_cancell_tooltip, 5000); | |||
|
162 | }; | |||
|
163 | ||||
111 |
|
164 | |||
112 | CodeCell.prototype.finish_completing = function (matched_text, matches) { |
|
165 | CodeCell.prototype.finish_completing = function (matched_text, matches) { | |
113 | // console.log("Got matches", matched_text, matches); |
|
166 | // console.log("Got matches", matched_text, matches); |
@@ -170,6 +170,15 b' var IPython = (function (IPython) {' | |||||
170 | }; |
|
170 | }; | |
171 | }; |
|
171 | }; | |
172 |
|
172 | |||
|
173 | Kernel.prototype.object_info_request = function (objname) { | |||
|
174 | var content = { | |||
|
175 | oname : objname.toString(), | |||
|
176 | }; | |||
|
177 | var msg = this.get_msg("object_info_request", content); | |||
|
178 | this.shell_channel.send(JSON.stringify(msg)); | |||
|
179 | return msg.header.msg_id; | |||
|
180 | } | |||
|
181 | ||||
173 | Kernel.prototype.execute = function (code) { |
|
182 | Kernel.prototype.execute = function (code) { | |
174 | var content = { |
|
183 | var content = { | |
175 | code : code, |
|
184 | code : code, |
@@ -700,14 +700,29 b' var IPython = (function (IPython) {' | |||||
700 | this.dirty = true; |
|
700 | this.dirty = true; | |
701 | } else if (msg_type === "complete_reply") { |
|
701 | } else if (msg_type === "complete_reply") { | |
702 | cell.finish_completing(content.matched_text, content.matches); |
|
702 | cell.finish_completing(content.matched_text, content.matches); | |
703 | }; |
|
703 | } else if (msg_type === "object_info_reply"){ | |
704 | var payload = content.payload || []; |
|
704 | //console.log('back from object_info_request : ') | |
705 | this.handle_payload(cell, payload); |
|
705 | rep = reply.content; | |
|
706 | if(rep.found) | |||
|
707 | { | |||
|
708 | console.log("object as been found"); | |||
|
709 | cell.finish_tooltip(rep.definition,rep.docstring); | |||
|
710 | } | |||
|
711 | } else { | |||
|
712 | //console.log("unknown reply:"+msg_type); | |||
|
713 | } | |||
|
714 | // when having a rely from object_info_reply, | |||
|
715 | // no payload so no nned to handle it | |||
|
716 | if(typeof(content.payload)!='undefined') { | |||
|
717 | var payload = content.payload || []; | |||
|
718 | this.handle_payload(cell, payload); | |||
|
719 | } | |||
706 | }; |
|
720 | }; | |
707 |
|
721 | |||
708 |
|
722 | |||
709 | Notebook.prototype.handle_payload = function (cell, payload) { |
|
723 | Notebook.prototype.handle_payload = function (cell, payload) { | |
710 | var l = payload.length; |
|
724 | var l = payload.length; | |
|
725 | console.log(payload); | |||
711 | for (var i=0; i<l; i++) { |
|
726 | for (var i=0; i<l; i++) { | |
712 | if (payload[i].source === 'IPython.zmq.page.page') { |
|
727 | if (payload[i].source === 'IPython.zmq.page.page') { | |
713 | if (payload[i].text.trim() !== '') { |
|
728 | if (payload[i].text.trim() !== '') { | |
@@ -868,6 +883,14 b' var IPython = (function (IPython) {' | |||||
868 | }; |
|
883 | }; | |
869 |
|
884 | |||
870 |
|
885 | |||
|
886 | Notebook.prototype.request_tool_tip = function (cell,func) { | |||
|
887 | // select last part of expression | |||
|
888 | var re = /[a-zA-Z._]+$/g; | |||
|
889 | var lastpart=re.exec(func); | |||
|
890 | var msg_id = this.kernel.object_info_request(lastpart); | |||
|
891 | this.msg_cell_map[msg_id] = cell.cell_id; | |||
|
892 | }; | |||
|
893 | ||||
871 | Notebook.prototype.complete_cell = function (cell, line, cursor_pos) { |
|
894 | Notebook.prototype.complete_cell = function (cell, line, cursor_pos) { | |
872 | var msg_id = this.kernel.complete(line, cursor_pos); |
|
895 | var msg_id = this.kernel.complete(line, cursor_pos); | |
873 | this.msg_cell_map[msg_id] = cell.cell_id; |
|
896 | this.msg_cell_map[msg_id] = cell.cell_id; |
General Comments 0
You need to be logged in to leave comments.
Login now