Thread overview
August 13
So, I'd like to fix some of visual D's navigation and editing logic and possibly implement something like elastic tabs: http://nickgravgaard.com/elastic-tabstops/

1. Backspace and delete should be tab aligned and use elastic space.

2. Indention on new line should not add spaces(it currently does and screws things up as things are no longer aligned and it is very difficult to realign stuff.

3. Indentation should use previous indentation when using tab or enter, unless empty line.

I've went ahead and added a property called elasticSpace to visual D's properties(should be in the tab section I suppose but I didn't wanna have to figure that mess out).



propertypage: https://justpaste.it/1a1if

dpackage: https://justpaste.it/1a1ig

This do add it to the first entry and defaults it to true but that can easily be fixed.

The real work is to consume all spaces, working backwards, when hitting backspace and to consume all spaces forward when hitting delete. Also dealing with other the tab and enter key appropriately.

TabSanity uses the code like

https://justpaste.it/1a1ij

Anyways, I'm at the following location in viewfilter.d and a little lost(well, time constraints).


The backspace key is handled as so:

			// Handle backspace
			case ECMD_BACKSPACE:
				if(mCodeWinMgr.mSource.IsCompletorActive())
					initCompletion(false);
				if (Package.GetGlobalOptions().elasticSpace)
				{
					mView.GetCaretPos(&line, &idx);

					dchar ch = pvaIn.uiVal;
				}
				goto case;

in which I've added the new code.

but it's a little difficult to navigate through the code. I think with the proper mapping maybe it is possible almost directly copy and paste the tabsanity code.

In any case, I figured I'd let you have a shot at it first if you want since your probably more familiar with it than me(and since debugging is extremely slow with this sorta thing I'll probably burn a lot more time than you would).

Thanks







August 14
On Sunday, 13 August 2017 at 20:43:21 UTC, Johnson Jones wrote:
> So, I'd like to fix some of visual D's navigation and editing logic and possibly implement something like elastic tabs: http://nickgravgaard.com/elastic-tabstops/
>
> 1. Backspace and delete should be tab aligned and use elastic space.
>
> 2. Indention on new line should not add spaces(it currently does and screws things up as things are no longer aligned and it is very difficult to realign stuff.
>
> 3. Indentation should use previous indentation when using tab or enter, unless empty line.
>
> I've went ahead and added a property called elasticSpace to visual D's properties(should be in the tab section I suppose but I didn't wanna have to figure that mess out).
>
>
>
> propertypage: https://justpaste.it/1a1if
>
> dpackage: https://justpaste.it/1a1ig
>
> This do add it to the first entry and defaults it to true but that can easily be fixed.
>
> The real work is to consume all spaces, working backwards, when hitting backspace and to consume all spaces forward when hitting delete. Also dealing with other the tab and enter key appropriately.
>
> TabSanity uses the code like
>
> https://justpaste.it/1a1ij
>
> Anyways, I'm at the following location in viewfilter.d and a little lost(well, time constraints).
>
>
> The backspace key is handled as so:
>
> 			// Handle backspace
> 			case ECMD_BACKSPACE:
> 				if(mCodeWinMgr.mSource.IsCompletorActive())
> 					initCompletion(false);
> 				if (Package.GetGlobalOptions().elasticSpace)
> 				{
> 					mView.GetCaretPos(&line, &idx);
>
> 					dchar ch = pvaIn.uiVal;
> 				}
> 				goto case;
>
> in which I've added the new code.
>
> but it's a little difficult to navigate through the code. I think with the proper mapping maybe it is possible almost directly copy and paste the tabsanity code.
>
> In any case, I figured I'd let you have a shot at it first if you want since your probably more familiar with it than me(and since debugging is extremely slow with this sorta thing I'll probably burn a lot more time than you would).
>
> Thanks

So, I'm trying to implement some of this stuff but I can't seem to find a way to get the modified line before it was modified.

I'm using something like this

BSTR str;
					mCodeWinMgr.mSource.mBuffer.GetLengthOfLine(line, &len);
mCodeWinMgr.mSource.mBuffer.GetLineText(line, 0, line, len, &str);

while tabsanity is using something like

auto snapshot = TextView.TextBuffer.CurrentSnapshot;

which I can't seem to find an equivalent of in visual D.


Any ideas?
August 14

On 14.08.2017 03:49, Johnson Jones wrote:
> On Sunday, 13 August 2017 at 20:43:21 UTC, Johnson Jones wrote:
>> So, I'd like to fix some of visual D's navigation and editing logic and possibly implement something like elastic tabs: http://nickgravgaard.com/elastic-tabstops/
>>
>> 1. Backspace and delete should be tab aligned and use elastic space.
>>
>> 2. Indention on new line should not add spaces(it currently does and screws things up as things are no longer aligned and it is very difficult to realign stuff.
>>
>> 3. Indentation should use previous indentation when using tab or enter, unless empty line.
>>
>> I've went ahead and added a property called elasticSpace to visual D's properties(should be in the tab section I suppose but I didn't wanna have to figure that mess out).
>>
>>
>>
>> propertypage: https://justpaste.it/1a1if
>>
>> dpackage: https://justpaste.it/1a1ig
>>
>> This do add it to the first entry and defaults it to true but that can easily be fixed.
>>
>> The real work is to consume all spaces, working backwards, when hitting backspace and to consume all spaces forward when hitting delete. Also dealing with other the tab and enter key appropriately.
>>
>> TabSanity uses the code like
>>
>> https://justpaste.it/1a1ij
>>
>> Anyways, I'm at the following location in viewfilter.d and a little lost(well, time constraints).
>>
>>
>> The backspace key is handled as so:
>>
>>             // Handle backspace
>>             case ECMD_BACKSPACE:
>>                 if(mCodeWinMgr.mSource.IsCompletorActive())
>>                     initCompletion(false);
>>                 if (Package.GetGlobalOptions().elasticSpace)
>>                 {
>>                     mView.GetCaretPos(&line, &idx);
>>
>>                     dchar ch = pvaIn.uiVal;
>>                 }
>>                 goto case;
>>
>> in which I've added the new code.
>>
>> but it's a little difficult to navigate through the code. I think with the proper mapping maybe it is possible almost directly copy and paste the tabsanity code.
>>
>> In any case, I figured I'd let you have a shot at it first if you want since your probably more familiar with it than me(and since debugging is extremely slow with this sorta thing I'll probably burn a lot more time than you would).
>>
>> Thanks
> 
> So, I'm trying to implement some of this stuff but I can't seem to find a way to get the modified line before it was modified.
> 
> I'm using something like this
> 
> BSTR str;
>                      mCodeWinMgr.mSource.mBuffer.GetLengthOfLine(line, &len);
> mCodeWinMgr.mSource.mBuffer.GetLineText(line, 0, line, len, &str);
> 
> while tabsanity is using something like
> 
> auto snapshot = TextView.TextBuffer.CurrentSnapshot;
> 
> which I can't seem to find an equivalent of in visual D.
> 
> 
> Any ideas?

You can capture the state of the line before default execution with

mNextTarget.Exec()

Maybe your code could just be moved up there to begin with.
August 14

On 13.08.2017 22:43, Johnson Jones wrote:
> So, I'd like to fix some of visual D's navigation and editing logic and possibly implement something like elastic tabs: http://nickgravgaard.com/elastic-tabstops/
> 
> 1. Backspace and delete should be tab aligned and use elastic space.
> 
> 2. Indention on new line should not add spaces(it currently does and screws things up as things are no longer aligned and it is very difficult to realign stuff.
> 
> 3. Indentation should use previous indentation when using tab or enter, unless empty line.
> 
> I've went ahead and added a property called elasticSpace to visual D's properties(should be in the tab section I suppose but I didn't wanna have to figure that mess out).
> 
> 
> 
> propertypage: https://justpaste.it/1a1if
> 
> dpackage: https://justpaste.it/1a1ig
> 
> This do add it to the first entry and defaults it to true but that can easily be fixed.

It's a lot easier to see your changes if you fork the code on github and push your commits. Than the diff shows up there automatically.

I wonder why the elastic-tabstop extension doesn't work with Visual D. I doubt it's tied to specific languages.
August 14
On Monday, 14 August 2017 at 06:50:21 UTC, Rainer Schuetze wrote:
>
>
> On 14.08.2017 03:49, Johnson Jones wrote:
>> On Sunday, 13 August 2017 at 20:43:21 UTC, Johnson Jones wrote:
>>> So, I'd like to fix some of visual D's navigation and editing logic and possibly implement something like elastic tabs: http://nickgravgaard.com/elastic-tabstops/
>>>
>>> 1. Backspace and delete should be tab aligned and use elastic space.
>>>
>>> 2. Indention on new line should not add spaces(it currently does and screws things up as things are no longer aligned and it is very difficult to realign stuff.
>>>
>>> 3. Indentation should use previous indentation when using tab or enter, unless empty line.
>>>
>>> I've went ahead and added a property called elasticSpace to visual D's properties(should be in the tab section I suppose but I didn't wanna have to figure that mess out).
>>>
>>>
>>>
>>> propertypage: https://justpaste.it/1a1if
>>>
>>> dpackage: https://justpaste.it/1a1ig
>>>
>>> This do add it to the first entry and defaults it to true but that can easily be fixed.
>>>
>>> The real work is to consume all spaces, working backwards, when hitting backspace and to consume all spaces forward when hitting delete. Also dealing with other the tab and enter key appropriately.
>>>
>>> TabSanity uses the code like
>>>
>>> https://justpaste.it/1a1ij
>>>
>>> Anyways, I'm at the following location in viewfilter.d and a little lost(well, time constraints).
>>>
>>>
>>> The backspace key is handled as so:
>>>
>>>             // Handle backspace
>>>             case ECMD_BACKSPACE:
>>>                 if(mCodeWinMgr.mSource.IsCompletorActive())
>>>                     initCompletion(false);
>>>                 if (Package.GetGlobalOptions().elasticSpace)
>>>                 {
>>>                     mView.GetCaretPos(&line, &idx);
>>>
>>>                     dchar ch = pvaIn.uiVal;
>>>                 }
>>>                 goto case;
>>>
>>> in which I've added the new code.
>>>
>>> but it's a little difficult to navigate through the code. I think with the proper mapping maybe it is possible almost directly copy and paste the tabsanity code.
>>>
>>> In any case, I figured I'd let you have a shot at it first if you want since your probably more familiar with it than me(and since debugging is extremely slow with this sorta thing I'll probably burn a lot more time than you would).
>>>
>>> Thanks
>> 
>> So, I'm trying to implement some of this stuff but I can't seem to find a way to get the modified line before it was modified.
>> 
>> I'm using something like this
>> 
>> BSTR str;
>>                      mCodeWinMgr.mSource.mBuffer.GetLengthOfLine(line, &len);
>> mCodeWinMgr.mSource.mBuffer.GetLineText(line, 0, line, len, &str);
>> 
>> while tabsanity is using something like
>> 
>> auto snapshot = TextView.TextBuffer.CurrentSnapshot;
>> 
>> which I can't seem to find an equivalent of in visual D.
>> 
>> 
>> Any ideas?
>
> You can capture the state of the line before default execution with
>
> mNextTarget.Exec()
>
> Maybe your code could just be moved up there to begin with.

Moved up where?

I see 'int rc = mNextTarget.Exec(pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut);'

which is about all that is used with mNextTarget.Exec, but it is calling it rather than overriding it in some way.

Once I get some progress I'll submit some patches, right now I'm just toying around with it trying to see how it's all set up. While I can do some things I feel like I'm gonna have to revamp some of the editing(all optional) because I get pretty frustrated in Visual D due to time consuming processes of wrangling with spaces.

e.g., when one hits return it always seems to take them to the start of the line, then tabs move one at a time instead of jumping to the previous tab indention. One one had many nesting and about 10+ tabs, this is time consuming, and must be done for each line. Similar issues occur with backspace, delete, etc.

I can fix the bulk of this and tweak them as I use visual D for my own projects once I get a handle on how to do that in visual D's source.  It's a bit more wacky than doing it in C# since it seems to use COM to do it all, which means there is little documentation for it.

What I've noticed is that one can run a separate window from visual studio using visual D and I think this will open some cool things for the future, such as a real time debug view window that can list such things as instantaneous memory usage(a graph, sort of like diagnostic properties, etc), performance, variable values, etc. Although, that's just conceptual now, but I can imagine it being a useful utility feature.

Right now I've got a simple console running displaying the debug information so I know what is going on, but eventually that could be turned in to something useful for actually coding and debugging in D.


August 15

On 14.08.2017 16:51, Johnson Jones wrote:
> On Monday, 14 August 2017 at 06:50:21 UTC, Rainer Schuetze wrote:
>>
>> You can capture the state of the line before default execution with
>>
>> mNextTarget.Exec()
>>
>> Maybe your code could just be moved up there to begin with.
> 
> Moved up where?
> 
> I see 'int rc = mNextTarget.Exec(pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut);'
> 
> which is about all that is used with mNextTarget.Exec, but it is calling it rather than overriding it in some way.

That's how the chaining works, this call executes the default implementation of the command.


> 
> Once I get some progress I'll submit some patches, right now I'm just toying around with it trying to see how it's all set up. While I can do some things I feel like I'm gonna have to revamp some of the editing(all optional) because I get pretty frustrated in Visual D due to time consuming processes of wrangling with spaces.

Apart from "smart indentation", there is little that Visual D does to spacing, it's default VS behavior. Even the "elastic tabs" plugin works (in VS2015), and I like its functionality of keeping code vertically aligned automatically, but I don't think it's a good idea to enhance tabs for this as the code will look broken everywhere else. Instead, it should just fill in tabs/spaces as usual.

> 
> e.g., when one hits return it always seems to take them to the start of the line, then tabs move one at a time instead of jumping to the previous tab indention. One one had many nesting and about 10+ tabs, this is time consuming, and must be done for each line. Similar issues occur with backspace, delete, etc.

Do you have "smart indentation" enabled?

> 
> I can fix the bulk of this and tweak them as I use visual D for my own projects once I get a handle on how to do that in visual D's source.  It's a bit more wacky than doing it in C# since it seems to use COM to do it all, which means there is little documentation for it.
> 
> What I've noticed is that one can run a separate window from visual studio using visual D and I think this will open some cool things for the future, such as a real time debug view window that can list such things as instantaneous memory usage(a graph, sort of like diagnostic properties, etc), performance, variable values, etc. Although, that's just conceptual now, but I can imagine it being a useful utility feature.
> 
> Right now I've got a simple console running displaying the debug information so I know what is going on, but eventually that could be turned in to something useful for actually coding and debugging in D.
> 
> 
August 15
On Tuesday, 15 August 2017 at 07:12:44 UTC, Rainer Schuetze wrote:
>
>
> On 14.08.2017 16:51, Johnson Jones wrote:
>> On Monday, 14 August 2017 at 06:50:21 UTC, Rainer Schuetze wrote:
>>>
>>> You can capture the state of the line before default execution with
>>>
>>> mNextTarget.Exec()
>>>
>>> Maybe your code could just be moved up there to begin with.
>> 
>> Moved up where?
>> 
>> I see 'int rc = mNextTarget.Exec(pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut);'
>> 
>> which is about all that is used with mNextTarget.Exec, but it is calling it rather than overriding it in some way.
>
> That's how the chaining works, this call executes the default implementation of the command.
>

Ok, I'll play around with it and see if I can make more sense of it.

>
>> 
>> Once I get some progress I'll submit some patches, right now I'm just toying around with it trying to see how it's all set up. While I can do some things I feel like I'm gonna have to revamp some of the editing(all optional) because I get pretty frustrated in Visual D due to time consuming processes of wrangling with spaces.
>
> Apart from "smart indentation", there is little that Visual D does to spacing, it's default VS behavior. Even the "elastic tabs" plugin works (in VS2015), and I like its functionality of keeping code vertically aligned automatically, but I don't think it's a good idea to enhance tabs for this as the code will look broken everywhere else. Instead, it should just fill in tabs/spaces as usual.

Yeah, I'm not proposing any virtual tabs. But simply make the keys a bit a bit smarter. e.g., backspace will not blindly remove the last space but look back to the first non-space character and to the lines around it. If they has a certain format, it will backspace more than one character automatically. Same with del, enter, tab, etc.  They won't blindly insert/remove characters but be more intelligent about their surroundings.

The goal, ultimately, so so that one does not have to do any formatting. Probably at least 10% of my keystrokes are formatting... it should be nearly 0. E.g., suppose a coding style has been created that formats the code exactly the way one wants, every keystroke, in theory, could reformat the document and make it look correct. This way the document never gets out of sync with the correct format. While this isn't possible in practice for various reasons, one can get close with a little work.


>> 
>> e.g., when one hits return it always seems to take them to the start of the line, then tabs move one at a time instead of jumping to the previous tab indention. One one had many nesting and about 10+ tabs, this is time consuming, and must be done for each line. Similar issues occur with backspace, delete, etc.
>
> Do you have "smart indentation" enabled?
>

Probably not, as I remember turning it off a long time ago due to it not working well and causing various issues.