Skip to content

Commit

Permalink
[New feature]: Make mode intro
Browse files Browse the repository at this point in the history
  • Loading branch information
fmount committed May 28, 2017
1 parent 459451a commit a96ed3c
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 17 deletions.
9 changes: 8 additions & 1 deletion bin/send_command
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ send_cmd() {
# if the method is direct, copy the command to the quickfix designed buffer,
# if instead method is queue, we enqueue the command to the designed queue

input_type="$1" #direct or queue
input_type="$1" #direct or queue or make

buffer="$(get_tmux_option "${QUICKFIX_BUFFER}" "local")"
case $input_type in
Expand Down Expand Up @@ -47,6 +47,13 @@ send_cmd() {
fi
tmux display-message "Command sent to quickfix"
;;
"make")
# Get the command from the current buffer and set it on metadata
#set_buffer_data "$(get_current_buffer_cmd)" "$buffer"
set_tmux_option "${QUICKFIX_MAKE}" "$(get_current_buffer_cmd)" "$(get_current_session)" "local"
#set_tmux_option "${QUICKFIX_PROJECT}" "$(pwd)" "$(get_current_session)" "local"
tmux display-message "Make command ready"
;;

*)
tmux display-message "tmux-quickfix unsupported input method"
Expand Down
13 changes: 9 additions & 4 deletions scripts/engine.sh
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,10 @@ quickfix_join_pane() {
}


quickfix_get_current_path() {
tmux display-message -p "#{pane_current_path}"
}

quickfix_position() {
get_tmux_option "${QUICKFIX_POSITION}" "global"
}
Expand Down Expand Up @@ -280,10 +284,11 @@ exec_cmd() {
;;

"make")

if [ -n "${QUICKFIX_PROJECT}" ] && [ -n "${QUICKFIX_MAKE_CMD}" ]; then
tmux send-keys -t "$pane_id" "cd ${QUICKFIX_PROJECT}" Enter;
tmux send-keys -t "$pane_id" "${QUICKFIX_MAKE_CMD}" Enter;
prj="$(get_tmux_option "${QUICKFIX_PROJECT}" "local")"
mk="$(get_tmux_option "${QUICKFIX_MAKE}" "local")"

if [ -n "${prj}" ] && [ -n "${mk}" ]; then
tmux send-keys -t "$pane_id" "${mk}" Enter;
else
tmux display-message "Undefined project:make_cmd parameters"
fi
Expand Down
22 changes: 15 additions & 7 deletions scripts/quickfix.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ source "$CURRENT_DIR/engine.sh"
source "$CURRENT_DIR/variables.sh"
source "$CURRENT_DIR/session.sh"

PANE_CURRENT_PATH="$(pwd)"

#PANE_CURRENT_PATH="$(pwd)"


quickfix_exists() {
Expand Down Expand Up @@ -87,15 +88,16 @@ split_qfix() {

[ ! -n "$qfix_size" ] && qfix_size="${QUICKFIX_DEFAULT_PERC_SIZE}"

local mode="$2" # direct / queue

local mode="$2" # direct / queue / make
#local cmd="$3"

case $1 in
"bottom")
info="$(tmux new-window -c "$PANE_CURRENT_PATH" -n quickfix -P -F "#{window_index}:#{window_id}:#{pane_id}")"
pane_id=$(echo "$info" | cut -d ':' -f3)
tmux select-window -l
if [ "$mode" == "direct" ]; then
if [[ "$mode" == "direct" || "$mode" == "make" ]]; then
tmux join-pane -v -l "$qfix_size" -s "$pane_id"
exec_cmd "" "$pane_id" "$mode"
else
Expand Down Expand Up @@ -164,7 +166,7 @@ quickfix_is_fore() {

send_back() {
win_index=$(get_qfix_id_by 'default')
local mode="$1" # direct / queue
local mode="$1" # direct / queue / make

tmux break-pane -d -t "${win_index}" -s "$(get_qfix_id_by 'pane_id')"

Expand All @@ -175,7 +177,7 @@ send_back() {
quick_meta="$(get_window_info "${win_index}")"
update_quickfix_meta "$quick_meta"

if [ ! "$(check_process)" ] && [ "$mode" == "direct" ]; then
if [ ! "$(check_process)" ] && [[ "$mode" == "direct" || "$mode" == "make" ]]; then
kill_quickfix "pane"
#else
# echo "Cannot kill"
Expand Down Expand Up @@ -236,7 +238,13 @@ bootstrap() {
set_tmux_option "${QUICKFIX_COMMAND_QUEUE}" "${QUEUE_HOME}/${QUICKFIX_CMD_QUEUE_BASENAME}.$session" "$session" "local"
;;
"make")
tmux display-message "MAKE MODE COMING SOON ..."
prj="$(get_tmux_option "${QUICKFIX_PROJECT}" "local")"

if [ -z "${prj}" ]; then
QUICKFIX_TARGET_PROJECT="$(quickfix_get_current_path)"
set_tmux_option "${QUICKFIX_PROJECT}" "${QUICKFIX_TARGET_PROJECT}" "$session" "local"
fi
PANE_CURRENT_PATH="$(get_tmux_option "${QUICKFIX_PROJECT}" "local")"
;;
esac
}
Expand Down
12 changes: 7 additions & 5 deletions scripts/variables.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ QUICKFIX_COMMAND_INPUT="@quickfix-cmd-input" # Global parameter
QUICKFIX_BUFFER="@quickfix-buffer"
QUICKFIX_BUFFER_RESERVED="@quickfix-buffer-reserved"

QUICKFIX_PROJECT="@quickfix-project"
QUICKFIX_MAKE="@quickfix-make"

# This is the variable containing all the quickfix informations
# with the form [@winID]:[winIndex]:[%paneID]
REGISTERED_QUICKFIX_PREFIX="@quickfix-id"
Expand All @@ -24,15 +27,14 @@ QUICKFIX_DEFAULT_SENDKEY="a"
QUICKFIX_DEFAULT_POSITION="bottom"
QUICKFIX_DEFAULT_WIN_INDEX=42
QUICKFIX_CMD_QUEUE_BASENAME="queue.cmd"
QUICKFIX_DEFAULT_CMD_INPUT="direct" # Allowed values: [direct|queue|make]
#QUICKFIX_DEFAULT_CMD_INPUT="direct" # Allowed values: [direct|queue|make]
#QUICKFIX_DEFAULT_CMD_INPUT="queue" # Allowed values: [direct|queue|make]
#QUICKFIX_DEFAULT_CMD_INPUT="make" # Allowed values: [direct|queue|make]
QUICKFIX_DEFAULT_CMD_INPUT="make" # Allowed values: [direct|queue|make]
QUICKFIX_DEFAULT_BUFFER_RESERVED="no" # Allowed values: [yes|no]
QUICKFIX_DEFAULT_BUFFER_NAME="tmbuf"
QUICKFIX_DEFAULT_MAKE_MODE="yes" # Allowed values: [yes|no]

QUICKFIX_PROJECT=""
QUICKFIX_MAKE_CMD=""
QUICKFIX_TARGET_PROJECT=""
QUICKFIX_TARGET_MAKE=""

QUICKFIX_DEBUG_LOG="quickfix-plugin.log"
TMUX_VERSION_ALLOWED="2.2"

0 comments on commit a96ed3c

Please sign in to comment.