This Text Editor Will Replace VSCode

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
looks like we're live hello everyone and welcome to yet another recreational programming session how about it machine to happen so let's make a little bit of an announcement and officially start at the stream hello hello everyone welcome welcome welcome so let's do a red circle live on Twitch and what are we doing today on Twitch at dot at television website today we're looking into the focus text editor right so I'm gonna give the link to uh to digital TV surgeon the place where we're doing all that I'm gonna ping everyone who's interested in being pinged and there you go the stream has officially started the stream has officially started so uh here's the focus uh simple fast and Fast text editor right so um I heard about this text editor for quite some time and it's actually quite famous among the Java beta testers and the reason why it is so popular among the Java beta testers is because it's entirely written in batch files that's the main reason right so in in fact it's it's written in Jai it's just like GitHub is incapable of recognizing GI files so that's why it says that it uses batch files because there's a couple of batch files which I do not necessarily understand why I thought the entire purpose of the the entire sort of like philosophy of jai is that uh you know the compiler itself is a build system you don't need additional scripts on top of the compiler to facilitate anything you just have one single file you just build that file and file does the rest but still I I suppose this is like some sort of old reflexes or like maybe to hook things up into text editors or something like that I don't really know but it is what it is after all these you know batch scripts are not really that big so they're just like you know they call Jai with a couple of parameters and stuff like that so anyway um so the problem with this text editor that they had is that it literally crashes on my machine and it crashes with a very interesting uh so the problem it crashes with the Sig eel so for those who doesn't know is a signal that is sent when the CPU tries to execute an illegal instruction it's not even a sec fault mind you right it's not even a second fault is when the the application is trying to touch the memory it's not supposed to touch Sig ill is just like the the code like looks at the memory and the memory contains an instruction that CPU isn't capable of executing there's a lot of situation that can lead to that and this is actually really weird right but uh recently I found a way to actually make it work right so and because of that I decided to finally do a string where I look into that text editor on top of that eleont suggested to implement something for this text editor because it's open source so you can actually extend it and stuff like that and specifically there is a problem uh on Linux for this text editor since um you know majority of the developers I suppose are on Windows because it's a language for game development and uh Windows is an operating system for video games right so Linux is a real operating system for serious business for serious people and for the video games there is a separator like a niche operating system called Windows right so majority of the of the so sorry majority majority of the GI developers are game developers so that's why they use this Niche operating system for video games and that's why they probably don't really test on on video operating systems right because of that there's some features missing and specifically there is no save dialogue for uh for for Linux right so uh so element is here uh just a second uh we have these reports something similar might be what you're getting yeah I think I already looked into that so you say it's an issue 92 um so I remember enable like I basically assume that you wanted to uh want me to implement this right so and essentially somebody already tried to implement the save dialogue for for the text editor and they couldn't because a very interesting problem right so the problem is that the safe the platform save dialog that the applications sort of designed around is synchronous but to make it sort of like a built-in you need to have an asynchronous one so it's a sort of a conflict between synchronous and asynchronous API and it's not as easy as just like you know calling to uh to a separate like API or something like that but you're saying you're saying there is um something something like this oh you're talking about um you're talking about the crash I already kind of fixed the crash so uh yeah yeah the the editor doesn't run uh when the CPU doesn't support as instructions yeah yeah so uh I found a workaround for that I don't know if you guys found a workaround for that uh but I found a workaround for that which I probably gonna show on on today's stream right so yeah thank you so much for for letting me know uh essentially uh so let me actually put um this thing maybe into the into the references uh right potential so um I don't know issue all the potential source of crash right I'm gonna put it in here just in case somebody else is going to have this synthetic uh right but to be able to use this text editor unfortunately you have to have an access to jai so yeah but maybe like enough people who actually enjoy better actually watch My Stream So maybe they will be able to uh to make use of that so I think I already cloned um Focus somewhere here so here it is already clunded so and essentially let's try to build this entire thing I'm gonna use this command line right so I'm going to use this command line and I'm going to run it super quick so I don't think it needs to be quiet so we do need import gear and let's just try to build it we'll just try to build um all right so as you can see it builds successfully right it builds absolutely successfully so now uh I think it created an executable right so Focus debug right so here's the focus debug and if I try to run this Focus debug uh it crashes right it says that it crashes with a signal 4 right and if we Google Apple this is signal for uh posix signal 4. mm-hmm posix signal 4 and I wonder if that's because of the Google goddamn Google posix signals uh some Chinese University or something like that that's very interesting uh so it's a signal right so it's an illegal instruction and it has something to do with uh calculate mu hash and mu hash if I'm not mistaken is like a custom hash implemented by the one and only the man the legend Casey moratori right so if we actually go to here simulatory uh so I think yeah it's his hash if I'm not mistaken right so so mu hash and somebody ported that mu hash uh to to jai and a lot of people use it I don't really know what's the main purpose of the hash uh I think it's like sort of like a general purpose hash you can use it for the uh for the hash tables or you can use it for uh you know competing like you know hashes for the files and stuff like that you know uh different stuff so I think it is general purpose hash so and it is used in here right it is used in here I'm going to copy paste this thing in the chat and for people who's potentially watching uh all of that on YouTube I'm gonna put it in here uh Neo hash by uh casing sorry so it's this one I probably want to put back back ticks in here so uh we've got some subs thank you so much thank you thank you thank you for which Prime subscription I really appreciate it uh all righty so and let's try to investigate that like I already know uh what kind of the problem I don't really know I still don't know what's the problem but I know how to fix that so as you can see it tries to load and merge uh config right so let's actually go there and try to see the context in which this calculate me of hash is used uh right so I'm gonna literally just grab for this specific function and just like find where is it is it used uh rather where it is defined so here it is here it's where it's defined and we can do calculate mu hash right so it is used to calculate whether I suppose a configuration file has changed or not right so I suppose I don't really know how exactly this text editor Works uh but from what I could understand um right uh it just like reloads the uh the config file and it can detect whether the config file was changed or not and maybe it can do something on that right maybe there's some sort of expensive operation of Pars in the configuration file so it doesn't want to do that if the file didn't change probably I don't really know I didn't really look deep into that but that would make sense that would make sense uh so and essentially we can look into this function right so uh let me also grab it and let me also find it grip or end um so we need to find the definition of this function right so here it is and we already have an assembly in line things right so instantly so in a place where things actually fail with Sig ill in legal instruction obviously we have some hard-coded assembly stuff well who would have thought that something like that will happen uh so it also calls to things like mu hash uh and some other stuff we can we may look into these kind of things it's actually a very interesting syntax right so hash colon back so and that is not really used anywhere but hash is kind of used somewhere so this thing I suppose defines a variable I'm not really familiar with how exactly ji works but I suppose it's a way to define a variable but what kind of variable so if it's a vect maybe it's a vac register you define a variable that it basically refers to the vector register but then we never really specify which Vector register we're referring to does that mean that the built-in like inline assembly of jai is so powerful that we can make abstract statements like pick whatever Vector register is free right now and use that is that how powerful Jai is really I can say basically any sort of vector register just give me whatever Vector register you have free as of right now because maybe uh of the because of the different optimization some of the vector register could be taken uh or something like that just like um use your register allocator and allocate me one of the register like I don't really know how J works it's just like this is the implications that I see just by looking at this syntax and that is I'm already blown away if that's actually true this is insane holy right I don't really know it's just like this kind kind of implies that you can do this and holy that is awesome because I've never seen any language doing this kind of thing um um it doesn't work on your PC though yeah it's too good to be true so yeah it is too good to be true uh thank you so much 2000 for um twitch Prime subscription that is insane my friendly befriend that is absolutely insane uh all right so let's take a look at this kind of thing um right so uh let me let me see so um where am I going so I think I'm actually lost a little bit so let's actually find this thing uh okay so I suppose this thing is defined in uh the modules right so in the main modules of giant so let's actually find this thing in here hopefully hopefully we will find it and if we take a look even more into that it's even more assembly right oh my God so it's pretty much implemented in assembly um right and it fails somewhere here with sigil uh right so a proper solution would be probably like figure out uh what kind of instruction my CPU doesn't support and maybe make some sort of like if Dev somewhere here or maybe in the main application so I went with a sledgehammer solution right so essentially what we need we need to calculate the hash so there is already a hash module in a standard ji library right so let's just use that instead it's probably worse right it's probably worse than mu hash because mu hash is like very carefully decided by the case emulatory himself right he tested out very carefully and made sure that it's suitable for these specific cases and stuff like that he spend a lot of time doing all that stuff so and I'm pretty sure that his hash is better than whatever we haven't here but our goal is to stop our application crashing at least so using these stock hash is probably going to be worse but it's gonna make our application at least run at least right so we don't want like to have like a super performance or anything like that like we want at least see something on the screen because right now we can't even see in this uh right so let me let me see what we can do in here so if I go to new hash so essentially what we can do uh we can just go ahead and like literally return uh return the bytes I think it's going to work and I'm going to just like comment this entire thing out right so whatever you put in any of these things is going to use the uh the thing from the hash right so and let's actually try to do the the build and uh it doesn't have a get hash so you're supposed to import it but as far as you can tell there's no includes or Imports in the new hash J so that means it's probably literally included into uh into some something else right so let's actually try to find where it is included we can try to find uh mu hash Jai so it is included in main.j right so this is basically the section where all of these things are included literally just inserted I think load just literally inserts everything um right and we should have something like Imports uh yeah there we go so here's the Imports of the standard libraries and this is where we can uh I don't know just put the hash in here right so I don't know how we're supposed to put I think you're supposed to sort them no they're not sorted by the alphabet I don't think so anyway so let's try to compile this entire thing and see if it's going to at least work um so I can hear some some weird people outside I should probably close the uh anyway so it's a KGB agents outside they're trying to to find me all right so it seems to be working right so it seems to compile at least right it seems to compile at least now if we do uh Focus debug it works so if you guys ever needed like a workaround for this situation here it is so you can do it like that it's I don't know what kind of problems this can introduce but at least it makes it work and there you go here is the focus text editor the the one and only the famous the legendary text uh text editor that you probably heard of probably not I don't know but here it is so what kind of can you do with this text editor so this is actually rather interesting so there's some uh you know shortcuts and everything it reacts to control scroll wheel right it reacts to that so we can do alt X that shows all of the commands Okay that's actually pretty cool uh so not that many commands right so we can create a new file uh so yeah I can probably edit something right so it also I don't know what that is right so I suppose it's a first line uh right can we write something like this right can you write hello world and we don't really have any syntax highlighting but I know for a fact that it does support syntax highlighting right so because if I try to I mean let's see it it can't open a thing that doesn't exist yet it can't really open a thing that doesn't exist yet so this is not something that you can do uh right but this is because it's unfinished right so this is because it's application uh so um yeah can I can I open that something that already exists so for instance I can probably open the buffer.j there we go so it does have highlighting four uh for giant right it does have highlighting for Jai but I'm not sure does it have highlighting for C files right because I mean okay let me create the C file in here right so and then I'm gonna go and just try to find main.c and then so it detects uh the highlighting by an extension and as far as I know you can put commands in here and there is no way to put a syntax like how do I enforce a syntax on something um right so I think there is no way to do that at least I couldn't find a way to do that right at least I couldn't find a way to do that so I suppose it's purely based on uh on an extension and it's probably going to be fixed at some point that's for sure because I personally uh what I like to do is I like to open a text editor open a new file that I never saved anywhere and set a specific syntax like work on that I think for a while and then save it right this is how I work and this is why this is this was the first thing I tried to do I tried to open a new file that I never saved and it was trying to find where do I set the syntax right so they couldn't find it then yeah but it does support like this kind of things I wonder how many syntaxes it supports we can probably try to find that we can try to do grep and just like literally trying where it looks for a string literal that looks like this I'm pretty sure this is how it checks for that maybe not uh no this is not how it does that that's for sure so it's probably something about extension extension oh that's that's a lot um but maybe there is a specifically like um string literal with just yeah there we go there we go get it easy peasy lemon squeezy the years of experience like I know nothing about this code Base by the way I purely guessed like how it was implemented right so if it's based on extensions that means somewhere in the code base there is literally a string literal that contains an extension and it's a very unique combination of characters uh that you can literally grab and instant Define that place right so I have zero knowledge about the code base but just like by knowing how the code base is usually behave uh I can just compose a grip and find the place and this is how it's done so this is uh how many different things it supports right so this is how many minutes supports two choose by the way um okay the JavaScript people probably uh won't ever use this editor anyway [Laughter] this is a freaking goal holy I love it if they do we'll stop making fun of me this is so good I don't like that so it's we already off to a great start right so people who develop this thing they have a great sense of humor like that um uh so uh okay um so in the main problem if I understand correctly ah what the is going on like dudes all right so we should probably switch to to focus um you can create a new file right so you created a new file and you can't save it like I press Ctrl s nothing happens nothing happens so the only thing it does it brings this name new file right so it only prints that but nothing nothing happens I can show you because it is not implemented uh so and uh let me let me see so I want you to look at some uh issues right so this is the main issues unable to save the file and it's a known issue because it's literally not implemented so the function that is responsible for this kind of thing is called platform get save file name we can try to find this function right so is it where is it defined uh so yeah there we go so this is actually a quite common thing right so we have a platform folder and for each platform we have a separate file Linux Windows and Mac OS and they probably have the same set of like functions right the same interface so to speak and depending on the platform like a different file is going to be included we can even try to confirm that by literally searching for mentioning of linux.ji right and obviously it is loaded in here right and as you can see depending on the current OS or current platform a different platform file is going to be included and a different implementation of these interfaces are going to be used right so and uh let me actually go to the Linux file and the function that we care about right the function that we care about is platform save file name and it's literally not implemented it it literally does nothing it literally does nothing so and here is an interesting thing if we take a look at the same function in a Windows File uh we'll see something right so in a Windows File uh we're preparing the usual crazy win win API structure or something like that and then we do get open file name and from what I could understand in this specific comment get open file name is actually blocking it is actually blocking so at this point the execution of the main program is going to stop right and then get open file name will create its own event Loop that is going to handle the user input and then the user will navigate and select the file and stuff like that and then it will close it and only then the control will resume in here and continue execution so and kind of like this entire function sort of assumes that it's going to be blocking uh but the problem is that the whole sort of native UI of the editor right and by native if you have the editor I mean the you know the UI system that the focus editor uses right it's very much asynchronous it's actually immediate UI right the things that like this uh sort of like a search stuff or um you know list dialogue they are not blocking they are integrated into the main Loop of the text editor itself and that's why it is so kind of difficult to implement this problem right so because on Windows the API is blocking but on Linux we have to have a version of API that is not blocking and it's like how do you do that and this is probably why eliante tried to debate me into into solving this problem but I'm a senior software developer like I briefly it took me like 10 minutes to just briefly look into the into the code base and realize what kind of stuff you're trying to wrote me in it's not going to work I know what you're trying to do it really didn't take me like a long to figure out all of that like no no no no no no um I'm not gonna do that like I'm not some Junior some enthusiastic Junior who will work on this project and jump into it and try to uh to prove something to somebody no no it took me just like a couple of grips and I already see what you're trying to do and I already see that uh but we can try to do something anyway uh why not right so it's a very big another very big but it's rather complex issue and it couldn't be really sold in one go uh right especially while you're trying to solve a long issue some things in the code base uh probably will change but we can try to we can try to add like um save dialog in a style of control o right in a style of control o uh or at least something like a new kind of this thing right so if we take a look at the in the widgets right uh so we need to have we need to find what happens when you press Ctrl o right so when you press Ctrl s what's supposed to happen is uh the opening of that blocking window but when you press Ctrl o something different happens right something different happens and uh maybe we can try to sort of copy and replicate that code right copy and replicate that code uh uh imagine trying a new editor just to get debated into implementing features yep you do be like that this is how open source works by the way so uh if you think that open source is free I have bad news for you this is how you pay for open source right you fix the bug and you are allowed to to use the open source project that's actually kind of interesting what if like we can imagine an open source project that basically and knows you annoys you in a style of sublime until you fix one bug in that project so yeah Sublime actually annoys you to get the money but open source project annoys you to actually fix one of their bugs or maybe they can even uh this is such a funny video basically instead of fixing bugs the um the developers can put a stub into the code that detects when a certain bug happens and when that certain bugs happen it shows pop-up hey so you encountered a bug you can actually fix that bug in there right or something I think I think something like that a rust compiler already does at least when something like well-known problem occurs they may print occasionally a link to uh like an issue to get more information on that so yeah two I think something like that already kind of exists right but not in the form of a UI application hmm just right in Iota has hallucinate a bug fixes isn't that called like a codex or copilot or something like that I don't know so we need to find a place where we open a file so maybe we can find that place by literally searching for open File by name right because where we encounter this particular string literal probably nearby we have a function that opens up this sort of like a dialogue somewhere nearby let's try to literally literally search for that combination of characters and this is by the way the trick that I keep repeating for um you know for new people on the streams over and over again you are exploring a new application right for example this is your first day at job at your new job and you need to fix a certain button right you need to fix a certain button but you don't know where to search for that button in the source code take the label of the button if it's sufficiently Unique right if the label the button sufficiently just take that label and literally grab it in the entire code base you will find where that button is located and those you will find the place where the action is triggered or probably some clue where if the action is triggered and then you can start from there so UI labels and UI text is actually very like useful clues that you can use to find places in the code base use that seriously with this kind of trick on one of my jobs I actually significantly impressed my peers like they were impressed how could I find relevant place in the first day at job they couldn't believe that it's possible like they didn't know that trick like so there was some sort of a problem with some with some button they suggest just investigate that and I like just found the problem like within like 10 minutes and it's just cool how did you do that you've seen that code base for the first time I just grabbed the labels and I found it so yeah this is actually super useful so use that use that that's the real software development advice for free I'm giving you like a useful information for free can you imagine that um so anyway let's try to find that uh it would be funny if I actually won't be able to find this place uh okay so um open files there we go uh so there you go so obviously so there's two two places where we do all of that uh so I suppose okay so this is commands and this has some sort of like a global uh Global thing uh and this is a draw and this is shortcuts to display I suppose this is sort of like a splash right this is some sort of a splash and this is like all of the main actions that you can have in here okay so that's cool uh open uh file by name show open file dialog in search hmm and uh that's very interesting so let's try to search for this thing so if I remember correctly this particular syntax means that it's an enumeration uh we can try to find the definition of commands let's try to find the definition of commands uh right so this is going to be like this and in here we have actions action action editors and I wonder if it's defined somewhere here it's not really defined anywhere in here so let's find action editors and for the action editors we have uh right so show open file dialog in search uh right so it is in fact um an action so since an action is enumeration there should be some sort of like a huge switch case um that handles each individual enumeration or maybe some sort of a hash table or whatever uh right and if we can find that Hub that switch case uh we can find what is exactly called uh when this kind of action is interpreted so to speak you know what I'm talking about right so let's go ahead and just like literally search for all of the instances of this specific thing and I will already see that like I instantly see that so here's the main thing and here is sort of like a chunk of that huge switch case there you go here is the switch case that I was talking about right so what it does it calls to a function show open file dialog and here's an interesting thing depending on like where it needs to be shown you can kind of pass an additional information to there so but the the function we're interested in is show open file dialog uh right so we can search for that specific function where it is defined uh what is it doing and maybe we can extend uh this entire stuff okay so it is located within widgets okay this is already interesting so there's a folder with different widgets uh so let's actually go there and all right delete file dialog open file dialog and in the okay and open file dialog we already see the place where we can start expanding things right so essentially you didn't didn't take take us too long to figure out like this is the point of extension right so we have open file dialog we have delete file dialog we probably need an ad to add another one which is a save file dialog and what we're going to implement there probably something similar that we have in open file dialog uh right so is this the power of senior developer uh asks Rock I guess it's a power of grep um so yeah what's funny is that like I'm not even using any uh IDE or any sophisticated system or anything like that it's just literally grab and find and logic right you just like uh the thing is that um you look at the application and you try to predict how it would Implement roughly and you use that prediction too sort of like Target grab and find to specific places right and it works in the majority of the situations if the code base is sane right so there are some code bases where it doesn't really work because they're so insane but this is the same code base I really freaking like it uh it's a very good code base so I can very quickly navigate and stuff like that all right so uh show open file dialog so what this function does all right so what this function does from root so I don't really know what this parameter means derive the oh from root probably from root of the file path right or file system okay so that makes sense I get active editor and buffer so this one is interesting uh if active Global widget is editors uh buffer has file not particularly interesting oh this one is interesting active Global widget we set it to open file dialog and then open file dialog mode mode so the mode is actually the parameter in here and then we refresh entries this is interesting this one is interesting it is probably some sort of a global variable that communicates to the main Loop what is currently what is the current widget right because you can have several widgets opened up uh somewhere here right so this is the focus debug so you can have the commands right so something like the commands in here or the open file stuff and I suppose this is this is just my hypothesis I don't know for sure this is some sort of a global variable that tells the main event Loop what is currently open is that the open file dialog or is that a command thing or something like that so that means somewhere in the main Loop there is a switch case that switch cases upon active Global widgets probably I don't freaking know that but if I were implementing this thing I would implement it like that and also within the spirit of immediate UI right because it feels like the whole UI in focus is immediate UI so I would presume that this is how it roughly works so let's actually go ahead and just like grab for uh active Global widget right so Okay so so here is the editors and as you can see we are assigning Global widgets to different things so I suppose we sort of switching the global widget to some different places and somewhere here we're comparing it right so is there something like case ah there's not that oh okay so here is the if I suppose the most interesting stuff is within the main file right it's within the main file and I already see one switch case in here so this is definitely a switch case when you see if with equals equals but without the right hand side this is a switch case and this is probably uh what we have in here right so handled maybe handle a common action that applied to all widgets so it's some sort of a flag that checks whether something was handled already ah I see I know what it is I freaking know what it is this is a common problem with like that I encountered with the immediate uis is that when uh essentially there is a event and you draw several widgets and one widget handles the event and you don't want it propagate that it went to the rest of the immediate widgets so you have to somehow stop that so yeah you can introduce some sort of like a variable that sort of like tells do not propagate this event further right do not call the rest of the things all right let's see what it is I think I think that's what it is um right so past events to active widgets right so and we have active Global widgets if it's editors we do that and if it's open file dialog we call to opal open file dialog handle event that is very interesting by the following the thing is very interesting so let's try to find this kind of thing so where is it defined so this is where we're handling this entire stuff and I suppose we went back to widgets open file right okay and then there are different events and depending on different events it does different things and I suppose it can also switch the active Global widget right does it switch the active Global widget probably not but maybe it deactivates one of the global issues okay so that's kind of interesting so the main sort of communication point about what is the currently working widget is active Global widget a global variable active Global widgets and different widgets basically work on that variable switching it to something checking it from time to time and the main Loop a switch cases on that Global active widget and call to corresponding widgets okay so that makes a lot of sense um that makes a lot of sense maybe we can even draw that so I wonder if I can draw that uh active I'm going to call it active Global widget right so this is an active Global widget and essentially there is a main Loop right there is a main Loop that checks this active Global widget periodically and then you have different widgets like widget one that essentially can set a recently I think there's another widget too that can set this entire thing and then main based actually maybe it has to be like in a different direction based on active Global widget can then sort of like go and pick into different widgets in here and it's sort of like the active Global widget becomes some some sort of like a state machine right it's a state machine and depending on what's the currently active we call to different uh you know widgets that can also change the active Global widgets and stuff like that or something like that this is how I see that but I'm not 100 sure um so yeah [Music] so uh I suppose one of the things we can try to do we can try to understand what are sort of like the main um the main methods of a single widgets right so because we have a lot of different widgets in here and probably one of the things we're gonna do we're going to create save file dialogue dot giant right so we're going to create this kind of thing but what we're supposed to put in there right we can even include it somewhere so let's actually find all the places like where this kind of stuff is included right so this is where it is included and there we go we just introduced a save file dialog we already made one step further towards the implementing that feature right so we already created a file that will probably hold the the logic of that save file dialog somehow we don't really know how exactly but uh we're already there uh so it's kind of funny like I don't know what I'm doing but we're already getting closer to implemented feature probably uh maybe not get them neighbors are smoking freaking okay I should have not opened the window but if I didn't open the window I would freaking fry life because it's so hot in here it's insanely hot all right it seems to be working right so we managed to uh to essentially improve the synthetic okay so let me see what kind of methods we even have in here how many methods we have so we have init open file dialog this one is interesting so there used to be more stuff in here okay and there is some sort of like a global open file dialog is it defined anywhere I don't think I think it's okay so there is this okay so here is the open file dialog uh right and uh so it is a structure that's still okay this one is rather interesting so there is a lot of interesting stuff in here so maybe we need to introduce like a similar thing right so a scope file I remember that it basically makes everything in here sort of like a private but I don't don't know what is a scope expert uh right I don't know if it's a scope expert so here we want to have save file dialog uh struct and what we want to have in here we probably want to have something like emitted on maybe something something else but even there you need to open file dialog uh it doesn't even have anything in here so what is the refresh entries this one is a very interesting function so what it does [Music] um oh so the open file dialog right the open file download if we do Focus the uh this kind of thing right it contains several entries in here and I suppose refresh and interest is just refreshing these things right maybe um you know reading them again [Music] scope expert is the default State it's there just to switch back to from scope file scope module okay um um scope file scope module and yeah okay I suppose I'm going to be just cooking this entire thing right so I'm going to be just copying uh all right so open file and so here is the entry right so we can have different entries in here uh so there's also text input and I suppose text input is one of the widgets all right so this one is actually rather useful so maybe we we are going to have a text input uh so we have some sort of entries let's just have a text input just a text input and nothing else right so this one is going to be a scope file uh right so it's going to be hidden from the rest of the thing so scope file it's basically everything below here is private and it's not going to be visible outside of that module if I understand correctly and scope export is sort of like a public right so it's publicly available and because it's the default thing save file dialog save file dialog so by the way I like I act like I'm implementing this feature like I don't know if I will be able if I manage to implement all that I'm just like trying to like explore and see like what is possible to do in here and how this entire thing works like I don't know probably I probably won't be able to implement something usable but I think I feel like we are moving in the right direction that's roughly where you want to go maybe I don't know it's just like just exploring just exploring and here's an interesting thing so you need to open file dialog where do we call that thing excuse me so where do we call that so let me just I'm pretty sure it's called one time uh yeah I was right it's like it's called one time in a workspace right we're initializing a lot of things in this huge as function and what is that huge ass function what is this maybe update workspace buffers hmm so there's an option of workspace and there's a notion of buffers uh right so there's some sort of a scan complete so process changed so there's some file Watchers and stuff like that and somewhere within this thing that I think we need to open file uh dialog right so workspace space complete shutdown scanners reset so this is a very sophisticated multi-threaded system in here that is scans and just collects things in the holy oh my God uh and if everything was scanned correctly apparently we initialize open file dialogue I have no idea what the is going on it looks crazy uh but I I'm gonna just assume that maybe this is where we want to call init uh save file dialog probably maybe maybe that's what we want to do maybe it's completely redundant because like even you need to open the file dialogue doesn't really do anything so maybe we shouldn't do that but I mean I'm really scared of this code so this workspace thing is intimidating this is how I would uh phrase it um it is a little bit intimidating um so there is is there something like threats in here yeah there's thread groups holy it's multi-threaded applications holy oh I'm really scared of this part of code so I'm gonna actually focus on Cell file dialogue okay um um so let's continue right so I'm gonna be just just slowly copying this entire stuff in here so if we call to scope um expert so that means there's something uh like this in here so scope file uh so it's it's private again right and then another scope okay so I see now why it is like that it's kind of weird but uh all right I need to open the file there look so maybe I'm gonna just do it like this actually right in it uh save file dialog right so we need save file dialog uh and here we're gonna do save file dialog initiate true we don't really have any uh you know entries in here so we can't really refresh anything uh right in here we say there used to be more stuff in here uh there there never was stuff because yeah so it's just like this is what we started with there there never was any stuff in here uh right which is technically true so do we want to de-initialize some stuff we don't really uh allocate anything right so so what else do we have in here so we probably need to do handle events do we also draw this thing how do we render this entire stuff [Music] so these are different actions these are different actions uh I just oh maybe a handle event is actually the thing that draws this entire stuff uh it may be handle text input event uh all right and so this isn't I think and then we'll do text input handle event and it's probably inside of the text input and then inside the text input event uh we do some stuff map event uh-huh I just realized that I don't know where all of that is rendered um I just don't know where all of that is rendered but maybe this is because I'm a little bit tired I'm a little bit tired so uh we need to make a small break let's make a small break I'm gonna refill my water and I'm not gonna drink tea because it's too hot right now and after that we're gonna try to figure out so I what I want to figure out is just to see like how all of that is rendered right so okay let's make some Break um all right so people have told me uh right so the the there is a module called draw.jai right uh and in here we have a thing that draws a single frame right and within a single frame we probably uh just look into active Global widget and depending on active Global widget we can do draw open file dialog right we can draw open file dialogue I'm surprised this thing is not complete why this thing is not complete is that because not everything hmm okay so let me try to do the so for those who doesn't know complete uh means that if there is any case that is not handled in here it won't compile it sort of forces you to handle each and individual case in a switch case and this is a switch Case by the way uh right so it's in Jai it starts with if enjoy its test with you right you may say that it's it's kind of a weird switch case it is kind of weird switch case but in my opinion it actually works out really well uh it actually works out really well I can show you so it kind of solves one of the problems that I had with any other language out there so essentially quite often you write an if condition like uh you know x equal 10. right and you have some sort of like a process X and at some point you decide okay so X can also be equal to 20. so now I need to turn this into a switch case to turn it into a switch case like what do I have to do I have to change this uh key keyword right then I have to remove this entire stuff then make a case in here 10 right and then I have to put the break in here and like I have to rework the entire sort of construction I have to rework this entire Construction in giant what I have to do I have to just take this right side copy paste it case boom it's already switch case what the so yeah because it's it's actually a very common mutation of the code when you just have an if condition that you want to then turn into switch case so you can then add more cases in here it is actually very ergonomic surprisingly it looks weird at first but when you think about it it actually makes sense uh right so it allows you to quickly turn if into switch case um so this is kind of cool I think so it's just like you move that value and there we go you have a case branch in there so I don't know maybe this is not how the logic went and maybe uh John is going to change that in the future but this is how I interpreted the the reasoning behind this kind of weird construction and it kind of makes sense to me um that's actually a very good point and we have switch as a variable name free yeah exactly so it's actually very useful variable name um so let me try to do the following thing I'm going to um oh wait a second maybe not because I never actually edit a new sort of case in here so let me try to First build add this entire thing and let me try to build this entire thing and see if it is building so it is complaining uh because I forgot the semicolon in here okay so I think it's building it's taking some time but it is building because I'm on my machine on my old machine so if I put complete in here okay so there's something that is not handled in here and the question is what is not handled in here and the thing that is not handled in here is editors uh and I wonder why why editors is not handled okay so it's basically skipped I suppose yeah so essentially if I understand correctly the editor's case is when there is no active widget like the editor itself the main window is active so that's why it is not complete right because in that case you just want to ignore drawing any of these widgets in here I guess that makes sense right I guess that makes sense uh anyway uh and I suppose one of the things we want to add in here is just like uh save file dialog and we want to be able to draw save file dialog so uh draw file uh open the file dialog what do we do in here uh oh so it has a special ID so we need to allocate a special ID for this internet thing okay draw save file dialog and we do yeah so we're including open file dialog I'm not really sure if I want to do that in here so what is UI ID this one is rather interesting so is it defined anywhere in here uh so let's go ahead and search for this magical magical object I'm pretty sure it has the definition that looks like that there you go it is enumeration and essentially um open file dialog the rest will be derived from look do we have to add a new thing in here I'm gonna add a new thing in here I have no idea why it is like that but I'm going to add a new thing in here right so uh okay I'm just copying I'm just replicating whatever I have in here so this is a save uh drill save file dialog and this is what I see in here if UI active is not equal to none uh oh yeah I think this is a classical uh classical immediate UI stuff figure out the dialog box I'm surprised none of that stuff is abstracted away that is a pretty sophisticated choice and not gonna lie right so it's a draw open file dialog and it's a very sophisticated trison look at that um so yeah so UI active is basically what is the current active widget if uh something is currently active and that active thing is not us and that um and us is not the child and we are not child of the active thing we just close this intest so there's also scroll bar ID we probably don't need it right now but maybe we will so what I'm thinking is that we definitely will need this thing right so we definitely will need this thing but for the save uh file dialog so for this guy doesn't know what the is all of that right intermediate UI you track different widgets with like with unique IDs right you track them with unique IDs and that's essentially what we have in here and there's usually Global variables like this like what is the currently active that holds the current uh sort of like ID right and in here if nothing is active or something is active that is not us and uh we are not a child of something that is active so there is some sort of like a parent-child relationship between widgets in here I do not fully understand in that case we just hide the open file dialog which is rather interesting should we do this kind of stuff um should we do this kind of stuff for the safe file dialog maybe I don't really know but maybe let's just like you know use that but in that specific case we probably have to do uh you know save file dialog which means that we need to introduce a new thing that closes the file save file dialog like so and say file dialog so what do we have we have initialization and here we have a hide say file dialog and how do we even handle that in an open file dialog so hide open file dialog activate editors and what is activate editors uh that's a very interesting question maybe we can just call this function and that will basically just do the magic trick activate editors so what is going on where is the definition of this thing uh oh okay so it just sets the active Global widget to editors and makes the cursor blinking thing uh that's the whole thing so that's kind of funny all right so that makes sense um all right and let's go to draw and what else can we do so here we're trying to figure out the dialogue box size uh draw rounded rectangle maybe that's literally what I'm gonna do so there's a little bit of a math involved into figuring out the box full for the dialogue and let's just draw that box without any implementation or anything like that let's just draw that box and call it day right because our goal is to introduce something meaningful I suppose uh right and that's what we can try to do so let's try to compile everything that we introduce in here because I haven't compiled for quite some time so maybe it doesn't even work anymore okay so this one have to has to be save save file dialog so it's actually aligned because everything is here in here is perfectly aligned let's actually keep it tidy because this is not our code this is not our code we not do not enforce our rules into somebody else code we're guests in here when you're being a guest in someone else project you respect their formatting you respect their rules right so this is very important this is very important so when you come to somebody's project you do not argue uh what is the best formatting whether you have to use tabs versus spaces no you look what the project already does and you shut the up and just use whatever the project does that's how you uh you know respect somebody's else project right so you just respect the rules of that specific approach so so everything is here is aligned so we're gonna align it as well uh okay so uh what do we have in here cell file dialogue so what does it save uh is not a member of enumeration okay so we need to actually extend even more Innovations ah all right so let me see let me take a look at the definition uh so it's probably defined somewhere here now connective Global Ware active Global widget where are you oh okay you guys didn't even Define a separate enumeration here right see what you guys did in here okay okay okay so you yeah so you simultaneously Define a variable and enumeration fair enough fair enough uh so save file dialog so this is a new kind of a file dialog uh let's try to rebuild and what else do we have in here okay and this is why complete is so useful right so it makes you go through all the places where you have to modify this entire thing okay so active Global widget um handled aha so you have to handle events in here so it's kind of cool that I didn't really know what kind of methods do I have to put into my safe file dialog but through implementing like everything that is needed the code itself kind of tells me what kind of methods should they have in there uh so that's kind of cool [Music] all right so let's go and just implement this interesting so I think I'm going to copy paste um uh open uh file dialog so this is kinda this is what we want to have in here uh and it should return I could have actually copy pasted the whole signature in here uh save file dialog all right and what do we have in here so we map uh event to action uh and depending on what kind of thing we have in here it's going to be like different actions and what not uh so you know what I'm gonna do I gonna actually handling keys so even type key pressed and I want to actually see what kind of key was pressed right so how do I check like the uh like the keys the specific keys let me go into the map events to action let's find the definition of this thing because I'm pretty sure that's where it is all defined all right and where is the specific key uh key code right so this is the key code uh and in a save file dialog and key code is do we have like Escape something like Escape so in the case of Escape I just want to hide the save dialogue that's basically what I want to do right and in that case I suppose I want to return true and then here I'm going to return false right so essentially we want to create like a minimal basic safe dialog without any function functionality right so when we try to press Ctrl s we want something to appear like a rectangle and when we press Escape we want it to disappear so that's my goal for today at least right because implementing like a full function in save dialog is actually a very difficult task and it's probably over like two hours or anything like that um right so yeah I don't want to do that [Music] um yeah I know that I can look for for the keys in this module is just like go in there and just doing control F and stuff like that takes time so I just implemented something and if it's not going to compile only then I'm going to go there that's how I work right it's kind of weird sometimes but it's just like sometimes some of these small actions like take too much effort from me so I kind of postponed them until I do the the compilation phase where I just compile and go through the completion right because I don't want to break my flow uh if that makes any sense um anyway so uh I guess that's basically it I guess that's basically it so if I try to to try to compile okay so we go to that okay with percentage so this is something that we don't have uh in here aha this is probably part of the open file dialog there also if I go to open file dialog with percentage right so I think I saw it so this is uh this thing how much of the screen okay so we can literally add that thing to the save dialog in here because why not okay so that makes sense uh anything else do you want anything else okay um yeah so this is because I also need to do using using save file dialog have some sort of about the completion surprise one and declare it with normal and in open file develop what's what's normal is it defined anywhere I suppose it is defined okay so we can copy paste it here as well so it's a constant it's kind of cool that you can have constant in here I wonder can you access those constants like this uh you should be able to otherwise there is not that much point in defining them inside of the structure all right and declared a width animation oof this one is weird so there is some sort of Animation stuff okay so do you have like is there some sort of Animation when I like open this in typing this is kind of weird like why do you have animation probably I didn't see any animations to be fair but there's some sort of animation so let me let me see let me see so with any open file dialogue with a new uh to win animation it's probably doesn't have some sort of a state I can just include that I can just include this entire thing and see if it's going to compile at least maybe it will compile if it's some sort of Animation it has to be pulled somehow um so I'm not 100 sure um all right so input direct height so this is another thing aha and it very much depends on this kind of thing and the font UI line height so maybe we also need to include this kind of thing so I didn't fully copy paste everything apparently which is fine this is why we have compilation phase to actually tell us and declared thing entries okay so this one is interesting uh so this thing I suppose also renders the entries so entry height if I have an entry height so it is um so what if I say that the amount of entries we're going to have one right so what if we have just one entry in here um seems to be compound so I suppose this is the thing with the entries but we don't really care about the entries per se I think we care more about input yeah so maybe we should have not copy pasted this thing uh right so maybe we should not copy paste it this thing draw the filter input yeah let's actually try to put this thing in here [Music] I lost the draw input so cut top whatever well let's just keep it as it is so everything seems to be combined right everything seems to be compiling so let's go ahead and try to run the focus because debug debug so one of the things we have in here let me show all of the commands there should be save [Music] D where is save though so if I do new and then I do save okay so there is save all and Control Plus s I wanna find where do we call the platform thing so if we go back to the platform uh specifically for Linux platform so save get save file name let me see where do we call this entire thing record okay so we call this into places in a buffer save buffer to a new file on disk and save buffer to disk alright so and as you can see this entire thing is blocking this entire thing is blocking that means Listen to I think also should change isn't that I think also should change right so essentially this entire code should go somewhere else and save file on disk should basically activate the save widget um right or something like that so or yeah that's that's how we should go so for now what I want to do on Linux I want to Simply activate the save um the safe widget right right save file widget uh open didn't I have open file I think I never had it so that means in an open file dialog there should be show yeah show open open thing all right so because there's a hide and we need to to have a show show save file dialog and in here what we do we we do just additional thing but the most important thing we're doing here is uh set the active Global widget to save file developer right and essentially in the platform uh here what we want to do we want to show save file dialog right so if we are on Linux we're just gonna return false that means we couldn't save anything but we're also going to activate the save file dialogue just to test if it's going if it's going to show anything at all uh right so and let's go ahead and try to recompile the center I think I just want to see if it's going to show anything right if it's going to behave the way I expect it to behave um all right so it seems to be compelling and let me see so um I have this stuff right I'm gonna put some things in here right so let's write hello world and if I try to press Ctrl s do you see this should I say and according to the logic that we code it if I press Escape it should disappear okay outbound first try like I see this code base for the first time in my entire life uh you could say that this is because your experienced software developer but that also means that the code base is reasonable it is not convoluted so yeah it's more props to code base rather than me right I'm just a grapper I'm just a stupid grapper I look at the the code I see that it uses some functions I just grab those functions and that's it and if the code is good enough you will find you will basically follow these breadcrumbs and find the relevant places so yeah props the developers of focus this is a goddamn good code so compliments from zozin I do a proof of that so um yeah and essentially the only thing that is left to implement right is basically the functionality of the of the save dialogue right so I suppose you can just copy paste the chunks of open file dialog in here for uh navigating files and for filtering and stuff like that right but also there is a little bit of a difficulty with this part right because this specific call is expected to be asynchronous right it is expected to be asynchronous so that means um on Linux in here we just have to open the save dialog and simply exit out of this but it it goes even further because you see here you should return whether you manage to save this thing or not so the synchronicity of this API leaks even higher in the abstraction it leaks even higher so we need to look um somewhere here right so we need to look somewhere here [Music] where do we call this thing uh specifically yeah unsaved buffers so yeah so save buffers I think somewhere here maybe yeah so and essentially um the actual saving the actual saving should happen somewhere within the save file dialog specifically within the handing the events so essentially somewhere here if you press like enter right then you basically perform all of this saving code right all of that saving code you perform it there so where is the platform yeah so all of that stuff should go into save file download but this is a kind of a tricky operation and again so according to the to the discussion in here we want to preserve both like these asynchronous built-in editor window and also synchronous native one for the operating system so we should be able to handle like synchronous and asynchronous you know save dialogue simultaneously depending on the parameter or something like that so it gets even more complicated than that it gets even more complicated than that but I suppose the first step could be just implementing a functional save file dialog handle you know say file dial right um okay drop it thank you thank you so much for twitch Prime I made your channel because of my friend in uni it's been really helpful entertaining since uh you're welcome I'm really glad that people in universities watch me um thank you thank you thank you [Music] there is an unsaved file develop which saves staff probably I don't know so it means we need to actually go a little bit deeper than uh what I did in here because I did like a shallow very shallow thing um so what we can do can we do something like actually useful that could be used maybe in the future um right so we can partially implement this fiction we can uh let's create maybe put some sort of a text in here saying not implemented you let's point out just like literally yeah so just put the text not not implement it um so we oh then you could press escape and it's just like you can't save files on Linux um so let's go ahead and try to do this and so that means we have to do and draw it's kind of interesting that all of the drawing methods are located outside of the widgets so the witches themselves they don't really know how to render themselves and it's the responsibility of this draw module so yeah um so excuse me um so there's something I think the plan how can I jump to to this message is there anyway see okay see threads I can see the thread uh to remove the native dialogue and use an uh editor maybe you can confirm plan to keep both because some people need their uh custom pins in the window dialer oh okay I see that so I said by the way I I think that's like the main reason why Sublime uses the native like operating system dialog um right and even on Linux it uses jtk but I think I think on Linux Sublime uses jdk all the way through right so I feel like the menus like a file uh help and stuff like that are also jtk so I think it's like basically jdk application Linux I really hate the sublime way I use a package to avoid that um is this the editor written in batch yes it is it written in page so if you take a look at the languages it's 100 batch files can your Linux do that can your Linux I didn't freaking think so um anyway so uh draw save file dialogue so um [Music] um where how do you render the text is there so I suppose it's just like a draw text so there's the label okay so there is a label where do we use the label how do we use the label okay so it's just like a draw text um so this is the input rectangle [Music] um and draw text input oh it's just it's a text input specifically um so and in label yeah I see I see I see I see so maybe we can find something relevant within the draw text function itself it should probably uh do the usual prepare text yeah Sim prepared text and uh you know so small font icons small this one is interesting all right so we prepared the text so in the icon icon excuse me what the hell is icon icon is a string oh I can it could be actually like a Unicode something or whatever yeah and then we just draw that text so essentially the text is drawn through the um through the Sim oh yeah and font icon small is basically actually hints for that so you you basically store the icons in the font it's like font awesome or whatever right so it's a font with with icons and I wonder if we can is there like a form directory in here so there's a fewer code huh from I literally sent font awesome and you guys use fondos Okay so okay it's kind of bizarre to see that outside of web applications because I got used to seeing that specifically on web applications but maybe I've been out of the loop with like actual real software development for quite some time uh right oh we'll get some gifted subs thank you so much coycoder for gifting uh one month to Obi-Wan's thank you thank you thank you that's pretty cool oh I suppose everyone this is like the main developer of focus yo that's such an honor thank you so much thank you so much for visiting my string that's actually pretty cool the creator of the focus is actually watching our stream right now uh anyway so let's just go ahead and draw some text I suppose I'm going to just copy paste the center I think now the question is like where do we have to even do that draw file dialogue um so we draw the rectangle and what I'm thinking is that so this is the text width but maybe we have to use a different font what kind of fonts do we have I presume that this is a global thing right so it must be some sort of a global thing so we can find the definition of that stuff somewhere uh all right so default font icon small okay so font UI size let's actually use Font UI big size um it's just a size yeah it's not what I want this is what I want yes we used to use um formed UI yeah let's let's use Font UI I don't know what that is but I'm gonna assume that that's what I want so and this is going to be font UI um so save dialog is not implemented yep uh so that means this is going to be font UI character height and this is some sort of a button stuff so button X aha so here I see we're trying to Center that half of the books minus half of the text so this is a classical centering and I suppose um this is basically the rectangle so we can say boxrect right and that effectively will Center everything the text color right depending on what we have in here if enabled I suppose we can just like always use UI default and here we're using font UI I suppose that is it red okay so let's give it a try um I'm going to where is the Giant [Music] okay that's surprising about uh-huh so I'm gonna try to put some stuff in here and then control s say the look is not implemented yet yo thank you that was easier than expected so though I feel like Computing these specific books it's kind of Overkill like that right so because I couldn't paste it like a lot of this stuff from open file dialog and as you can see it's like it uses a lot of in here like is any of that really needed so also redraw requested like if if we just want to show something like this in here I feel like it's not needed um right on Linux uh yeah okay so dog is not implemented uh um Linux on Linux yet um yeah so let's actually divide that maybe it could have been done a little bit simpler but to make it simpler I actually have to read this entire thing and understand it and I don't want to I basically treat this chunk of code as a black box right so I know that in the output of that black box I have this thing that contains the rectangle that basically places this thing somewhere here how exactly does that I don't know and I just don't want to read this thing you know what I'm talking about so I'm just treating this piece of code as like a black box uh right so but I feel like it is overkill because it involves animation and stuff like that I'm not sure but maybe this part is a little bit of underkill but this one looks reasonable more or less this one looks reasonable so he used to use and let me try to run the focused bug and let's do a safe dialogue is not implemented on Linux yet alright so that is interesting I kind of I think like Escape didn't work did they break Escape Escape doesn't work though clicking away actually kind of works then Ctrl s Ah that's really weird why escape the script I remember it working actually um or maybe I'm hallucinating there because ah because I was explaining things and I changed the escape to enter as you know as an example and enter it happens to be a valid value as well so I see okay this kind of stuff happens to me way too over for some reason uh especially when I'm explaining things I just change the code but then I do not realize that the changes that I made actually affect the behavior of the code and it's just like then I spent an hour like to debug this thing instead uh yeah oh it's actually smaller but this is because that's kind of cool and then you press Escape there we go so does it make sense to submit that as a full request because essentially this is this could be like a first step towards a safe dialogue I guess right uh so it makes sense to submit that all right so I'm gonna work on that a little bit more off screen to make it a little bit more presentable um just cleans things up and stuff like that and I'm gonna submit that as a pull request uh I'm gonna submit that to the pull request I'm also not sure about the workaround with mu hash should I also submit that as a separate certificable request but I'm not sure about the new hash okay I'm going to explore research what exactly is going on with new hash and what I want to do I want to actually pinpoint exactly what's the illegal instruction what's the actual instruction in the code that my computer considers illegal and maybe look up or you know um yeah so maybe we just need to establish the the minimal you know instruction set for the for the application right so what's the minimum instruction set uh or something like that I know um [Music] honestly making it a text input instead of a disclaimer then calling save buffer with the text input as a file would be fine that's actually not a bad idea honestly right so we can try to do that um so let me let me see but how do you render the the input text input so let me see so let me copy paste this kind of stuff um so we had this stuff I'm gonna do if one and this one is going to be else the classical sort of like a flip-flop thingy uh right input direct cut top input react height okay so that makes sense then shrink get UI ID from location parent UI okay so I suppose this thing would work uh all right so so let's do it like that and maybe I'm going to do Focus debug so what did you didn't you like what did you actually like else without if really oh yeah I'm sorry it's like for a second I thought that maybe you can't have else in the compile time I'm sorry I think I'm already getting tired um right [Music] and uh that didn't work this is probably because we also don't handle the input uh we we never really rendered that way that freaking second week this is not enough it's a draw filter uh-huh draw text input and then we use the input okay okay yeah yeah so there's also label mm-hmm so let's go back so after that yeah yeah okay so this is a save file debug input we should have do we have input item remember actually we do have input okay so that's cool so this is the input rectangle uid you can see by the way I'm sorry so it is active and label um let's put path in there let's put path let's restart semicolon imagine asking semi for semicolons in 2023 come on what's that was that c was invented in 1970. all right would you look at that we've got the choice we've got the choice and it does not respond to anything because uh we don't handle the events there so let's actually go ahead and handle them somehow so now if I go to open file dialog a handle open handle yeah there we go so we probably pass oh event type this one is very interesting okay huh I really like that so if the event type is text the input weird so deflect propagating it into the input so if open file dialog navigate whatever nobody cares seems to be a bug in the text input module which generates text input event for Dell ooh thank you so much for the comments on here thank you that is aha so if open file navigate and character return true so we take in the character YouTube 32 and we're being careful because it might generate the delete thing here all right and then uh we just text input a character into the input okay okay that's cool and we should not forget to do the save file dialogue in here and interestingly I suppose we can do something like this ah this is not how we're supposed to do that yeah it has to be case uh-huh and I wonder yeah so let's put like this and now if I do enter uh this is where we can save the current file so this is where we can do that actually that's kind of interesting uh let's see if it's compiled or not so we're gonna put to do save the file right in the path we should get the path out of the input in here right so we should give the file uh so let me see let me see you know we could have actually we could have print something in there let's turn this into print come like this just to be able to see right enter true so this is to do essentially uh um alrighty so new file let's zoom in uh home streamer test dot C and yeah to do save file but that didn't yeah okay so that didn't hide it all right I think we're like already one step away from working save dialogue even a very scuffed one so uh what was the function uh one life's left suggested to use uh I need to find save buffer save buffer I wonder like let me try to find the save buffer functions like which one should I call though save buffer um so this is a buffer ID um editor buffer save new file so that's the problem though that's the problem so save buffer to disk yeah [Music] is there any function that we can just yeah because get buffer name get safe file name and this one yeah this one could be um buffer has file how can we get the file the buffer itself all right how can we get the buffer itself so first of all let me see uh the definition for the buffer it's a little bit annoying it's a tiny bit annoying and a little bit heckish so it has a file it has file buffer might not have a corresponding file um and net meme honestly when we press Ctrl s we call to the platform save uh you have to get the buffer ID from the active editor so it all looks a little bit complicated for the amount of time that I've left uh for the amount of time that I left so I don't think I'm gonna go with that route yeah so like I literally have like a couple of minutes left and not gonna go there but it's actually one step away from being able to save right so I I can see that it's just like one step away it's just like you need to do a little bit more routing and stuff like that and I'm already going uh you know for for two hours and I prefer not to do that uh right so my goal for today was to actually explore uh this text editor not only from the outside but more of it from the inside right so more from the inside we looked into the private parts of this text editor and we figured out how it works internally in such a pretty cool editor so I think it does have potential uh it does have potential and I really like how reasonable uh the source code is and how easy it is to to find things in there right so essentially what I'm going to do off screen I'm gonna probably finish this entire thing uh right and I can basically try off screen to like wire it up into saving the buffer and then submit it as a as a pull request so so we can have at least something working right so it's kind of scuffed but at least it's going to be working right so that's that's kind of cool right because as soon as you have something working you can improve it build upon it and uh a woman so forth all right so that's a pretty cool editor um I guess that's it for today thanks everyone who's watching me right now I really appreciate it have a good one and I see you all on the next Recreation programming session and we'll do something else as usual right love you
Info
Channel: Tsoding Daily
Views: 64,093
Rating: undefined out of 5
Keywords:
Id: AhPm8pv6dEs
Channel Id: undefined
Length: 106min 2sec (6362 seconds)
Published: Thu Aug 03 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.