This commit is contained in:
Jorge Morante 2023-05-23 14:46:14 +02:00
parent e98baf6ba6
commit 659595f953
9 changed files with 33 additions and 78 deletions

View File

@ -1,6 +1,7 @@
# frozen_string_literal: true
MRUBY_REV = '1c765dc37a80bf681bbab271b0ba90711d935be9'
TARGET="x86_64-macos-none"
MRUBY_REV= 'c32f7915fb567c73b78db10ebc13c38a617a75aa'
MRUBY_ROOT = 'build/mruby'
RUBY_FILES = [
'lib/tmux.rb',
@ -11,9 +12,12 @@ RUBY_FILES = [
'lib/fingers/dirs.rb',
'lib/fingers/config.rb',
'lib/fingers/commands.rb',
'lib/fingers/input_socket.rb',
'lib/fingers/action_runner.rb',
'lib/fingers/commands/base.rb',
'lib/fingers/commands/show_version.rb',
'lib/fingers/commands/load_config.rb',
'lib/fingers/commands/send_input.rb',
'lib/fingers/commands/start.rb',
'lib/fingers/cli.rb',
@ -35,13 +39,13 @@ end
desc 'Compile mruby'
task build_mruby: [MRUBY_ROOT] do
Dir.chdir('build/mruby') do
sh 'MRUBY_CONFIG=../../build_config.rb rake'
sh "CC=\"zig cc -target #{TARGET}\" MRUBY_CONFIG=../../build_config.rb rake"
end
end
desc 'Compile tmux-fingers'
task compile: ['build_mruby'] do
sh "#{MRUBY_ROOT}/bin/mrbc -B main_ruby -o build/bytecode.c #{RUBY_FILES.join(' ')}"
sh "gcc -std=c99 -I#{MRUBY_ROOT}/include main.c -o build/tmux-fingers #{MRUBY_ROOT}/build/host/lib/libmruby.a -lm"
sh "zig cc -target #{TARGET} -I#{MRUBY_ROOT}/include main.c -o build/tmux-fingers #{MRUBY_ROOT}/build/host/lib/libmruby.a -lm"
sh 'echo tmux-fingers build complete'
end

View File

@ -1,10 +0,0 @@
#!/usr/bin/env ruby
# encoding: UTF-8
GC.disable
$LOAD_PATH.unshift File.expand_path('../lib', __dir__)
require 'fingers'
Fingers::CLI.new(ARGV, File.expand_path(__FILE__)).run

View File

@ -1,47 +0,0 @@
---
mruby:
version: 3.2.0
release_no: 30200
git_commit: 1c765dc37a80bf681bbab271b0ba90711d935be9
builds:
host:
https://github.com/iij/mruby-env.git:
url: https://github.com/iij/mruby-env.git
branch: HEAD
commit: 056ae324451ef16a50c7887e117f0ea30921b71b
version: 0.0.0
https://github.com/mttech/mruby-getopts.git:
url: https://github.com/mttech/mruby-getopts.git
branch: HEAD
commit: 32878292c1162a911b39e1e0810a28ab2cb83f6a
version: 0.0.0
https://github.com/ksss/mruby-singleton.git:
url: https://github.com/ksss/mruby-singleton.git
branch: HEAD
commit: 73dd4bae1a47d82e49b8f85bf27f49ec4462052e
version: 0.0.0
https://github.com/iij/mruby-tempfile.git:
url: https://github.com/iij/mruby-tempfile.git
branch: HEAD
commit: 9b883438547020dae328e34c8a2fe736171cd0ab
version: 0.0.0
https://github.com/mattn/mruby-onig-regexp.git:
url: https://github.com/mattn/mruby-onig-regexp.git
branch: HEAD
commit: 074325207f9181ad242ffb8de34072607164f57f
version: 0.0.0
https://github.com/katzer/mruby-logger.git:
url: https://github.com/katzer/mruby-logger.git
branch: HEAD
commit: f794ef6f6ceff1794d02a6d9cfc1d281bdfcad21
version: 0.0.0
https://github.com/iij/mruby-iijson.git:
url: https://github.com/iij/mruby-iijson.git
branch: HEAD
commit: c5e730c30090d3cddae258f57ab9508edb3e9fce
version: 0.0.0
https://github.com/mattn/mruby-json.git:
url: https://github.com/mattn/mruby-json.git
branch: HEAD
commit: f99d9428025469f2400f93c53b185f65f963e507
version: 0.0.0

View File

@ -7,14 +7,15 @@ class Fingers::ActionRunner
end
def run
Fingers.logger.info "hey!"
Tmux.instance.set_buffer(match)
return unless final_shell_command
#return unless final_shell_command
IO.popen(action_env, final_shell_command, "r+") do |io|
io.puts match
io.close_write
end
#IO.popen(action_env, final_shell_command, "r+") do |io|
#io.puts match
#io.close_write
#end
end
private
@ -107,6 +108,7 @@ class Fingers::ActionRunner
end
def program_exists?(program)
system("which #{program}")
# TODO REMOVE THIS HEHEHE
return program == "xclip"
end
end

View File

@ -41,8 +41,7 @@ class Fingers::Commands::Start < Fingers::Commands::Base
show_hints
sleep 2
#handle_input
handle_input
teardown
end
@ -124,14 +123,16 @@ class Fingers::Commands::Start < Fingers::Commands::Base
tmux.disable_prefix
tmux.set_key_table "fingers"
Fingers.benchmark_stamp("ready-for-input:end")
Fingers.trace_for_tests_do_not_remove_or_the_whole_fabric_of_reality_will_tear_apart_with_unforeseen_consequences("fingers-ready")
#Fingers.benchmark_stamp("ready-for-input:end")
#Fingers.trace_for_tests_do_not_remove_or_the_whole_fabric_of_reality_will_tear_apart_with_unforeseen_consequences("fingers-ready")
return if Fingers.config.trace_perf == "1"
#return if Fingers.config.trace_perf == "1"
input_socket.on_input do |input|
view.process_input(input)
Fingers.logger.info "state: #{state}"
break if state.exiting
end
end

View File

@ -86,6 +86,8 @@ class ::Fingers::Hinter
capture_offset = nil
#end
# Converting match data to string
captured_text = captured_text.to_s
if hints_by_text.has_key?(captured_text)
hint = hints_by_text[captured_text]

View File

@ -90,7 +90,9 @@ class Fingers::View
state.input = ""
render
else
state.result = match
Fingers.logger.info "Match: #{match}"
Fingers.logger.info "Match: #{match.to_s}"
state.result = match.to_s
request_exit!
end
end

View File

@ -5,7 +5,6 @@ module Kernel
end
end
puts "hello"
begin
absolute_fingers_path = "/home/morantron/hacking/tmux-fingers/build/tmux-fingers"
ARGV.shift
@ -15,4 +14,3 @@ rescue StandardError => e
puts e
puts e.backtrace
end
puts "goodbye"

View File

@ -146,8 +146,10 @@ class Tmux
end
def set_key_table(table)
system(tmux, "set-window-option", "key-table", table)
system(tmux, "switch-client", "-T", table)
`#{tmux} set-window-option key-table #{table}`
`#{tmux} switch-client -T #{table}`
#system(tmux, "set-window-option", "key-table", table)
#system(tmux, "switch-client", "-T", table)
end
def disable_prefix
@ -156,7 +158,8 @@ class Tmux
end
def set_global_option(name, value)
system(tmux, "set-option", "-g", name, value)
`#{tmux} set-option -g #{name} #{value}`
#system(tmux, "set-option", "-g", name, value)
end
def get_global_option(name)
@ -166,7 +169,7 @@ class Tmux
def set_buffer(value)
return unless value
system(tmux, "set-buffer", value)
`#{tmux} set-buffer #{value}`
end
def select_pane(id)