XBrackets plugin

Discuss and announce AkelPad plugins
  • Author
  • Message
DV
Offline
Posts: 1292
Joined: Thu Nov 16, 2006 11:53 am
Location: Kyiv, Ukraine

Post by DV »

AZJIO wrote:

Code: Select all

res = AkelPad.Call("XBrackets::SelToMatchingBracket", 1, lpBuffer);
что здесь делает единица?
Единица - это часть API.
Если единица не указана, вызов SelToMatchingBracket выделяет до парной скобки (действие по умолчанию).
Если единица указана, вызов SelToMatchingBracket заполняет буфер, переданный вторым параметром (после единицы). Вызвать SelToMatchingBracket с дополнительными параметрами можно либо из скрипта, либо из другого плагина.

DV
Offline
Posts: 1292
Joined: Thu Nov 16, 2006 11:53 am
Location: Kyiv, Ukraine

Post by DV »

Новая версия плагина находится в разработке!
Добавляется возможность расширить выделение скобок до ближайших скобок вокруг них.
Пример, как это работает:
https://gifyu.com/image/tzf0

DV
Offline
Posts: 1292
Joined: Thu Nov 16, 2006 11:53 am
Location: Kyiv, Ukraine

Post by DV »

XBrackets v.7.7
+ добавлено: nearestbr.selto_flags = 2 (расширяет выделение ближайших скобок)
Влияет на работу функции XBrackets::SelToMatchingBracket, позволяя ей захватывать внешние скобки вокруг уже выделенных.

Примечание: если вы уже используете XBrackets, установите значение nearestbr.selto_flags = 2 вручную в файле "XBrackets.ini" или в Реестре под "HKEY_CURRENT_USER\SOFTWARE\Akelsoft\AkelPad\Plugs\XBrackets".

Offline
Posts: 1873
Joined: Mon Aug 06, 2007 1:07 pm
Contact:

Post by Infocatcher »

DV wrote:XBrackets v.7.7
+ добавлено: nearestbr.selto_flags = 2 (расширяет выделение ближайших скобок)
Влияет на работу функции XBrackets::SelToMatchingBracket, позволяя ей захватывать внешние скобки вокруг уже выделенных.
О! Удобства, спасибо!

Я правильно понимаю, то при включенном Coder'е будут учтены результаты его работы?
Например, на вот таком сферическом (и специально поломанном) коде подсветка парных скобок работает, но при этом SelToNearestBrackets эти {} корректно игнорирует:
Image

Code: Select all

function convertSource(file, text) {
	//…
	text = text
		.replace(/\r\n?|\n\r?/g, "\r\n")
		.replace(/[ \t]+([\n{\r]|$)/g, "$1}");
	//…
}

И, соответственно, правильно ли я понимаю, что при использовании SelToNearestBrackets можно ориентироваться на постветку Coder'а (то есть если поствека/фолдинг не поломались, то и выделит все как надо)?

DV
Offline
Posts: 1292
Joined: Thu Nov 16, 2006 11:53 am
Location: Kyiv, Ukraine

Post by DV »

Infocatcher wrote:Я правильно понимаю, то при включенном Coder'е будут учтены результаты его работы?
Да. Реализация GoToNearestBracket и SelToNearestBrackets достаточно сильно опирается на плагин Coder, и без него будет "хромать" (хотя с обычным текстом справляется довольно неплохо). Эти функции используют собственный алгоритм поиска парных скобок (более "тяжёлый" алгоритм), который отличается от алгоритма, использующегося при подсветке скобок.

DV
Offline
Posts: 1292
Joined: Thu Nov 16, 2006 11:53 am
Location: Kyiv, Ukraine

Post by DV »

XBrackets v.7.8
+ улучшено поведение при запуске AkelPad
+ небольшой рефакторинг для OnEditGetActiveBrackets

Offline
Posts: 165
Joined: Fri Aug 15, 2008 8:58 am

Post by Diamen »

On a very long file, 10000 lines Javascipt, it doesn't look like it works anymore "Go to matching backet".
With same function isoled in other smart file work.

DV
Offline
Posts: 1292
Joined: Thu Nov 16, 2006 11:53 am
Location: Kyiv, Ukraine

Post by DV »

Diamen wrote:On a very long file, 10000 lines Javascipt, it doesn't look like it works anymore "Go to matching backet".
With same function isoled in other smart file work.
What about "Go to nearest bracket"? (It may look surprising, but "Go to matching backet" and "Go to nearest bracket" actually use different approaches and are implemented differently).
I tested XBrackets with a .js file of 11 MB (186000 lines), and it worked.
Could it be that you are using XBrackets without the Coder plugin? In such case, XBrackets may not highlighted/jump to brackets in case of ambiguity.
You may experiment with the option "highlight.hlt_xmode" described in the "XBrackets-Eng.txt" file.

Offline
Posts: 165
Joined: Fri Aug 15, 2008 8:58 am

Post by Diamen »

You're right. It is not a length problem. It does not work with this code:

Code: Select all

abc:function(url, br){
	if(xy(":")===0){
		xy(br, aaa, bbb);
	}else{
		xy(url, "abc", null, {
			found:false,
			end:function(a){
				if(this.found===false){
					alert(br, aaa, bbb);
				}
			},
			end2:()=>{},
			end3:function(a){
				a=a.value;
				if(typeof a!==und && a!==null){
					this.found=true;
					a=JSON.parse(a);
					xy(br, aaa, bbb);
				}
			}
		});
	}
},

DV
Offline
Posts: 1292
Joined: Thu Nov 16, 2006 11:53 am
Location: Kyiv, Ukraine

Post by DV »

Diamen wrote:It does not work with this code
This isolated code works for me, with and without the Coder plugin.
Probably the problem is in the context (something around this code) or maybe in some specific characters (such as Unicode whitespaces or special brackets/quotes that have not been copied/pasted to the forum with the very same character codes as in the original text).

Offline
Posts: 165
Joined: Fri Aug 15, 2008 8:58 am

Post by Diamen »

I attach here the file.

Image

DV
Offline
Posts: 1292
Joined: Thu Nov 16, 2006 11:53 am
Location: Kyiv, Ukraine

Post by DV »

Diamen
Hmm, I don't know what to think, looks OK for me:

Image


Image

Offline
Posts: 165
Joined: Fri Aug 15, 2008 8:58 am

Post by Diamen »

I discovered that it returns to work if I delete these files. There must be a strange conflict.

DV
Offline
Posts: 1292
Joined: Thu Nov 16, 2006 11:53 am
Location: Kyiv, Ukraine

Post by DV »

Diamen
Ah, yes, something similar came to my mind lately last night.
XBrackets heavily relies on Coder's parsing when Coder is available. (That's why I suggested to play with the "highlight.hlt_xmode" option - to see whether something changes when the AEM_ things are disabled).
In short, if the Coder's rules (defined in the corresponding "*.coder" file) introduce some negative effects on brackets/braces/quotes parsing, these negative effects will be inherited by XBrackets (since XBrackets heavily relies on Coder's parsing when Coder is available).

Offline
Posts: 165
Joined: Fri Aug 15, 2008 8:58 am

Post by Diamen »

highlight.quote_detect_lines = 1
work fine.
Post Reply