/* * Common code, invoked when the mouse is resting for a moment. */ void general_beval_cb(BalloonEval *beval, int state UNUSED) { #ifdef FEAT_EVAL win_T *wp; int col; int use_sandbox; linenr_T lnum; char_u *text; static char_u *result = NULL; long winnr = 0; char_u *bexpr; buf_T *save_curbuf; size_t len; # ifdef FEAT_WINDOWS win_T *cw; # endif #endif static int recursive = FALSE; /* Don't do anything when 'ballooneval' is off, messages scrolled the * windows up or we have no beval area. */ if (!p_beval || balloonEval == NULL || msg_scrolled > 0) return; /* Don't do this recursively. Happens when the expression evaluation * takes a long time and invokes something that checks for CTRL-C typed. */ if (recursive) return; recursive = TRUE; #ifdef FEAT_EVAL if (get_beval_info(balloonEval, TRUE, &wp, &lnum, &text, &col) == OK) { bexpr = (*wp->w_buffer->b_p_bexpr == NUL) ? p_bexpr : wp->w_buffer->b_p_bexpr; if (*bexpr != NUL) { # ifdef FEAT_WINDOWS /* Convert window pointer to number. */ for (cw = firstwin; cw != wp; cw = cw->w_next) ++winnr; # endif set_vim_var_nr(VV_BEVAL_BUFNR, (long)wp->w_buffer->b_fnum); set_vim_var_nr(VV_BEVAL_WINNR, winnr); set_vim_var_nr(VV_BEVAL_WINID, wp->w_id); set_vim_var_nr(VV_BEVAL_LNUM, (long)lnum); set_vim_var_nr(VV_BEVAL_COL, (long)(col + 1)); set_vim_var_string(VV_BEVAL_TEXT, text, -1); vim_free(text); /* * Temporarily change the curbuf, so that we can determine whether * the buffer-local balloonexpr option was set insecurely. */ save_curbuf = curbuf; curbuf = wp->w_buffer; use_sandbox = was_set_insecurely((char_u *)"balloonexpr", *curbuf->b_p_bexpr == NUL ? 0 : OPT_LOCAL); curbuf = save_curbuf; if (use_sandbox) ++sandbox; ++textlock; vim_free(result); result = eval_to_string(bexpr, NULL, TRUE); /* Remove one trailing newline, it is added when the result was a * list and it's hardly every useful. If the user really wants a * trailing newline he can add two and one remains. */ if (result != NULL) { len = STRLEN(result); if (len > 0 && result[len - 1] == NL) result[len - 1] = NUL; } if (use_sandbox) --sandbox; --textlock; set_vim_var_string(VV_BEVAL_TEXT, NULL, -1); if (result != NULL && result[0] != NUL) { gui_mch_post_balloon(beval, result); recursive = FALSE; return; } } } #endif #ifdef FEAT_NETBEANS_INTG if (bevalServers & BEVAL_NETBEANS) netbeans_beval_cb(beval, state); #endif #ifdef FEAT_SUN_WORKSHOP if (bevalServers & BEVAL_WORKSHOP) workshop_beval_cb(beval, state); #endif recursive = FALSE; }
void workshop_beval_cb( BalloonEval *beval, int state) { win_T *wp; char_u *text; int type; linenr_T lnum; int col; int idx; char buf[MAXPATHLEN * 2]; static int serialNo = -1; if (!p_beval) return; if (get_beval_info(beval, FALSE, &wp, &lnum, &text, &col) == OK) { if (text && text[0]) { /* Send debugger request */ if (strlen((char *) text) > (MAXPATHLEN/2)) { /* * The user has probably selected the entire * buffer or something like that - don't attempt * to evaluate it */ return; } /* * WorkShop expects the col to be a character index, not * a column number. Compute the index from col. Also set * line to 0 because thats what dbx expects. */ idx = computeIndex(col, text, beval->ts); if (idx > 0) { lnum = 0; /* * If successful, it will respond with a balloon cmd. */ if (state & ControlMask) /* Evaluate *(expression) */ type = (int)GPLineEval_INDIRECT; else if (state & ShiftMask) /* Evaluate type(expression) */ type = (int)GPLineEval_TYPE; else /* Evaluate value(expression) */ type = (int)GPLineEval_EVALUATE; /* Send request to dbx */ vim_snprintf(buf, sizeof(buf), "toolVerb debug.balloonEval " "%s %ld,0 %d,0 %d,%d %ld %s\n", (char *)wp->w_buffer->b_ffname, (long)lnum, idx, type, serialNo++, (long)strlen((char *)text), (char *)text); balloonEval = beval; workshop_send_message(buf); } } } }