Giter VIP home page Giter VIP logo

textredux's Introduction

Textredux is a module for the Textadept editor that offers a set of text based replacement interfaces for core Textadept functionality.

Textredux' main branch usually follows Textadept's nightly development and started tracking the changes in Textadept 12 alpha.

The API docs are generated with ldoc:

cd docs
ldoc .

The Textredux module is released under the MIT license. Please visit the homepage for more information.

textredux's People

Contributors

brandonirizarry avatar chadvoegele avatar finalpatch avatar fsx avatar hackerpilot avatar ioplker avatar jugglerchris avatar loomer avatar markus-oberhumer avatar nilnor avatar rgieseke avatar snoopy avatar triplejam avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

textredux's Issues

Support for find_in_files?

Is it possible to have TR take over the find_in_files dialog?

Unrelated but how do you make the TR version of snapopen accept the current working dir as starting point?

Textredux changes line number margins

Hi,

I'm finding that when opening a textredux buffer, the line number margins on other buffers are being changed. I think the culprit is set_margin_styles() in core/buffer.lua.

Is there a reason it changes the margin for non-textredux buffers? In my case (curses) it seems to save the margin width from very early on (before my own INITIALIZED setup code has run), and keeps setting buffers to that width. Everything seems to work fine if I comment out the second half of the function.

Chris

Textadept 10.2 renamed spawn() to os.spawn() and broke textredux.ctags

https://foicica.com/textadept/CHANGELOG.html

"Renamed spawn() to os.spawn()."

I changed ctags.lua to user os.spawn and it's working.

Another question....
I'm using OSX and installed ctags with: brew install ctags
I have a key binded to textredux.ctags.goto_symbol and it's works nicely IF I launch textadpet in the terminal with "ta" or with /Applications/Textadept.app/Contents/MacOS/textadept_osx but don't work (no message presented) when I launch clicking in the Textadept.app icon.
Any clue about this ?

Thanks in advance!

Pedro Costa

Wrapped lists always return first element

I am calling a wrapped list in TR with textredux.core.filteredlist.wrap(m('Buffer/Select Lexer...')) (lexer is used in this example but it's the same with recent files etc.).
Once the select lexer list is open the second entry is selected ("ada"). The lexer (indicated on the bottom right) changes to the first selection of the list ("actionscript").

Using hijack() and then calling the normal TA dialog will not show the TR list but the TA one.

Here is a video to showcase the problem: lexer.webm

attempt to index upvalue 'ta_snapopen' (a nil value)

Hello,

I have the following error after adding textredux in my modules folder (using git) and by using the given code in my init.lua:

_M.textredux = require 'textredux'
keys.co = _M.textredux.fs.open_file

There is no error at stratup bu if I type C-o, I have the following error:

~/.textadept/modules/textredux/fs.lua:420: attempt to index upvalue 'ta_snapopen' (a nil value)

I'm using the latest version of Textadept (6.5).

Maybe some things changed in this version...

Limit open to one instance

Currently it's possible to "stack" open dialogs on top of each other. Would it be a good idea to only allow one open dialog at a time?
Do you happen to have a clever idea to implement this?

Syntax highlighting each individual line of code in one column of a core list?

Hi

I have modified (https://github.com/loomer/.textadept/tree/master/modules/tr_fif) to create an unsorted list of all lines from all open buffers - and then filter exact matches (its near the end of the attached file as 'func.find' - please note depends upon win32 findstr.exe).

functions_lua.txt

Q1. Is there any way to apply syntax highlighting to each individual line of code found, in this case column 3, depending upon the lexer for the specific file type?

Please note I am using Textadept-curses.exe and therefore just the TERM theme.

Q2. Is there an easy keybind to refresh the buffer containing the list?

Kind Regards Gavin Holt

PS I know this is listing from the saved disk version of the files. Using the live buffer versions is a project for my next empty weekend!

Show file size in file browser

Hi! Is it possible to show file sizes in file browser aligned to the right of file names? In human-readable format like so:

~/.textadept/modules/textredux/core : 8/8 items

../
buffer.lua                                                                32Kb
filteredlist.lua                                                         124Mb 

Error with latest Textadept version

Can you confirm this error on the latest version of Textadept?
textadept_nightly_2022-10-10/init.lua:283: bad argument #2 to 'connect' (function expected, got nil)
Happens with the latest alpha as well.

init.lua used for testing:

local textredux = require('textredux')
textredux.hijack()

How can I tell a textredux buffer from other textadept buffers?

Hi,

I tweak various settings in new buffers based on BUFFER_NEW etc. events. At least one of those things (buffer.wrap_mode) I'd prefer not to do on textredux list buffers. Is there a way I can reliably recognize them from the event handler so as to avoid changing those settings?

Regards,

Chris

Open multiple files at once

Is there such functionality and I simply missed it?
If not then it would be nice to have this feature. For example you open (or snapopen) to a certain directory and then filter the files you want to open (i.e. by extension) then open all of them.
What do you think about this?

Line number margin does not get reset

When switching to a TR buffer the line number margin gets removed. Closing the buffer resets the line number margin.
In some cases the line number margin does not get reset. I haven't been able to ascertain why and when. This will only happen in exactly one normal buffer.

Removing the following lines from bufer.lua will "fix" the problem by never removing the line number margin in TR buffers.

target.margin_width_n[1] = not CURSES and target.margin_width_n[0] + 4 or 1
target.margin_width_n[0] = 0

Obviously there must be a better solution but I don't know what causes this. Maybe something that was overlooked with the switch from 0 to 1 based counting? Seems to be a fairly recent bug anyways.

Can usually be reproduced by selecting a buffer through the buffer list and then cycling through your buffers until you find one without line numbers.

Does textredux work in textadept-curses?

How does one actually choose a file or buffer? Is it supposed to be enter/return? For some reason, I can't choose anything from the lists (filtering works great). I'm using the curses version of textadept. I've tried a couple versions of textadept (hg version, 6.5, 6.2). Thanks!

reduxstyle missing property?

The documentation for reduxstyle states the following:
reduxstyle.list_match_highlight.fore = reduxstyle.class.fore
However during my tests neither of these had the fore property.

I was trying to have TR automatically use the same colors for the file dialogs as in the buffer list. The colors for the buffer list are set in list.lua. Hoever the colors for the file dialogs are set in fs.lua. The problem here is that they don't work. The file dialogs will not use their assigned colors but instead use the default (text) color.
Assigning the colors manually via reduxstyle.list_match_highlight.fore = #123456 does work because you are creating the necessary property.

Is this working as intended or am I maybe missing something?

Marker margin width based on line number margin width

The width of margin 2, the marker margin is based upon the width of margin 1, the line number margin. Which doesn't make much sense and results in it being wider than needed.

target.margin_width_n[2] = not CURSES and target.margin_width_n[1] + 4 or 1

I think the line above should be

target.margin_width_n[2] = not CURSES and 4 or 1 

That's the default in TA 11 and TA 12 see

https://github.com/orbitalquark/textadept/blob/2dc0609b81018fa52f75084ec6c22b59c5771e6b/init.lua#L171

Thanks.

preserve files order in search

There files (sorted) :

$ ls -1 core
buffer.lua
filteredlist.lua
indicator.lua
init.lua
list.lua
style.lua
ui.lua

when I type lua, I'd like to have all that files, keeping the original.

With the proposed patch:

diff --git a/util/matcher.lua b/util/matcher.lua
index ddb2fbf..ebcd36b 100644
--- a/util/matcher.lua
+++ b/util/matcher.lua
@@ -161,6 +161,17 @@ end
 -- @return A table of matcher functions, each taking a line as parameter and
 -- returning a score (or nil for no match).
 function M:_matchers_for_search(search_string)
+  print(search_string);
+  return {
+    function(line)
+      local start_pos, end_pos = string.find(line, search_string, 1, true)
+      if start_pos then
+        return 1, start_pos, end_pos, search_string
+      end
+    end
+  }
+
+--[[
   local fuzzy = self.search_fuzzy
   local fuzzy_penalty = self.fuzzy_score_penalty
   local groups = {}
@@ -184,6 +195,7 @@ function M:_matchers_for_search(search_string)
     end
   end
   return matchers
+]]
 end

I can achive the same.

The default behaviour is a bit crazy: it sorts files by filename length.

ui.lua
list.lua
init.lua
style.lua
buffer.lua
indicator.lua
filteredlist.lua

it's very confusing. I'm also not sure how the current patch can be integrated...

feature request : integrate fzf into textredux

Hi,

you might have heard of fzf. it is an actively developed , general purpose fuzzy finder.

the scoring / matching algorithm is excellent and fast , it would be excellent if this tool could be integrated into textredux as sorter / matcher for results which will do all the heavy lifting and the editor takes care of populating the list and displaying it as it comes from fzf . just like the git ls-files example.

this is where this tool gets integrated into vim fzf.vim, and the basic idea is that everything is done by the tool and vim just display those results ( with some fine grain control over some fzf settings that could be done over at the editor side if needed )

I am still exploring TextAdept myself , and integrating this into TA/Textredux would be a killer feature, plus it lessen the processing done on the editor / lua side , especially for large repos.

attempt to call field 'new' (a nil value)

I just installed Textadept 6.5, and added this to my init.lua:

_M.textredux = require 'textredux'
keys.co = _M.textredux.fs.open_file

When I press Ctrl+O, I get this message:

/home/amar/.textadept/modules/textredux/core/buffer.lua:405: attempt to call field 'new' (a nil value)

buffer reloading and cursor positioning working as intended?

Got two questions on intended behavior.

First, when switching between say the buffer list and some other buffer the current cursor position inside the buffer list will be reset (i.e. to the top). As far as I can tell this happens for all reduxlists.
Is this intentional? Consider a very long list and the user switching and upon returning to the list the cursor always resets to the top which can be annoying (somewhat related is that going to the end of the buffer in a reduxlist only goes to the end of the currently visible page).

The other point concerns buffer reloading.
When you change a file outside of TA which is open in TA and then select another file (not the one that was changed!) you will get a popup asking if you want to reload the changed file.
Normal TA only asks for that if the file was actually selected but in TR the confirmation always comes up when switching files.
Intended or not?

Select a directory itself

Would be useful to be able to select and return a directory itself. Like select_file but to make the selection a separate keybinding would be need to be used since enter is already for navigating. Perhaps Ctrl+d. Should be able to pass a function that receives the path. I'm not sure if all non-directories should be filtered, but it should be an option.

feature request: open in split

Would it be possible to have an option for the the functions fs.open_file and textredux.buffer_list.show to:

  • if we only have 1 pane: split the pane and show the textredux buffer in the other pane (putting focus in there).
  • if we already have a split pane: replace our sibling pane with textredux buffer.

while in textredux buffer:

  • when selecting a file or buffer: replace the current textredux buffer with selection (so we are left with 2 panes minimum { view.split, view, false }).
  • if we hit a "1" while on a file or buffer: make the current selection take up the entire window. (left with 1 pane: {ui.goto_view, 1, true})

This is similar to how emacs buffer-menu-other-window works, and it is quite handy.

Textredux buffers update slowly

When I switch to a textredux buffer, I see the remains of the previous buffer for something like a second, then the buffer clears up. The same thing happens when I switch to a directory with a few items - I can see the previous content for a little bit. I am not sure if this is a problem with Textadept or textredux, however the problem only happens when switching to textredux buffers or changing their content (like filtering).

Here is an animation of what it looks like. The animation shows the use with tabs from the latest nightly, but the problem existed even before the update.

animation

Cursor jumps into search area with TA 11.2b2

Using TR with TA 11.2 beta 2 the cursor jumps into the user search area when typing text in lists.
I thought the problem might lie with list:_refresh() but changes there do nothing to stop this behavior. Can you check this and see if it is the same for you?

No files shown (Ctrl+O)

Textredux latest git version
Textadept latest nightly (also 7.0 and 7.1)
Windows 8.1 64-bit

Textredux doesn't show any files on Ctrl-O. Traversing the file system with backspace does work but shows always 0/0 items:

\C:\Users\thorsten - Textadept (\C:\Users\thorsten)
1 \C:\Users\thorsten : 0/0 items
2
3

Various improvements

I'd like to get your feedback on various improvements that I've made and if you think any of them are viable enough to get merged upstream.

First, could you take another look at the save_as implementation? It should integrate with TR pretty seamlessly and is a great addition in day-to-day workflow IMO.

I also added the ability to open multiple files at once which was something that is missing from TR unless I overlooked it. This however depends on the save_as functionality hence it would need to get merged first.

Also made a change so that there is a confirmation dialog before a file is created via the open dialog. Before this change the open dialog would silently create files if you made a typo while trying to open a file.

Lastly just as a convenience function I added a hotkey for going up one directory level even if there is text in the entry field (which prevents backspace from going up one directory level).

I really enjoy TR but unfortunately development is somewhat stale so I tried to add some features that I'd like to see.
Let me know what you think.

Filters when using quick_open via toggle

It seems lfs.default_filter does not apply when using quick_open via the toggle (default: ctrl+s in the open dialog).
I tried to fix this here: https://github.com/loomer/textredux/commit/b200c1e880a6a1a344ea243a97d0331c2b832f3f
The code is rather brittle though as it was originally just designed to make quick_open work again after it was broken by some TA updates. It makes some assumptions about the structure of filter entries but does work.
The existing filter system in TR seems quite messy and overhauling all of it would probably be a fairly big task.

What is your take on this?

small file sorting issue.

Hello!

Thanks for nice plugin!

I have an small enhancement report. When sorting files, the file, with the shortest shared filename should go first, instead of last. I.e.

# ls -1 ..
bom                                 # this one goes first
bom-feed
bom-market
bom-platform
bom-postgres
bom-rpc
bom-test
bom-utility
bom-web
bom-websocket-api

In the textredux it shows the folders in the order:

bom-feed
bom-market
bom-platform
bom-postgres
bom-rpc
bom-test
bom-utility
bom-web
bom-websocket-api
bom                                            # goes last, not nice

Support for textredux in Textadept nightly's command_entry-buffer

Hi,

Now that (in the nightlies) the command_entry is a nearly full-fledged Scintilla buffer (http://foicica.com/lists/code/201410/2113.html), it'd be nice to be able to use Textredux with it.

I've got a quick and dirty proof of concept (calling a new "attach to command entry" method as an alternative to show, and fixing assumptions on _G.buffer as needed). I'll try to send it in case it's of any use.

Is this something that you would add?

Chris

No data displayed because buffer.lines_on_screen is zero

I'm not sure what the underlying problem is (initialization order?), but please try this small init.lua:

local textredux = require('textredux')

local function replace_untitled_buffer_with_open_file()
    -- see textadept/core/file_io.lua 'Closes the initial "Untitled" buffer.'
    if #_BUFFERS == 1 then
        local buf = _BUFFERS[1]
        if not (buf.filename or buf._type or buf.modify or buf._textredux) then
            local dir = lfs.currentdir()
            textredux.fs.open_file(dir)
            view:goto_buffer(buf)
            io.close_buffer()
        end
    end
end

events.connect(events.INITIALIZED,    replace_untitled_buffer_with_open_file)
events.connect(events.BUFFER_DELETED, replace_untitled_buffer_with_open_file)

I'm currently using this diff as a workaround.

diff --git a/core/list.lua b/core/list.lua
index 798a114..6dd0d4a 100644
--- a/core/list.lua
+++ b/core/list.lua
@@ -313,6 +313,9 @@ function list:_refresh()
   -- Items.
   data.items_start_line = buffer:line_from_position(buffer.current_pos)
   local nr_items = buffer.lines_on_screen - data.items_start_line - 1
+  if buffer.lines_on_screen == 0 then -- mfx FIXME: why can this be 0 ????
+    nr_items = 9999
+  end
   self:_add_items(data.matching_items, 1, nr_items)
   buffer:goto_line(data.items_start_line - 1)
   buffer:home()

Shortcut to go to home folder

Attached is a simple patch, which adds a tilde '~' command to jump to home directory. Especially useful when you are in a deep subdirectory and need to open a file close to $HOME.

diff --git a/fs.lua b/fs.lua
index d39c771..24602b3 100644
--- a/fs.lua
+++ b/fs.lua
@@ -299,6 +299,11 @@ function on_keypress(list, key, code, shift, ctl, alt, meta)
       chdir(list, parent)
       return true
     end
+  elseif key == '~' then
+    if user_home then
+      chdir(list, user_home)
+      return true
+    end
   end
 end

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.