Windows Live ID Добро пожаловать на IT Community 
Регистрация

Стань частью ИТ-сообщества

Хочешь найти своих друзей, коллег или просто интересных людей со схожими интересами в ИТ-области? Не теряй время...

Присоединяйся к нам!

Max Zaets

Артур Жямайтис

Сергей Гаврилов


Все участники

PowerTab в Far… 

То чего я и боялся В PowerShellFar не реализованы методы для работы с raw консолью, - рисовать менюшку не получится… Просто использовать PowerTab для получения строк для завершения, без intellisense - потерять половину его прелести

Опубликовано 25 октября 2007 г. 8:29 в PowerShell и другие скрипты

Рейтинг0
Просмотров: 1022
Ответов: 10

Комментарий

Roman Kuzmin 29 октября 2007 17:00
Подумал про подстановку алиасов - пожалуй, не буду лишние условности наворачивать (пока). Дело в том, что PSF TabExpansion не сделает то, что ''бесит''. В твоем примере он не подставит scripts вместо sc, потому что чаще всего он предлагает все варианты, а не только что-то одно - файл или соммандлет, ... Поэтому в твоем примере тебе будет предложен выбор из set-content, scripts, ... Вполне нормально, вроде.
xaegr 29 октября 2007 14:57
WMI позарез нужен - без вариантов :) Еще с .net чтото не так... Но посмотрю потом, может не разобрался просто.

Понятно что не критика, конкуренция = путь к идеалу :)

Да, думаю такой подход к альясам был бы самое то.

С сменой менюшки ты не просёк фишку всёж, вместо того чтоб перезаписывать функу Out-ConsoleList, просто делаем Out-ЧтоугодноConsoleList и подставляем её в параметр: $PowerTabConfig.DefaultHandler = ‘Out-ЧтоугодноConsoleList’, а Default это именно дефолтный перебор табом пускай будет :) Но это мелочи уже :)
Roman Kuzmin 29 октября 2007 14:50
А, WMI... точно, забыл. Его-то я и не пользую почти, ну не нужен мне и все тут.

Но это не критика была по любому.

А вот с дополнением алиасов интересно - можно подумать. В фаре можно разрешить дополнение алиасов в редакторе, когда пишется скрипт, в котором, кстати, алиасы и не рекомендованы, а в ком.строке - запретить. Наверное, логично, подумаю.
xaegr 29 октября 2007 14:34
Роман, база в PowerTab используется в основном из за WMI, в PowerShellFar его пока не вижу (а надо очень :) )
От раскрывания альясов - dir -> get-childitem в свое время в PowerTab отказались, потому что бесит очень иногда :) Например при попытке сделать cd sc[tab] я ожидаю дополнения папки .\scripts\ а не set-content :)
Roman Kuzmin 29 октября 2007 13:57
I am sure that TabExpansion-.ps1 misses a lot of PowerTab power.
But something perhaps looks better, just a few facts (not criticism in any way):

PowerTab and console menu:
a) get[Tab] - only file paths
b) get-[Tab] - only cmdlets
c) get-*c[Tab] - only cmdlets and the menu does not allow to continue typing
d) Needs a database. Dynamically loaded assemblies are not supported, database should be updated
e) [datetime]::Now.h[Tab] - gets full member list
f) dir[Tab] - nothing
g) are script parameter names expanded?
h) [*sql*build[Tab] - nothing

TabExpansion-.ps1 and FAR list menu:
a) get[Tab] - functions, cmdlets, scripts in the system path, files in the current location
b) get-[Tab] - the same as above
c) get-*c[Tab] - the same and no problems to continue typing further when the menu is shown. Also you can use * and ? during typing (makes job faster if a list is really long and prefixes are mostly similar and too long to type).
d) Does not need a database and still works pretty fast. Dynamically loaded assemblies are supported (but, yes, only currently loaded and data cache may need update).
e) [datetime]::Now.h[Tab] - [datetime]::Now.Hour
f) dir[Tab] - Get-ChildItem
g) script (or even its alias) parameter names are expanded if a script is in the path and 'param' and parameters are one per line (as I usually do, so this assumption works for me).
h) [*sql*build[Tab] - requested matches
Roman Kuzmin 29 октября 2007 13:56
New UI control (list menu) is implemented in Far.NET 3.3.30 and used for TabExpansion in PowerShellFar 1.1.30.

Features:
*) Incremental filter on typing (including wildcard * and ?)
*) Some settings exposed as $Psf.Settings.Intelli*
(need more features/settings? - ask)

----------

## How to load and use PowerTab TabExpansion in PowerShellFar:
& ''...\Init-TabExpansion.ps1'' -ConfigurationLocation ...
$PowerTabConfig.DefaultHandler = 'Default'

## How to get back TabExpansion from TabExpansion-.ps1:
function global:TabExpansion ($line, $lastWord) { TabExpansion- $line $lastWord }

(I think it should be OK to switch them back and forth by these commands)

----------

If needed, advanced way to load PowerTab:

& ''...\Init-TabExpansion.ps1'' -ConfigurationLocation ...
function global:Out-ConsoleList
{
param ($lastWord)
$m = $Far.CreateListMenu()
$Psf.Settings.Intelli($m)
$m.X = [console]::CursorLeft
$m.Y = [console]::CursorTop
$m.IncrementalFilter = $lastWord
$m.Incremental = 'Prefix'
$input | .{process{
[void]$m.Items.Add($_)
}}
switch($m.Items.Count) {
0 { return }
1 { return $m.Items[0].Text }
}
if ($m.Show()) {
$m.Items[$m.Selected].Text
}
}
Roman Kuzmin 26 октября 2007 13:34
MoW, Xaegr,

Do not worry, work is in progress and PowerTab will work in FAR in a few days as requested. Actually it works already if $PowerTabConfig.DefaultHandler = ‘Default’. There is a request though from Xaegr to improve behaviour of the menu. It is relatively easy, I even guess my task is easier than it was for you, FAR UI API has some power.

I still think that there will be no need in custom handler and changes of Invoke-TabItemSelector (that would be kind of a hack in fact).
xaegr 26 октября 2007 12:39
@ MoW:
This is exactly what Roman is doing now - tabitemselector for use in far (the one that i named FarList :) but this is up to Roman to choose the name). ATM PowerShellFar uses classic Far menu, which not satisfies me because it assign letter shortcut to every item in menu, and it is impossible to type text in it to narrow the list. http://xaegr.wordpress.com/files/2007/10/currentfarmenu.png Yellow letters is automatically generated shortcuts. This is causes inpredictable results when i try to use it :)
mow 26 октября 2007 12:28
Xaegr, Roman

It is hard to follow the discussion using google translate, and I only used FAR till my trail expired to look at Roman's work, so do not know exactly how the Farlist works.

but the addition of another handler is very simple.

In the TabExpansionLib.ps1 the helperfunction Invoke-TabItemSelector is defined where you can add other handlers, I still need to add a list to configuration, but you can basicly call any function or cmdlet to handle the output, PowerTab will provide the array with results and the $lastword value to it.

you can find a complete description of this here.

http://thepowershellguy.com/blogs/posh/archive/2007/04/18/powershell-tabextension-part-6-customizing-powertab-0-9.aspx

@ Roman : also to you, Keep up the good work !

Greetings /\/\o\/\/
xaegr 25 октября 2007 19:49
Если я правильно понимаю то надо сделать $PowerTabConfig.DefaultHandler = ‘Out-FarList’ - этот параметр как раз и делался для возможности использовать иные функции выбора :) А default оставить для действительно дефолтного варианта.
Анонимные комментарии не разрешены
RSS

Блог

Календарь

«Октябрь 2007 г.»
ПнВтСрЧтПтСбВс
24252627282930
1234567
891011121314
15161718192021
22232425262728
2930311234

Категории

Синдикация

Виртуальные сообщества

Сообщества сайтов (тэгами)