Hi,
For fun I'm "porting" my UMIX UM implementation I wrote in C for ICFP 2006 to Pharo. For the sake of this, I need a really, really basic terminal emulator, honestly just a window showing text in a fixed-width font that I can read from and write to. Bonus if I can't move the cursor around and delete outputted text, but not necessary. CommandShell looks like overkill for what I need. I'd rather build something basic from scratch to learn more about Morphic. I'd appreciate any direction you could share with me. Thanks, — Daniel Lyons |
Hi daniel
I know that camillo and toon did a full repl command line editor So have a look at Coral packages. Stef On Apr 21, 2012, at 8:48 AM, Daniel Lyons wrote: > Hi, > > For fun I'm "porting" my UMIX UM implementation I wrote in C for ICFP 2006 to Pharo. For the sake of this, I need a really, really basic terminal emulator, honestly just a window showing text in a fixed-width font that I can read from and write to. Bonus if I can't move the cursor around and delete outputted text, but not necessary. > > CommandShell looks like overkill for what I need. I'd rather build something basic from scratch to learn more about Morphic. I'd appreciate any direction you could share with me. > > Thanks, > > — > Daniel Lyons > > |
Hi Stef,
On Apr 21, 2012, at 1:34 AM, Stéphane Ducasse wrote: > I know that camillo and toon did a full repl command line editor > So have a look at Coral packages. Very cool stuff, thanks. I think this is the inverse of what I need though. :) I just need a basic in-Pharo console-like-thing, not a way to run Pharo code from the regular console. Am I misunderstanding Coral? Thanks, — Daniel Lyons |
On Apr 21, 2012, at 9:57 AM, Daniel Lyons wrote: > Hi Stef, > > On Apr 21, 2012, at 1:34 AM, Stéphane Ducasse wrote: > >> I know that camillo and toon did a full repl command line editor >> So have a look at Coral packages. > > > Very cool stuff, thanks. I think this is the inverse of what I need though. :) I just need a basic in-Pharo console-like-thing, not a way to run Pharo code from the regular console. Am I misunderstanding Coral? Ahhhh have a look at transcripter :) because you will get an simple repl Why a workspace is not enough for you :) > > Thanks, > > — > Daniel Lyons > > |
On Apr 21, 2012, at 2:17 AM, Stéphane Ducasse wrote: > Ahhhh > have a look at transcripter :) > because you will get an simple repl > Why a workspace is not enough for you :) They might be! Sorry if I'm being dense. :) I hate to ask for this much hand-holding, but I'm just not seeing how it's done. Supposing I have an object with a #writeCharacter:aChar and #readCharacter selectors that read and write a character to/from the device respectively, what do I need to do to hook that object up to a Transcripter or a Workspace? And how can I force the font to be fixed-width? Thanks again, — Daniel Lyons |
runnnig it from real stdin / stdout won't help you?
Cause that's what I did with my readline implementation: - open an image from the command-line - run a readline instance in the image using FileStream stdout as output - test my implementation with the image and the real terminal side-by-side On 2012-04-21, at 10:34, Daniel Lyons wrote: > > On Apr 21, 2012, at 2:17 AM, Stéphane Ducasse wrote: >> Ahhhh >> have a look at transcripter :) >> because you will get an simple repl >> Why a workspace is not enough for you :) > > They might be! Sorry if I'm being dense. :) > > I hate to ask for this much hand-holding, but I'm just not seeing how it's done. Supposing I have an object with a #writeCharacter:aChar and #readCharacter selectors that read and write a character to/from the device respectively, what do I need to do to hook that object up to a Transcripter or a Workspace? And how can I force the font to be fixed-width? > > Thanks again, > > — > Daniel Lyons > > |
On Apr 21, 2012, at 5:34 AM, Camillo Bruni wrote: > runnnig it from real stdin / stdout won't help you? > Cause that's what I did with my readline implementation: > > - open an image from the command-line > - run a readline instance in the image using FileStream stdout as output > - test my implementation with the image and the real terminal side-by-side I suppose I could, but I was hoping to have it working inside Smalltalk. Also for didactic purposes. I intend to write something to visualize the registers in the CPU next. Is it the fixed-width font that's making it difficult to do from a UI inside Pharo? I could certainly compromise on that. — Daniel Lyons |
On 2012-04-21, at 18:51, Daniel Lyons wrote: > > On Apr 21, 2012, at 5:34 AM, Camillo Bruni wrote: > >> runnnig it from real stdin / stdout won't help you? >> Cause that's what I did with my readline implementation: >> >> - open an image from the command-line >> - run a readline instance in the image using FileStream stdout as output >> - test my implementation with the image and the real terminal side-by-side > > I suppose I could, but I was hoping to have it working inside Smalltalk. Also for didactic purposes. I intend to write something to visualize the registers in the CPU next. Is it the fixed-width font that's making it difficult to do from a UI inside Pharo? I could certainly compromise on that. well you could also plug my readline implementation to any text morph and set the a monospace font as default for code :) (that's what I have anyway). Manually creating a text morph an changing it's font to some fixed-width version is not that hard. And then depending on your needs you would simply edit / change the underlying text (in this case with even my readline implementation)... Check my implementation at: http://ss3.gemstone.com/ss/readline.html |
On Apr 21, 2012, at 1:19 PM, Camillo Bruni wrote: > well you could also plug my readline implementation to any text morph and > set the a monospace font as default for code :) (that's what I have anyway). > > Manually creating a text morph an changing it's font to some fixed-width > version is not that hard. And then depending on your needs you would simply > edit / change the underlying text (in this case with even my readline implementation)... I believe you but I seem to need a bit more explicit hand-holding. For example, when I create a new text morph, it winds up on the screen by itself with no enclosing window. Using the code derived from the TextMorph class comment: font := TextFontReference toFont: (StrikeFont familyName: 'Pragmata Pro' size: 16). tMorph := TextMorph new. t1 := 'This is fixed-width' asText addAttribute: font. tMorph contents: t1. tMorph openInHand. It doesn't seem to recognize Pragmata Pro or any other font name I put in, I always get the default font I set in my preferences (which is a system font and works fine). I see there's a FixedFaceFont class, but it looks like a completely different sort of thing. I also don't see how to get started with your Readline implementation. I'm sure I'd like to use it eventually but I want to get something basic working that I can understand first. Thanks again, — Daniel Lyons |
On 2012-04-22, at 17:53, Daniel Lyons wrote: > > On Apr 21, 2012, at 1:19 PM, Camillo Bruni wrote: >> well you could also plug my readline implementation to any text morph and >> set the a monospace font as default for code :) (that's what I have anyway). >> >> Manually creating a text morph an changing it's font to some fixed-width >> version is not that hard. And then depending on your needs you would simply >> edit / change the underlying text (in this case with even my readline implementation)... > > I believe you but I seem to need a bit more explicit hand-holding. For example, when I create a new text morph, it winds up on the screen by itself with no enclosing window. Using the code derived from the TextMorph class comment: > > font := TextFontReference toFont: (StrikeFont familyName: 'Pragmata Pro' size: 16). > tMorph := TextMorph new. > t1 := 'This is fixed-width' asText addAttribute: font. > tMorph contents: t1. > tMorph openInHand. > > It doesn't seem to recognize Pragmata Pro or any other font name I put in, I always get the default font I set in my preferences (which is a system font and works fine). I see there's a FixedFaceFont class, but it looks like a completely different sort of thing. indeed maybe a workspace will do just fine then :), sadly I'm not that much into morphic hence my partial approach here (that's why I personally find it far easier to directly use the terminal)... - check that you have freetype enabled in your settings (otherwise system fonts won't be recognized) - as a pragmatic solution I'd change the coding font globally to fixed-width (default in my images since I cannot program in a non mono-spaced font :P) "open a new workspace " ws := Workspace openContents: 'Initial Contents' " update the contents of the workspace" ws contents: 'new Contents' > I also don't see how to get started with your Readline implementation. I'm sure I'd like to use it eventually but I want to get something basic working that I can understand first. for the readline stuff check the test (that's generally the best place to see how code works ;) see class: RLReadlineTest a small example is given in RLReadline >> #readlineExample the basic principle is that you move around a cursor and put characters / strings there: RLReadline >> #write: RLReadline >> #writeAll: I know the readline implementation is quite complex for what it does, but you shouldn't bother too much and simply rely on the public interface and the example use-cases provided by the tests. best cami |
Cami,
On Apr 22, 2012, at 1:32 PM, Camillo Bruni wrote: >> It doesn't seem to recognize Pragmata Pro or any other font name I put in, I always get the default font I set in my preferences (which is a system font and works fine). I see there's a FixedFaceFont class, but it looks like a completely different sort of thing. > > indeed maybe a workspace will do just fine then :), sadly I'm not that much into morphic hence my partial approach here (that's why I personally find it far easier to directly use the terminal)... Yes, it probably would be, but I think the Smalltalk environment contains great power, I just need to learn enough to harness it, and that means baby steps. > - check that you have freetype enabled in your settings (otherwise system fonts won't be recognized) It is, and it works great, I'm using a system font everywhere else. I take it the invocation I used was not incorrect then? > - as a pragmatic solution I'd change the coding font globally to fixed-width (default in my images since I cannot program in a non mono-spaced font :P) I can live with that for a while. > "open a new workspace " > ws := Workspace openContents: 'Initial Contents' > " update the contents of the workspace" > ws contents: 'new Contents' OK, I can do that for writing, but for reading, I will need the read message to block until I type a character. Is there a way to do that with the workspace? >> I also don't see how to get started with your Readline implementation. I'm sure I'd like to use it eventually but I want to get something basic working that I can understand first. > > for the readline stuff check the test (that's generally the best place to see how code works ;) > see class: RLReadlineTest > > a small example is given in RLReadline >> #readlineExample > > the basic principle is that you move around a cursor and put characters / strings there: > > RLReadline >> #write: > RLReadline >> #writeAll: > > I know the readline implementation is quite complex for what it does, but you shouldn't bother too much and simply rely on the public interface and the example use-cases provided by the tests. Thanks, I'll dig through that later tonight. — Daniel Lyons |
In reply to this post by Daniel Lyons
On Apr 22, 2012, at 9:53 AM, Daniel Lyons wrote: > font := TextFontReference toFont: (StrikeFont familyName: 'Pragmata Pro' size: 16). OK, this works if I use LogicalFont instead: textArea := TextMorph new contents: ('This is a test' asText addAttribute: (TextFontReference toFont: (LogicalFont familyName: 'Consolas' pointSize: 14))) I bet there is a more abstract way of locating a font than using one of these two classes. — Daniel Lyons |
In reply to this post by Daniel Lyons
On 2012-04-22, at 22:00, Daniel Lyons wrote: > Cami, > > On Apr 22, 2012, at 1:32 PM, Camillo Bruni wrote: > >>> It doesn't seem to recognize Pragmata Pro or any other font name I put in, I always get the default font I set in my preferences (which is a system font and works fine). I see there's a FixedFaceFont class, but it looks like a completely different sort of thing. >> >> indeed maybe a workspace will do just fine then :), sadly I'm not that much into morphic hence my partial approach here (that's why I personally find it far easier to directly use the terminal)... > > Yes, it probably would be, but I think the Smalltalk environment contains great power, I just need to learn enough to harness it, and that means baby steps. well smalltalk spent too much time in the image, it kind of blinds you after some years :). plus by using the terminal you don't leave the environment at all, since you still control everything from within the image. >> - check that you have freetype enabled in your settings (otherwise system fonts won't be recognized) > > It is, and it works great, I'm using a system font everywhere else. I take it the invocation I used was not incorrect then? > >> - as a pragmatic solution I'd change the coding font globally to fixed-width (default in my images since I cannot program in a non mono-spaced font :P) > > I can live with that for a while. > >> "open a new workspace " >> ws := Workspace openContents: 'Initial Contents' >> " update the contents of the workspace" >> ws contents: 'new Contents' > > OK, I can do that for writing, but for reading, I will need the read message to block until I type a character. Is there a way to do that with the workspace? I guess there is a nicer way to plug things together, but I'd say keep an external text / String / readline and update the contents of the workspace each time they changed... I suggest you read the corresponding chapters in http://pharobyexample.org/ that should help you with most of the UI questions >>> I also don't see how to get started with your Readline implementation. I'm sure I'd like to use it eventually but I want to get something basic working that I can understand first. >> >> for the readline stuff check the test (that's generally the best place to see how code works ;) >> see class: RLReadlineTest >> >> a small example is given in RLReadline >> #readlineExample >> >> the basic principle is that you move around a cursor and put characters / strings there: >> >> RLReadline >> #write: >> RLReadline >> #writeAll: >> >> I know the readline implementation is quite complex for what it does, but you shouldn't bother too much and simply rely on the public interface and the example use-cases provided by the tests. > > > Thanks, I'll dig through that later tonight. > > — > Daniel Lyons > > |
In reply to this post by Daniel Lyons
Next problem, the TextMorph is always the size of the initial
string. It will grow vertically as lines are added, but I don't see how to make it resize to fit the frame. Any clues? window := StandardWindow labelled: 'Text test'. text := (TextMorph new contents: 'Hello, world!' asText). text fillStyle: (Color white). window addMorph: text frame: (0@0 corner: 1@1). window openInWorld. Thanks again, -- Daniel Lyons |
Free forum by Nabble | Edit this page |