~jpgleeson/spawsh

a2465f3b82f1fd463af5ff1bf4d84df47eb163fb — Jack Gleeson 7 months ago c024ccb master
Highlight currently selected link
1 files changed, 17 insertions(+), 3 deletions(-)

M Program.cs
M Program.cs => Program.cs +17 -3
@@ 510,7 510,19 @@ namespace spawsh
                            string outString = DisplayBuffer[i].Replace("#", string.Empty);
                            Console.WriteLine(outString);
                            Console.ForegroundColor = originalColour;
                        } else {
                        } else if (DisplayBuffer[i].Length > 3 && DisplayBuffer[i].Substring(0, 2) == "{l") {
                            string linkMetadata = DisplayBuffer[i].Split("}")[0];
                            string numberMetadata = linkMetadata.Replace("{l", string.Empty);
                            int thisLinkIndex = int.Parse(numberMetadata);
                            
                            var originalColour = Console.ForegroundColor;
                            string outString = DisplayBuffer[i].Replace(linkMetadata + "}", string.Empty);
                            if (selectedLinkIndex == thisLinkIndex) {
                                Console.ForegroundColor = ConsoleColor.Blue;
                            }
                            Console.WriteLine(outString);
                            Console.ForegroundColor = originalColour;
                        }else {
                            Console.WriteLine(DisplayBuffer[i]);
                        }
                    }


@@ 522,6 534,7 @@ namespace spawsh
        static void buildDisplayBuffer() {
            string[] tempBuffer = new string[1024];
            int currentPointer = 0;
            int currentLink = 0;

            foreach (string singleLine in LineBuffer) {
                if (singleLine.Length < Console.WindowWidth)


@@ 536,13 549,14 @@ namespace spawsh
                            //then singleLine = singleLine.Replace(toRemove, "");
                            string linkAndDescription = singleLine.Substring(3);
                            if (linkAndDescription.Contains('\t')) {
                                tempBuffer[currentPointer] = linkAndDescription.Split('\t')[1];
                                tempBuffer[currentPointer] = "{l" + currentLink + "}" + linkAndDescription.Split('\t')[1];
                            } else {
                                toRemove = linkAndDescription.Split(' ')[0];
                                linkAndDescription = linkAndDescription.Replace(toRemove, "");
                                tempBuffer[currentPointer] = linkAndDescription;
                                tempBuffer[currentPointer] = "{l" + currentLink + "}" + linkAndDescription;
                            }
                            currentPointer++;
                            currentLink++;
                        } else {
                            tempBuffer[currentPointer] = singleLine;
                            currentPointer++;